Is learning Rust worth it?

If you are into System Programming, chances are you have heard of Rust. And if you are reading this article, chances are you are thinking what's all the hype about? In this article I will try to give you some idea about why I think Rust is awesome, based on my experience in same stack.

I am fairly new in System Programming. I work in higher level languages like PHP, Python, JavaScript, Lua etc at my workplace - Divine IT Limited. And last year I had to work on C, mostly for two reasons- 1) We had an old C based real-time server and 2) We had some PHP and MySQL extensions written in C.

As I had some very basic experience on C (from university contests mostly), pretty soon I was pulling my hair due to memory leaks. And that real-time server had multiple threads working together with a global state. After days of fighting I got used to with C (And actually liked it).

Recently I am experimenting with Rust, and it surprised me in a couple of different areas. Those are -

Memory Management #

Rust successfully identified issues with memory management and why those exist at all. If you never code in languages like C, it would be hard to imagine what memory leaks feels like. Most low level languages gives full control over memory for sake of speed and control. But doing it right is hard. On the other end of the spectrum is high level languages like Python, which gives you pretty safe platform to write code without worrying about memory at all. But you get less speed and control as a result. Rust completely stands out on this area. It gives you option to take control with some simple rules, so that possible leak gets identified in compile time. It can be little daunting at first to grasp on, but it pays off later. And if your rust code compiles, you can have a good sleep while your code is in production.

Dependency Management #

Again, if you played with makefile or cmake ever, you know what working with 3rd party library feels like in C. And things like, working on cross-platform project can be very overwhelming for inexperienced programmers. Rust has its own package manager Cargo. Anyone worked with composer, NPM or gradle can get easily familiar with it. Adding a dependency, multiple release flavors are easy to manage with a single tool and in a cross-platform fashion.

Programming Paradigm #

This can be a controversial topic to talk about. But for me Rust is kind of in a sweet spot of different programming paradigms. I think Rust took good things from both worlds OOP (Object-Oriented Programming) and FP (Functional Programming). And it does not force to choose one strictly, it gently recommends what seems good. So if you are from either world it has something for you. Just do what fits you.

Interfacing with Other Languages #

Rust is a perfect fit for you, if you are in need of speed in your existing codebase. For us, its almost never a good idea to write whole project from scratch in another language. But still you can get benefited by implementing critical parts of your application with Rust. It has very good API to build extensions for other languages.

Documentation & Community #

Rust has awesome documentation and very friendly community. Most articles & videos on Rust written by very passionate Rustaceans. They even have a website for searching them. There are lots of very high quality libraries to use. Even though its fairly new, in terms of programming languages, its being loved and used by lots of talented programmers.

So, is it worth learning Rust? Definitely. Learning any programming language can give us something new. And Rust is not like another language to toy with, you can actually go to production with confidence. If you have to write some code in lower level languages, you can count on it. Even though it says it's a System Programming Language, projects like Rocket, Yew shows potentials of targeting other areas with it. To conclude, learning Rust is not only fun, but you can work on your next big thing with the safety of Rust.