The dark side of Rust Language

Rust is an amazing language. If you follow my blog activity and know me in person you might know I'm really invested in rust on the last +12 months and also blogging a lot about Rust. Now I want to do something different. I do not want to paint a rosy picture of Rust. I do believe trade-offs matter and you only know something true when you know the cons. There are some problems I will expose in this blog post and not related to rust only but related in fact about two other factors. A) "New" languages. Rust has +10 years however still not mainstream and I still consider it a new language. B) New Paradigm / Approach - everything you deviate from standard C/OOP you will face resistance, I saw it happens a lot with other languages like Scala and Clojure. These problems happen in rust but I want to make it absolutely clear they are not unique to rust. So Let's get started, let's start with the Good things.

The Great Things About Rust

Before talking about rust benefits you might want to talk a look into some blog posts I made about Rust.

* Rust - The Language of the future: Rich Type System, Correct and Fast
http://diego-pacheco.blogspot.com/2019/07/rust-language-of-future-rich-type.html

* Rust and Java Interoperability
http://diego-pacheco.blogspot.com/2019/09/rust-and-java-interoperability.html

* Running Rust Service in Kubernetes with only 3.5MB
http://diego-pacheco.blogspot.com/2019/09/running-rust-service-in-kubernetes-with.html

* Building a Microservice with Rust
http://diego-pacheco.blogspot.com/2020/01/building-microservice-with-rust.html

Now let's talk about Rust Language benefits:

Live: Rust is a live language. It has a community, tech events, new ideas, and libraries are flowing and popping up every single day. I would argue this is one of the most desirable properties of a language. You want to be where the innovation is happening.

Interoperability: Rust plays very well with pretty much all other languages. It's very easy to invoke this language from rust and vice versa. For this reason, rust is really great for embedded systems and IoT for instance.

Easy To Read: Rust code is obvious, it's very easy syntax and therefore very easy to read the code. The ability to easily read the code is really important for a maintenance perspective and for learning.

Functional Vein: Rust allows functional programming, you have lambdas, Optional, map, find, filter and much more. Functional programming is a really great paradigm and a modern language needs to fully embrace it or at least partially.

Memory Allocation: Rust really forces you to think about memory allocation and memory management. Most of windows bugs are related to memory allocation issues. The Windows team is also considering using Rust.

Zero Cost of Abstractions: This is another great rust capability. Several languages have great syntactical sugar and features however often using the abstractions are SLOW compared with standard features. Rust does not have this problem.

Libraries variety: Rust has a great variety of libs and ecosystems. Crates.io has over +35K libraries.

Speed: Rust is super fast. Faster than Java, Go, C++. Rust is only slow compared with C but is not really bad. Compared with high-level languages like Java, DotNet, Go, Python, Ruby - Rust is super fast and much better than these languages in sense of speed. which means: Doing less with more, saving costs(if you are running on the cloud) and better user experience.

Safe: Rust is also super Safe. As long as you dont use the "Unsafe{ }" feature.  This is one of the main advantages of Rust. The compiler is really your friends and catches a lot of things.

Web Assembly: Web Assembly is the future of the web and the implementations are in Rust. This is another very attractive point for the language.

Small Binary, Small Footprint: Rust is not a memory sucker like Java. Rust generates very small self-contained binaries which are really great for containers like Docker and Cluster managers like Kubernetes.

Great for Concurrency: Rust is also strong in concurrency, having channels, Thread Pools, and Futures. The language provides a variety of great options and good syntax for concurrent programming.

My Personal Thoughts are that coding in rust is a pleasure and makes me learn new things and write better software. However not every ting are roses in Rust - let's talk about the dark side now.

The Dark Side of Rust

Small Market: Currently there are few companies using rust. Therefore a few programmers and few job offers. I do believe the market size will increase but if you need a massive number of developers now and it cannot afford their education - Rust is not a good choice for you now!

Too Many Strings: Rust has issues with String. Rust has 6 String types. String, Str, CString, Cstr, OsString, Ostr. Wich makes it complicated and confusing. Some functions return Str and you need to convert to String. String and Str have different functions.

Slow Compilation: As you have +200 dependencies you will see compilation become super slow. Everything or almost everything is statically linked which makes compilation slow and you have lots of outdated libs in your FS.

IDE Support is not Ideal: I'm VsCode is the best option so far but it has flaws. RLS is slow and crashes often in VSCode compared with the console. RLS code completion does not work well 100% of the time.

Libraries low maturity: Several libs are incomplete and immature. Often you find poor documentation and documentation that is not up-to-date. This making uses a library always an "adventure" so you need to look at the source code. It's often not copy-paste-n-work.

Rust is not for Beginners: Concepts like Borrow and Ownership take time for you to internalize. Try calling a function 2 times with the same variable. Rust will punish you, you won't be able to compile your code. Rust requires discipline and learning. If you cannot pay this price, do not use Rust, maybe you should consider Go or even Java instead.

Rust is a great language. I believe rust will grow a lot in the new years. Documentation, library maturity, Jobs/Engineers, Tooling support issues tend to get fixed. However, Borrow and Ownership is not going away so you will be required to learn.

Cheers,
Diego Pacheco

Popular posts from this blog

Kafka Streams with Java 15

Rust and Java Interoperability

HMAC in Java