Part 5: Node vs Rust
To me, Rust doesn’t feel as much like an alternative to NodeJS as it does an alternative to Go. With that said, I won’t go into much detail as most of the benefits of Go over NodeJS also apply to Rust. Rust does have some distinct advantages over Go, however, but may also be a little more difficult to get started with and scale in an enterprise setting, which is where Go really thrives.
Full Type System
For better or for worse, Rust has a far more complete and sophisticated type system than Go. Depending on the application this may be a good thing or completely unnecessary. For a simple CLI application, Go may be a better option. For an API in a sophisticated domain, Rust may be a better option due to its support for generics and polymorphism rather than Go's hacky use of interfaces and reflection.
Macros
Like Elixir, Rust has a macro system that can be used to extend the language, adding another layer of abstraction and sophistication. I haven't looked into the potential of macro support in Go 2, but regardless it may be in direct conflict with the goal of keeping Go simple and never make it into the language.
Zero-runtime
The genius behind Rust is its unique approach to memory management. Rather than using garbage collection like Go, Javascript etc, Rust uses the compiler to enforce rules around 'borrowing' that not only eliminates the need for a runtime and garbage collection, but also adds a layer of safety that you don’t get in other lower-level languages like C/C++.
This is where the innovation comes into play with Rust. As mentioned in the previous article, Go isn't particularly innovative, but was instead designed around productivity in the enterprise. Rust's zero-runtime design and approach to memory management elevates it above Go from a technical standpoint, but also come with added complexity that may not be needed.
Tokio
Although not part of the standard language, which has all the lower-level async primitives used in multi-threaded applications, Tokio adds an async runtime to Rust that rivals that of the ‘green threads’ of the Erlang VM as well as the goroutines in Go, and is also much better than working with OS threads. It will also be somewhat familiar to JS developers considering its use of Futures, which feel pretty similar to Promises.
Summary
Again, I wouldn’t necessarily say Rust is as much a competitor to NodeJS as Elixir/Go, but is more of a competitor to Go/C++/Java. Go can be used where raw performance isn't a requirement, but for the most low-level, modern and performant option Rust is the way to go.