Why hasn't Discourse been rewritten in Rust?

Discourse is memory-safe. Ruby is a memory safe language; all garbage collected languages are. The main difference to Rust in this regard is when the safety checks are performed; Rust does them at compile time, Ruby does them at runtime.

Rust tackles only a few classes of errors, mainly those caused by C++'s lack of garbage collection. It certainly is cool that they found a way to do that while maintaining the performance benefits theoretically possible with pointers, but it by no means prevents the sort of bugs you’d see as a user. For example, if I use < when I meant <=, and get an off-by-one error as a result, Rust won’t save me. If I forget to spawn a success message after an action is complete, Rust won’t save me.

What actually does prevent bugs is the sort of test-driven development Discourse already deploys. There are very few projects which you can just deploy straight from master and expect them to be stable, but Discourse is one of them.

“modern platforms” are popping up left, right and center using JavaScript for backend and frontend. Ruby is 2 places behind Rust in popularity (Kotlin is between the two), so it’s hardly a rare language at the moment. Sure, in another 10 years things may look differently, but even a rewrite to Rust would be tech debt in 10 years.

It’s hard to convey just how naive that statement is, which is why everyone is laughing at the idea. I’ve seen my devs refactor code for 3 years now, and they’re only just ready to start porting from wxWidgets/ShuttleGUI to Qt/QML - which, for context, is a migration from C++ to C++, just a different UI toolkit. It’s just hard to transform code while also ensuring that the behavior stays identical. 12-16 days is the time you’d need just for planning before anyone gets started probably.

15 Likes