by melling · 6y ago · 0 comments
Are there any anecdotal stories about how Rust programs have fewer errors?
Facebook, for example, rewrote Messenger with ReasonML:
https://reasonml.github.io/blog/2017/09/08/messenger-50-reas...
And it had a lot fewer bugs:
"Messenger used to receive bugs reports on a daily basis; since the introduction of Reason, there have been a total of 10 bugs (that's during the whole year, not per week)! *"
https://www.rust-lang.org/static/pdfs/Rust-npm-Whitepaper.pd...
Excerpt:
> npm’s first Rust program hasn't caused any alerts in its year and a half in production. "My biggest compliment to Rust is that it's boring," offered Dickinson, "and this is an amazing compliment." The process of deploying the new Rust service was straight-forward, and soon they were able to forget about the Rust service because it caused so few operational issues. At npm, the usual experience of deploying a JavaScript service to production was that the service would need extensive monitoring for errors and excessive resource usage necessitating debugging and restarts.
My hobby projects are in Rust and Go. Its personal taste, but I prefer programming in Go. I actively dislike programming in Rust.
In Go, I usually I start a debugger once a week because I need to understand the cause of a bug or panic. I have no idea how to debug Rust, because in 2 years of Rust, I haven't had that type of low level bug.
In my previous gig, we had a premium website hosting platform, and our incoming clients would usually want their old inbound links to keep working. Over time, this meant a few hundred thousand autogenerated rewrite rules in Nginx. This was causing Nginx to use about 10G of memory, so restarting it, which we had to do every time we added a redirect, was an issue.
I replaced this with a small reverse proxy written in rust that loaded all of the redirects from postgresql into a cuckoo filter. Adding a redirect was an INSERT, followed by a NOTIFY to let the proxy know to add the redirect to the filter.
Putting it all together took about 2 weeks of swearing at the compiler, but it never had an issue in production, and used about 1M of memory, while adding less than 1ms of latency, or about 4ms in case of a filter hit. Cuckoo filters can have false positives, so if a redirect was found, we still had to check in the db table before returning 301.
As far as I know it's still working fine, and I use rust whenever I can.
My anecdote is that programming in Rust intuitively "feels" like programming in languages like OCaml or Haskell, which have a reputation for "you'll often spend a lot of time fighting the compiler, but when your program finally does compile, it's much more likely to work correctly on the first run than other languages (e.g. C, C++)."
It's wholesome development, if there were such a thing. I feel good and proud of the code I write in it.