How to combat JavaScript fatigue with Rust
Tags: node, rust
Published: 2019-03-20 19:05:24

---
title: How to combat JavaScript fatigue with Rust
published: true
description: NodeJS is a fantastic tool. Blog posts are full with 5 minute tutorials, and companies using it up and down the Fortune 500 latter. However, developers using NodeJS have a different story to tell.
tags: nodejs, rust
---

Do you find yourself in any of those thoughts when creating applications with NodeJS?

- "I for sure need to pick the right npm module to solve this problem, but which one fits best and is getting supported well?"
- "Uh, my app is growing so big, I have no idea what the difference between `user` and `customer` is anymore and which properties they have."
- "TypeScript will definitely solve my problems!"
- "Hm, I don't know if this is an error with TypeScript or in the transpiled JavaScript? Or did I just disable the wrong ESLint option?"
- "Is this all what I will do for the rest of my career?"

Creating JavaScript applications is easy at first but it's getting harder and harder once the application grows. You can wait and hope that any of the big tech companies will solve your problems through TypeScript and other tools. A few years go by and you ask yourself: Is this all? Do I create CRUD application for the next 20 years?

It is sometimes harder to keep up with the latest [hype train](https://dev.to/tomekponiat/javascript-predictions-for-2019-by-npm-pie) then actually learning fundamentals. 

NodeJS became a victim of its own success. The market is flooded with developers, every company is using Node in some part of their tech stack. You can say that companies don 't pick it because of it's underlying technology but because they can get cheap labor and feel safe because all the other companies are also using Node, so it must be a good choice.

## Meet Rust

You probably know the saying that you should learn Lisp, even if you won't use it, just because the learned mindset will make you a better developer? Instead of learning Lisp to become a better developer, you can learn a language which is actually in use and will improve you as good as Lisp does. Meet Rust. Rust is not the latest hype, but has [fundamentals](https://arxiv.org/pdf/1903.00982.pdf) which offer you a wide range of opportunities, even in the long run. 

> [Rust](https://www.rust-lang.org/) is a systems language, but it's ergonomic syntax empowers the developer after the first struggles. 

From a NodeJS perspective, Rust can be used to create web server applications and  services. You can write [Lambda functions](https://aws.amazon.com/blogs/opensource/rust-runtime-for-aws-lambda/) or full fledged applications. Instead of using TypeScript, Rust has a strong build-in Type system. Instead of using ESLint, it ships with the [pickiest compiler out there](https://vorner.github.io/difficult.html). 

The pain you feel in the beginning is different. I call it good pain. Good pain lets you grow as a person (and developer), bad pain just hurts. I would categorize many of the TypeScript and NodeJS pains as bad pain. Not because the tools are bad, but a language which was created in [10 days](https://en.wikipedia.org/wiki/JavaScript#History) just gets you so far. 

At some point you need to make a personal decision of how your life should look like. Your day to day has a huge impact on your happiness and the well-being of your surroundings. Rust can help you rediscover the joy of programming again.

After you learned Rust, you may think you just replaced tool X with tool Y and end up in the same place. But, there is a difference. Once learned, you can use Rust to create:

- Games
- CLI tools
- Operating Systems
- Web Services
- Browser Applications
- Applications on Embedded Devices

One would say you can cover the whole stack. Rust creates a self feeding system:

- Developers from C, C++, Java, Kotlin, Python, Ruby and JavaScript flock to the language
- Rust and its features are getting discussed not only in a web context but in a wide range of scenarios
- Different areas, perspectives and use cases are getting fed back into the language in an [open way](https://predictablynoisy.com/rust-governance)

## Lets picture a perfect world 5 years from now
You are writing your web service in Rust. Instead of installing five different npm modules which help you cover your mistakes, you are using build-in tools to harden your code base. After the compiler gives you a green light you are 98% sure your application will run [safe and fast](https://youtu.be/cDFSrVhnZKo?t=1865) in the years to come.

But, hold on, you are still sometimes frustrated by the repetitive work environment. But now you mastered a language which you can use to build your own [Operating System](https://os.phil-opp.com/) on the side, you can implement the [TCP protocol](https://www.youtube.com/watch?v=bzja9fQWzdA), you can [create Games](http://arewegameyet.com/) and join a local game community. You can even create applications for the Browser which are [compiled to WASM](https://webassembly.org/). If this is not enough, you can get yourself a piece of hardware and [run Rust on it](https://www.rust-lang.org/what/embedded).

## Node is not gone

NodeJS won't be completely gone, and your skills neither. However you found a great addition and you might just focus on Rust more in the future. Remember, no language survived forever. NodeJS could end up with the same faith as PHP and others. Picking a systems language like Rust gives you strength and opportunities for many years to come.

## Should you learn Rust?
From a developers perspective: Yes, definitely. Rust has many unique features which will be copied also to other programming languages ([like Ownership in Swift](https://github.com/apple/swift/blob/master/docs/OwnershipManifesto.md)). Learning Rust sharpens your thinking and will make you more considered in your day-to-day language of choice.

From a safety and correctness perspective: You should aim to replace part of your web service with Rust. Start small and see where it leads you. Other companies like [NPM](https://www.rust-lang.org/static/pdfs/Rust-npm-Whitepaper.pdf), [Dropbox](https://www.wired.com/2016/03/epic-story-dropboxs-exodus-amazon-cloud-empire/) and [Yelp](https://www.youtube.com/watch?v=u6ZbF4apABk) are doing it and had big success.

[Rust for the web is not completely there](http://www.arewewebyet.org/), but once fully landed, it can not only convert your web services into safe bets. Once mastered, Rust lets you jump up and down the stack, explore Computer Science concepts first hand and build tools in your free time other then the next CRUD application.

So, take the chance and make 2019 the year you learn Rust. Have [something in production](https://dev.to/gruberb/web-programming-in-rust-02x-deploy-your-first-app-1k05) by Christmas and try to replace part of your services at work in Rust and see if it's successful. Rust will not only let you sleep calmer at weekends, knowing that a rock solid [binary](https://doc.rust-lang.org/book/ch14-01-release-profiles.html) is running in production, but the skills you gained let you explore a vast universe of possibilities around technology.

> I will help you with that. Follow my series on ["Practical Web Development with Rust"](https://dev.to/gruberb/intro-to-web-programming-in-rust-for-nodejs-developers-lp) and build with me a shiny web application in the next few months.