4 ms·
JIT engines like this one don't receive much benefit from being rewritten in a memory-safe language. Errors typically occur in the generated machine code, not i
by sstangl 6y ago
JIT engines like this one don't receive much benefit from being rewritten in a memory-safe language. Errors typically occur in the generated machine code, not in the compiler itself. The benefit would be small.
- tannhaeuser 6y agoThat's exactly the point I wanted to make (but failed to) a couple months ago [1] - that for the (few) tasks you'd use C for (such as writing language runtimes) Rust might not be a good fit. If it isn't a good fit for regexp, it might not be a good fit for JavaScript either. [1]: https://news.ycombinator.com/item?id=22661930 https://news.ycombinator.com/item?id=22661930
- JoshMcguigan 6y agoIt’s not that rust wasn’t a good fit. It’s that writing a regex engine from scratch in rust to be integrated into their c++ code base wasn’t the right choice for them when compared against integrating an existing c++ solution.
- monocasa 6y agoThere's more benefits to Rust than just it's memory safety. It being a non-GCed language with ADTs is a big one, and that's been nice for the couple JITs I've written in Rust. And the partial memory safety over the metadata around the actual JITed code is a big win as well. Yes, Rust doesn't get you there 100%, but IMO it gets you closer than C or C++.
- saagarjha 6y ago> It being a non-GCed language with ADTs is a big one C++ has both, too, so in this case Rust's only advantage would be memory safety.
- monocasa 6y agoHaving used both (and in the space for writing JITs particularly), C++'s support is very weak in the space of ADTs. Like most things in C++ you _can_ reach it with straight jacketing yourself in a particular way, with 80/20 static analysis rules backing that and 20% manual code review, but it's difficult to maintain. Rust gives you that more or less by default and for free wrt tooling. It's sort of the classic "Rust makes you write the C++ you should have been writing all along", which makes it a net win IMO.
- saagarjha 6y agoIt might be weak, but I think every browser engine makes do with what they have available fairly well…
- monocasa 6y agoGiven the fact that Mozilla is the primary sponsor of Rust, and Rust has been sneaking its way into Chrome as well, I'd say the authors of those browsers disagree with you.
- saagarjha 6y agoI'm not them, but I suspect that they're slowly switching not because of its slightly better abstract data types but because it offers better memory safety.
- monocasa 6y agoThose are one and the same. The ADTs are how the shape and validity of the data is described to the compiler in a lot of cases. Rust wouldn't be able to be memory safe without it. C++'s ADTs are easy to subvert even accidently; Rust's can't be without explicitly calling it out as unsafe. It allows you to describe transformations of state in a formal set theoretical way. You should check out formally verified software like CompCERT and sel4 and their heavy use ADTs internally to achieve that. Rust obvs isn't full formally verified but it's a neat 80/20 in that direction.