Hacker News new | ask | show | jobs
by Malidir 621 days ago
Would Rust and it's memory safety stuff have prevented this?
4 comments

In some sense, yes. Use-after-free is impossible in safe Rust (if you don't use the unsafe keyword)
I'd argue that this is a good example of how rust could've prevented use-after-free, but y'know, I'd obviously be glazing.
It's not as easy as everyone might think. You could take a look at this thread titled 'My big problem with Rust is too much "unsafe" code' [1].

[1] https://news.ycombinator.com/item?id=41792477

Java too !
The difference being that no one in their right mind is thinking of rewriting a browser in Java to also make it faster, while that's exactly what Servo/Stylo etc are all about.
And don't forget Ada.
And OCaml or Haskell :)
Why go fancy? Even Python saves you from use-after-free.
Come on, I had to outbid Ada somehow :)

For what it's worth, Python was also considered at some point for use in the Firefox codebase. I don't remember the rationale for not adopting it, but I think the idea was "we all like Python, but we already have one messy language (JavaScript), let's not make it two".

Brainfuck too!