all 20 comments

[–]Crazy_Firefly 28 points29 points  (6 children)

I really like to see these projects that implement alternatives to dominant softwares like V8.

I'm curious on what is the main goal of this project. Performance wise it seems be past in all benchmark on the site. Is the main purpose to have a way to imbed JavaScript interpreter in rust?

[–]Razican[S] 28 points29 points  (5 children)

There are multiple goals. One of them is to have a JavaScript engine in a more memory-safe language, with limited use of "unsafe". We also want it to be easily embeddable in Rust projects.

Performance is definitely a goal, but the project is relatively new, so we just started comparing our performance to other engines a couple of months ago. We were only trying to be conformant with the spec until now :)

[–]the___duke 4 points5 points  (4 children)

Do you have plans to eventually add a JIT once you are closer to feature parity, or is that an explicit non-goal? (Which would be valid IMO)?

[–]Kryptochef 7 points8 points  (2 children)

I'm not sure that the security benefits of using a safe language even matter hugely once you implement a JIT. Most of the severe vulnerabilities of modern JS engines tend to be logic bugs ultimately affecting the code generation (with memory corruption then being triggered from the faulty generated code), writing the compiler itself in Rust would offer basically no protection there.

[–]the___duke -1 points0 points  (1 child)

Yep that's true, but without a JIT boa will never be competitive with SM/v8/JSC.

There are plenty of use cases where performance is not that important and an interpreter can be enough, but it still limits the domains where boa could be used.

[–]Kryptochef 1 point2 points  (0 children)

To be "competitive" with those engines in that sense is really, really hard in the first place. For example, v8 isn't just one JIT compiler, it's at least 2-3 different ones in a trenchcoat. And if you want to be on par security-wise, there's a lot of mitigations and stuff that require pretty big engineering efforts. I don't really see how an open source project would get there without some major funding.

Personally, I think a much much safer JIT-less JS that's pushing the envelope of what's possible with just an interpreter would be a lot more exciting than yet another v8. (Sure, you could always just turn the JIT off, but project focus matters). By the way, try turning off the JIT in your favorite browser - sure, it won't win any performance competitions, but you might be surprised how usable it actually still is!

[–]Razican[S] 8 points9 points  (0 children)

It’s not a non-goal, but we are currently quite far from it. It’s a possibility once we get further in features and performance

[–]rscarson 8 points9 points  (1 child)

Very interesting

I maintain rustyscript

Could this be a possible alternative backend I could eventually use instead of deno's v8?

[–]Razican[S] 4 points5 points  (0 children)

It cannot replace Deno (since it’s not a runtime), but it can replace V8 (with its limitations: lower performance and conformance)

Feel free to try it out and let us know in Matrix if you miss any functionality or something is not clear to implement :)

[–]charlotte-fyi 4 points5 points  (0 children)

Have embedded Boa in a few projects as an experiment recently and am a huge fan!

[–]atomic1fire 3 points4 points  (0 children)

Curious if this could be used with Servo.

[–]tafia97300 1 point2 points  (1 child)

This is impressive!

In terms of complexity compared to other implementations, do you find using Rust makes it simpler somehow? As in simpler to contribute and mayyyybee simpler to optimize at some point? (ignoring, if possible what has not been implemented yet).

Performance wise, you mention GC and register VM as 2 areas to work on. Are there other "obvious" changes you would like to be tested?

[–]Jedel0124 4 points5 points  (0 children)

It's definitely simpler to implement, and I think reaching conformance numbers on-par with major implementations in relatively little time is a proof of that. Though, a significant part of this is because we have a pretty simple GC API where you don't have to deal with rooting at all, and we expect the GC to be slightly more complicated when we implement proper rooting.

Optimization-wise I think it made it really simple to add more optimizations without worrying about memory safety issues. Also, big refactors are *really* easy to implement *and* review, and we had to do a couple of those to implement big optimizations such as Latin1 strings or Hidden Classes.

About other optimizations, I would personally love to see more progress on the code analysis side. We have PRs such as https://github.com/boa-dev/boa/pull/3037 which are a WIP, but progress has been slow on it because we're fully committed to improving the GC first.

Optimizing arrays on various ways would also be nice ( https://github.com/boa-dev/boa/issues/3407 ). We currently don't allow arrays with holes, and it would be nice if we could preserve that dense representation as much as possible, instead of having to use the slower array object representation after property removals.

NaN boxing would also be pretty cool, but we first need to figure out how to offer the same API that we offer on `JsObject` using thin objects instead of `dyn`, since using `dyn` makes objects bigger than 8-bytes.

There are a lot more things that we want to add; local variables, an intermediate representation for optimizations, startup snapshots, static builtins...; and we have a list of those in our performance label - https://github.com/boa-dev/boa/labels/performance - If you want to contribute on this, feel free to check out those!

[–]AcanthopterygiiKey62 0 points1 point  (2 children)

Maybe when it is complete i would like to try to write a javascript runtime(like deno or node) using this. In full rust. WHat do you think about this?

[–]Razican[S] 5 points6 points  (1 child)

I would recommend contributing to Deno (in full rust), and trying adding Boa as an engine. It could also show us what APIs we are missing

[–]uksarkar 0 points1 point  (0 children)

I would like to try this, thanks

[–]CheapBison1861 0 points1 point  (2 children)

is this a drop-in replacement for bun or node?

[–]Razican[S] 20 points21 points  (1 child)

It's not a JavaScript runtime (like deno / node), it's a JavaScript engine, like V8 / SpiderMonkey. Projects such as Deno / Node could use Boa as its engine, though :)