Why Rust?

Your code can be perfect

Rust gives you the opportunity for your code to be truly perfect. Its way of handling errors and optional types are explicit and elegant at the same time. Its closures and iterators are so powerful and concise. Its traits allow the same functionality of polymorphism without all of the drawbacks experienced in other languages. Rust’s enums and pattern matching are the best allowing for every case to be handled and making invalid states impossible (representing state machines is flawless).

Imperfect code is detrimental to businesses. Downtime results in lost revenue and breaks trust with users. Rust’s strict and rich type system paired with its explicit error handling produces some of the most reliable code. A lot of companies resort to tests and other various processes to hopefully catch errors. You can do that in Rust but the type system and the compiler catch bugs long before anything down the chain catches it. This allows for a faster feedback loop and a better development experience.

Unlimited control with a modern experience

Many languages such as Python and JavaScript can do many jobs. They are used at the largest companies to power various backend applications but there comes a point when Python and JavaScript just don’t cut it anymore. They run into various roadblocks when it comes to controlling what is going on in the application and it runs into many barriers when it comes to performance. The reasons why so many companies choose Python and JavaScript are for their entire development experience. Between PyPi and NPM you have hundreds of thousands of packages to choose from. They are supported in various runtimes and almost every major company has SDKs for JavaScript and Python. Rust is able to achieve many of the things that JavaScript and Python are able to do (specifically on the backend) and in many cases, Rust gives you the ability to have added control beyond what JavaScript and Python can offer. Rust’s package manager, cargo, also has over one hundred thousand packages to choose from and many are mature and well-maintained.

Minimal compromise

For the longest time, you were stuck between 3 choices. You could choose speed (C and C++), memory and type safety (Java and C#), or a “modern” experience (Python, Ruby, PHP, and JavaScript). Depending on the application you were building, you would have to weigh the different pros and cons and pick a language with many compromises. We’ve seen a massive slew of memory issues from C and C++. We’ve seen companies deal with colossal scaling issues (both in terms of technical scalability and the number of engineers that can comfortably work on the code base) with Python, Ruby, PHP, and JavaScript. And we’ve seen the exhausting developer experience of bloated Java and C#.

Rust dominates in all three categories with near-zero compromise. It has the performance of C and C++, it’s memory and type-safe like Java and C#, and it has a modern developer experience (excellent package manager, concise syntax, well supported, tooling, community, etc) like Python, Ruby, PHP, and JavaScript.

Frequent concerns

  • Steep learning curve

    With any programming language, there is a large fixed set of things that every language has. Rust front-loads most of those concepts to the beginning. A language like JavaScript will have you encountering unlearned aspects of the language far into your career.

  • Long compile times

    This is mostly a nonissue. There are ways to circumvent this in development and it’s mostly a nonissue in production CI.

  • 3rd party packages haven’t hit maturity yet

    This is true in some cases. They aren’t as mature as other libraries such as many Java libraries. Rust does have some that are very mature that can be found at https://blessed.rs.

  • It’s a “systems programming” language

    Why use a “systems programming” language when you could use a “scripting language” like Python? When we define what a “system” is in software engineering we realize that we are using “scripting languages” to build “systems” such as backend servers and more. We’re only starting to come to terms as a larger community and realizing that languages like Python, Ruby, JavaScript, and others are terrible for building “systems” especially when exposed to larger scales.

  • Small standard library

    Rust is very much on the opposite end of the spectrum as compared to something like Java or C# in regards to standard library size. This mainly comes from the fact that the internet is more significant than ever, and more people are working on open-source libraries every day. Rust takes an approach where it lets the community decide what is important and how things should get built. This decentralized approach to how a language develops typically results in better outcomes. Bad 3rd party library decisions are usually isolated and are quickly usurped by better libraries. Bad decisions in core libraries are usually more detrimental to the language as a whole and they are less frequent if there’s just less to maintain.

  • It would be faster to build xyz in Python, JavaScript, etc.

    That is usually the case for teams of 1 or 2 developers. Once you start adding engineers or you already have a large team, languages without types tend to actually be slower in the long term. When you are developing a code base with any amount of code already written, one of the tasks you have to do is gather enough context to effectively understand what you should be doing. In languages like Python and JavaScript, you have almost no context as to what variables actually contain or what functions return. This makes new engineers working in new code bases work slower. Engineers working in Python or JavaScript resort to inline documentation but these docs have no guarantees that they are correct or up-to-date like a proper type system guarantees.

Conclusion

Obviously, the conclusion that I have come to is that Rust is by far the best programming language. I hope that I’ve been able to provide some strong arguments in favor of that position. Ultimately you’ll have to come to whatever conclusion by comparing Rust yourself. There are also some important caveats that I appended to this article that can also be considered when coming to a conclusion.

If this and/or other sources have piqued your interest in learning Rust, I would recommend starting with “The Book” or checking out the other resources provided on Rust’s website.

Caveats

  • This comparison mainly focuses on backend development (which is the majority of software engineering). There are other specializations that require specific languages. Game development is still heavily C++, frontend development is heavily JavaScript/TypeScript, mobile is Swift/Kotlin, data is Python, etc. A lot of these could benefit from Rust but the ecosystem is better for the respective languages.

  • There are two languages I didn’t compare Rust to because they require some more in-depth comparison. TypeScript and Go have also emerged as powerful contenders.

    TypeScript encounters a lot of the same problems as JavaScript. It suffers from extremely poor performance. Although it adds a type system on top of JavaScript, it can be pretty loose and perform poorly. I have never used a language that encounters so many non-deterministic errors in CI and experienced so many runtime errors that should have been caught in development. The main redeeming quality of TypeScript is the massive ecosystem and tools that are built for TypeScript. Things such as Vercel, Deno Deploy, and Cloudflare Workers make TypeScript an attractive option. TypeScript is also an attractive option due to the fact that it’s usually quite prevalent in other areas of your stack such as the frontend. Having fewer languages to maintain as a company has advantages. I personally choose TypeScript for frontend and Rust for backend as this plays to their strengths.

    Go sits in an interesting position. Go solves a lot of the same problems that Rust solves. It’s got decent performance, it’s type and memory safe, and it has a pretty decent ecosystem. It also has an easier learning curve than Rust does. So why Rust over Go? One huge difference. Compare the way that Rust and Go handle errors and optional values. This may seem like a minor difference but in practice, this is a big deal. As developers, we are prone to introducing bugs into our code and we need all the help we can get. Rust helps us handle each case that we should handle. Go simply allows us to not handle errors or not take into account if the data being accessed is potentially nonexistent. Although I would never choose Go and despite these tradeoffs, Go remains an attractive solution for backend systems.