Moving from NodeJS to Rust in 2019

Bastian Gruber
4 min readMar 8, 2019

For a more nuanced introduction and in-depth introduction to web programming in Rut, read part 1 of X in my series.

If you followed me for the last few weeks or months on twitter, you saw that I take Rust pretty seriously lately.

In this article I want talk about my reasoning behind it, and why you as a NodeJS developer should consider the same.

Rust is the new JavaScript

JavaScripts appeal comes mainly from it’s easy-to-use and available-everywhere characteristics. It’s the only choice in the browser to build applications.

It also shines on the server side of things with its easy to use frameworks, easy syntax and no static types.

Building a web application with NodeJS takes literally a few hours. And with React on the frontend you have a always evolving and powerful tool to build complex applications.

So why is Rust the new JavaScript then?

  • Rust is available not only on the server, but also runs on hardware
  • With WASM, Rust will be able to run in the browser as well
  • As a frontend developer, NodeJS helped you to get into server-side programming. Learning Rust will help you covering the whole stack from hardware to server to frontend

Rust is the logical next step

NodeJS was so successful that even large applications got build with it. However, one missing piece was and is its type system. With no static types, Microsoft had to step in and create TypeScript. It offers many people who had to move from C++ and Java a familiar environment.

However, now instead of learning JavaScript, you are learning a tool from Microsoft which adds another layer on top of all the other layers to make JavaScript run on the server.

Learning TypeScript is bad pain, learning Rust is good pain

When you learn TypeScript, you mostly cope with a tool which is there to improve a language which lacks well thought through features.

If you want types, and you might need them in bigger applications, you can move to a typed language right away. Why bother with a transpiler?

Types

You know the saying: The biggest strength is also your biggest weakness?

Well with Rust, the thing you will love the most is its static type system. It will take some time though. The type system will prevent you from easily deploying a CRUD app in under one hour, but it will help you in the long run crafting sophisticated, safe and fast applications.

And once you are used to it, you can create your own “rust-web-starter” app and get the same benefits of crafting fast prototypes as you would with Node.

Rust is the new Bitcoin, but better

I painted a pretty simple picture: Why would you then choose Rust over, lets say Go? Since Go has static types as well (although, generics are not yet a thing yet in Go-land).

Because Rust is the new Bitcoin. The majority of contributers are not working for Mozilla (who took over the Rust project and published it). The development of the language happens in the open, and everyone can contribute. Decentralized if you wish. Everything happens on GitHub and in Discord.

If Mozilla would completely abandon the language, it would still live on and flourish. Go however is solely maintained within Google, and we all know what happens to most Google projects after a few years.

It doesn’t seem like Go will go anywhere, the language is great and you will be super productive with it. But so is Rust, plus it has all the other features.

Documentation

When I talked about “leveling up” in the beginning, I meant leveling up. You don’t have to read through StackOverflow to fix some random problem.

The Rust docs are superb. You have to get used to them though. The structure and explanations make more sense once you start building your own applications and need help.

The Rust Compiler

Your biggest enemy and your best friend. The term “good pain” couldn’t be more accurate when it comes to the Rust Compiler. You will hate it that even simple exercises will fail in the beginning and you can’t even easily pass Strings around.

But, once you got the hang of it, you realize the biggest strength of the compiler:

You can pair program with the compiler and be sure to have crafted a solid application afterwards

Rust is still evolving, and you might live in a city where the community is not strong yet! So what? The Rust Compiler knows everything, and if it approves your code you can feel safe and secure.

Obviously…

Rust is as well:

[UPDATED 03/10]: Here is Part 1 of X of how to get started with web development in Rust from a NodeJS perspective.

📝 Read this story later in Journal.

🗞 Wake up every Sunday morning to the week’s most noteworthy Tech stories, opinions, and news waiting in your inbox: Get the noteworthy newsletter >

--

--