Hacker News new | ask | show | jobs
by ezbie 13 days ago
I dont get the point of this.

Developers rewrite code in rust for memory safety, not speed.

5 comments

Python and Node are already memory safe. If that were the only thing that mattered, Rust wouldn't be a thing.
Rubbish. There are at least three big reasons to use Rust:

* Memory safety

* Performance

* Logical correctness

People definitely rewrite in Rust for speed. To be honest I would say memory safety has been overegged as an advantage - yes obviously you want memory safety, but I think some people think it's the only advantage Rust has, when logical correctness (due to the stronger type system) is definitely in the same league.

I recently did it only for speed honestly. Python is quite slow in many cases, like a small operation on millions of lines of text. I tried the rust version and it removed that bottleneck, it's quite easy with AI. It's mostly for manipulation of strings, for math we already have numpy, numba, pytorch etc.

But in many cases a rust version already exists (like for tokenization etc.). I wouldn't advise to write it yourself if a supported repo is already doing it.

As we just saw in the MS outage, making it run faster might be introducing race conditions that were previously shadow conditions. You have the correct take. Rewrite the parts that are bad, not the parts that are slow.
As far as I can tell, the only reason people rewrite things in Rust is so that they can make HN posts about rewriting a thing in Rust that didn't need rewriting in the first place.