Is Rust the right language for your team?

Oliver Hu
5 min readFeb 26, 2024

…thoughts after a few months into Rust

Mar 7

I’ve written ~10k loc in Rust now, and I am well on the climbing slope of englightenment. Looking back at last update, I was a bit over desperate :) I still hold that it is not practical to train the whole engineering group a new language in a non-expanding company, however, I am getting more and more comfortable doing anything in Rust. I am really looking forward to my own next update on my Rust experience!

Feb 25

This is a quick reflection of my short journey learning Rust (and some retro of my previous experience using Swift). Even though it has only been a few months of part time developing with Rust, my experience has pretty much assembled the diagram below (some folks argue this diagram is not a true correct reflection of Dunning-Kruger effect, but it is off topic for this blog’s discussion)..

“Know-Nothing”

I always knew Rust is not an easy language and those “lifetime”, “borrow checker” are monsterous, it is also a relatively new language. When a senior engineer touted an idea that “all new infra projects should be in Rust”, I was quite appalled by his idea.

Quoting my own pushback in Slack group chat:

We adopted Swift for iOS since version 1.2, a huge mistake, a super crappy compiler without even incremental compilation + missing inter operatbility with many ObjC/C++ libraries. We later switched back to ObjC(rewrite half the code). After 3 years of migrating to ObjC, Swift becomes actually much more usable.. so we started another journey to move from ObjC to Swift again

This is unfortunately not exaggerated, the dev tooling for Swift was so bad that each compilation used to take 5 hours for our iOS code base (with ~50 engineers after 6 months of development). I had a previous blog on the Swift journey.

Compared with Java -> Rust, ObjC -> Swift transition could have been a much more seamlessly positive experience if the dev tooling had worked. Both ObjC and Swift are ARC, Swift is safer with strong types (crash rate reduced by 95%ish iirc), most iOS APIs are similar across the two languages, and Swift is also quite performant (tho there was no ABI so binary size was bloated quite a lot).

So my take for this stage was, no thanks, we are happy with Java for backend infra, Go and Python for our AI platform.

Peak of “Mt. Stupid”

Surprisingly, after I spent the first 2 weeks using Rust during my parental leave, I fell in love with the language. The syntax are quite nice and it reminded me of all the gorgeous part of Swift. I wrote a pet side LLM inference project in Rust and it worked pretty well. The best part compared with my previou ObjC -> Swift traumatic experience is that — the dev tool for Rust is amazing. Another Slack quote of myself …

Spent sometime catching up on Rust outside of work, it’s amazing. Besides the known benefits, dependency management, dev tooling, debuggability are all great. It’s quite similar to the Swift syntax, the lifetime concept is not that hard to grok, worth some POCs. Haven’t explored its ecosystem at length tho.

Looking back after 2 months of that message on reflection — Geez, that was such an utterly stupid claim. I had no idea of lifetime at all when I sent that message and I was discussing with other people that Rust seems like a good languge to bet on. My whole code base back then had 0 lifetime annotation since I didn’t have any shared code (only business logic).

Valley of Despair

Well, the honeymoon didn’t last long. I fell from the peak of Mt Stupid to the Valley of Depair. I was completely defeated by Rust after another two weeks into refactoring my pet project to build a common interface for CPU and GPU (so I only have one code path for the transformer forward pass) — I spent probably 2 full days, made 0 progress, and could not figure out what the heck is going on. In the end, I resort to the Rust User Community forum for help and realized I practically knew nothing about Rust. I read a few more blogs from the Rust core team, man, this is such a hard language and I barely scratched the surface of the core values of the language (with cautious optimism that I will be proficient in it after 1,000 hours into it ;)

By the way, I was surprised by the kindness and responsiveness of the forum.

Verdict?

As someone who just passed the valley of despair and being enlightened, my take on Rust is closer to my thought at the Know-Nothing stage — it might not be the language that you want to use for everything for every developer. If you build everything in Rust and only expose Rust libraries for your customers, I am quite confident folks will hate you.

If your team is already full of Rust talents, there is no reason to switch to another “easier” language at all. Linus once discussed why Linux kernel is still in C rather than more modern/safer language. He mentioned writing safe and robust code is already a habit for kernel developers, and there is no need to invest in a new language for that at all.

If your team is mostly familiar with GC/ARC languages, for product teams, I would say don’t switch to Rust. For platform teams, check your ser/de, probably tune GC a bit and upgrade to a newer Java version, rather than re-training the whole team to another language.

What about about infra teams where the incumbent talents are heavily using GC/ARC languages? I think unless the company is in a fast expansion phase with infra teams well staffed and abundant external budget/headcounts, it is not a bad idea to invest in Rust for some core infra projects where the requirements for robustness/performance/tail latency are extremely high. Or if the leadership has decided to dump JVM for a choice between C++ vs Rust, it might make sense to re-train the whole team in Rust than C++.

Otherwise, under current economic condition, you’re likely constraint to internal talents, and it is gonna be quite challenging to transform the whole team to think in a different language.

--

--