Live data from Hacker News

Nova: A JavaScript and WebAssembly engine written in Rust

trynova.dev

21–30 of 70 posts

Re: Nova: A JavaScript and WebAssembly engine written in Rust

#21
OP, since you're here in the comments can you talk about the binary and memory size and sandboxing support? Ability to import and export functions/variables across runtime boundaries? Is this a feasible replacement for Lua scripting in a rust application?

Re: Nova: A JavaScript and WebAssembly engine written in Rust

#22

More ways for Servo to be all-Rust, OK!

That is one explicit goal, maybe next year realistically: Servo has asked for help making their JS engine bindings layer modular, and I have a self-serving interest in helping achieve that :)

Re: Nova: A JavaScript and WebAssembly engine written in Rust

#23
post #12
post #7

Hi, main developer of Nova here if you want to ask any questions! I'm at a choir event for the rest of the week though, so my answers may tarry a bit.

Given the fact that you were so precise in your time estimate on interleaved garbage collection, how long do you think it would take to get to 99% of the tests?

Haha, I think that was a one time fluke! :D

I'm aiming for something like 75-85% this year; basically get iterators properly done (they're in the engine but not very complete yet), implement ECMAScript modules, and then mostly focus on correctness, builtins, and performance improvements after that. 99% would perhaps be possible by the end of next year, barring unforeseeable surprises.

Re: Nova: A JavaScript and WebAssembly engine written in Rust

#24
post #10

Earlier quoted context omitted.

Essentially implementing JavaScript on top of the ECS architecture :D

Yup! My whole inspiration for this came from a friend explaining ECS to me and me thinking "wouldn't that work for a JS engine?"

I've seen this brought up a couple times now, but I never get it. Why would ECS fit a JS engine? The ECS pattern optimizes for iterating over ton of data, but a JS engine does the opposite of that, it need to interpret instruction by instruction which could access random data.

Re: Nova: A JavaScript and WebAssembly engine written in Rust

#25
post #8

Earlier quoted context omitted.

Hi, Nova dev here. Yes, basically. And removing structural inheritance.

Can you elaborate on "And removing structural inheritance"? Does that mean Nova doesn't use traits, and if so, why would that matter?

Traits are a type of interface inheritance; base classes and inherited classes à la C++ is structural inheritance.

So basically it just means that I have to write more interfaces and implementations for them, because I don't have base classes to fall onto. Instead, in derived type/class instances I have an optional (maybe null) "pointer" to a base type/class instance. If the derived instance never uses its base class features, then the pointer stays null and no base instance is created.

Often derived objects in JS are only used for those derived features, so I save live memory. But: the derived object type needs its own version of at least some of the base class methods, so I pay more in instruction memory (executable size).

Re: Nova: A JavaScript and WebAssembly engine written in Rust

#26

Earlier quoted context omitted.

Yup! My whole inspiration for this came from a friend explaining ECS to me and me thinking "wouldn't that work for a JS engine?"

I've seen this brought up a couple times now, but I never get it. Why would ECS fit a JS engine? The ECS pattern optimizes for iterating over ton of data, but a JS engine does the opposite of that, it need to interpret instruction by instruction which could access random data.

Indeed, there's no guarantee that it will fit: I think it will but I don't know and want to find out.

There are strong (IMO) reasons to think it will fit, though. User code can indeed do whatever but it rarely does. Programs written in JS are no less structured and predictable than ones written in C++ or Rust or any other language: they mostly operate on groups of data running iterations, loops, and algorithms over and over again. So the instructions being interpreted are likely to form roughly ECS System-like access patterns.

Furthermore, it is more likely that data that came into the engine at one time (eg. one JSON.parse call or fetch result) will be iterated through at the same time. Thus, if the engine can ensure that data is and stays temporally colocated, then it is statistically likely that the interpreter's memory access patterns will not only come from System-like algorithms, they will access Component-array like memory.

So: JS objects (and other heap allocated data) are Entities, their data is laid out in arrays of Components (TODO laying out object properties in Component arrays, at least in some cases), and the program forms the Systems. ECS :)

Re: Nova: A JavaScript and WebAssembly engine written in Rust

#27

OP, since you're here in the comments can you talk about the binary and memory size and sandboxing support? Ability to import and export functions/variables across runtime boundaries? Is this a feasible replacement for Lua scripting in a rust application?

Hmm, sorry, I'm not sure what you mean.

The engine is written with a fair bit of feature flags to disable more complicated or annoying JS features if the embedder so wants: it is my aim that this would go quite deep and enable building a very slim, simple, and easily self-optimising JS engine through this.

That could then perhaps truly serve as an easy and fast scripting engine for embedding use cases.

Re: Nova: A JavaScript and WebAssembly engine written in Rust

#28
post #12

Earlier quoted context omitted.

Given the fact that you were so precise in your time estimate on interleaved garbage collection, how long do you think it would take to get to 99% of the tests?

Haha, I think that was a one time fluke! :D I'm aiming for something like 75-85% this year; basically get iterators properly done (they're in the engine but not very complete yet), implement ECMAScript modules, and then mostly focus on correctness, builtins, and performance improvements after that. 99% would perhaps be possible by the end of next year, barring unforeseeable surprises.

have you considered using js polyfills to help you get closer to 100% coverage and then replacing with native implementations prioritized by performance impact?

Re: Nova: A JavaScript and WebAssembly engine written in Rust

#29
post #10

Earlier quoted context omitted.

Essentially implementing JavaScript on top of the ECS architecture :D

Yup! My whole inspiration for this came from a friend explaining ECS to me and me thinking "wouldn't that work for a JS engine?"

I'll be checking this project out! I'm a big fan of ECS and have lofty goals to use it for a data processing project I've been thinking about for a long time that has a lot in common with a programming language, enough that I've basically been considering it as one this whole time. So it's always cool to see ECS turn up somewhere I wouldn't otherwise expect it.

Re: Nova: A JavaScript and WebAssembly engine written in Rust

#30

More ways for Servo to be all-Rust, OK!

That is one explicit goal, maybe next year realistically: Servo has asked for help making their JS engine bindings layer modular, and I have a self-serving interest in helping achieve that :)

Nice to hear!
Post reply on HN