Hacker News new | ask | show | jobs
by Cthulhu_ 1865 days ago
I'm pretty confident we'll see a JS engine written in Rust at some point in the future, it'll just take a very long time to get parity with V8 and will likely introduce its own slew of issues.
4 comments

I don't know about a JS engine written in Rust. Well, I'm sure it will be attempted (no doubt it's being done right now), but I don't see a path to success.

Like you say, it would take a long time for a Rust JS engine to reach parity with V8. But long-running projects need real use-cases to succeed... they drive support and provide direction/feedback. How much will a half-baked Rust JS engine be adopted when a mature, stable V8 or SM is available? Will the projects that do so be successful themselves? A pure Rust JS engine might be destined to peter-out well before becoming viable.

A better approach (though less satisfying) might be to convert an existing engine incrementally. But even there, there probably needs to be continuous, compelling benefits along the way to justify the increased complexity and large amount of additional work. Imagine release after release where the main item in the release notes is "rewrote another subsystem in Rust"... followed by a bunch of bugs in the previously stable subsystem. I know SM has some Rust bits, but I'm not sure how far that is really going to go.

I don't see any benefits (for me, the user) if its written in Rust. Yes, Rust has nice features for more security+stability for the developer, but just because a JS Engine would be written in Rust wouldn't mean its automatically better than V8. It's not the programming language that gives the edge in this case, it is the amount of time, sweat and grease that went into V8. And other engines would have a long way to come.
I rather imagine we'll see a wasm vm/runtime in rust, and a typescript/js to wasm compiler written in typescript...
> I rather imagine we'll see a wasm vm/runtime in rust

Like Wasmtime? https://github.com/bytecodealliance/wasmtime

Yes, but we would also need an event loop I guess. As I understand it nodejs is essentially a (c++) js runtime inside a c++ event loop. But I think we already have a rust event loop (or two?)
Parts of the Firefox JS engine (SpiderMonkey) are written in Rust (although nothing really significant I believe).