Picking up Rust(y) habits: learning Rust as a JS developer
Published: 2023-05-04 04:16:35

Do you work with Javascript? I do: let's first pour one out for all the idiosyncrasies of the language we know and love and acknowledge that for all its faults, the JS/TS ecosystem is _thriving_: https://2022.stateofjs.com/en-US/conclusion/

While there's plenty of frameworks, micro-frontends and full-stack toolchains to master, there's something to be said for broadening your horizons. You may be wondering what other programming languages are worth learning, not least to expand your skills and improve your career prospects. 

I'm here to pitch one to you: [Rust](https://www.rust-lang.org/). Rust has gained a lot of popularity in recent years, let's explore why Rust is a good choice for Javascript developers to learn.

## What is Rust?
Rust is a systems programming language, originally developed at Mozilla as a personal project in 2006 by [Graydon Hoare](https://twitter.com/graydon_pub). It's designed to be a safe, fast, and concurrent language that can be used for a wide range of applications. Rust is particularly popular for developing low-level software, such as operating systems, device drivers, and web browsers. 

Yeah, that all sounds kinda dry, but how about this: Rust was named after a [hardy fungus](https://en.wikipedia.org/wiki/Rust_(fungus)), due to one of its primary strengths being the [enforcement of memory safety](https://en.wikipedia.org/wiki/Memory_safety). This is a key strength of the language, we'll come back to it.

## Why should I learn Rust?

Here are five reasons why Rust is a good choice for you to learn right now in 2023:

### 1. Performance and Safety

One of Rust's primary advantages is its speed and safety. Rust is a compiled language, which means that code written in Rust is transformed into machine code that can be executed directly by a computer's CPU. This makes Rust much faster than interpreted languages like Javascript. Additionally, Rust has built-in memory safety features that prevent common programming errors, such as null or dangling pointer errors, which can cause crashes or security vulnerabilities. 

Hot take incoming: _This means that Rust code is much less likely to cause bugs or security vulnerabilities than Javascript._

### 2. Compatibility with WebAssembly

[WebAssembly (WASM)](https://webassembly.org/) is a low-level, portable bytecode format that is designed to be executed in web browsers. WASM allows developers to write high-performance code in languages other than Javascript and run them in the browser. Rust is an excellent language for writing code that can be compiled to WASM, meaning that you can write Rust code that can run directly in the browser, alongside or instead of Javascript. Check out this guide for the how and why: [https://developer.mozilla.org/en-US/docs/WebAssembly/Rust_to_wasm](https://developer.mozilla.org/en-US/docs/WebAssembly/Rust_to_wasm)

### 3. Learning Rust can improve your Javascript skills

Rust and Javascript are very different languages, but learning Rust can (albeit indirectly) improve your Javascript skills. Rust emphasizes the importance of code organization, strict typing and modularity - for me personally, I enjoyed being shaken out of my comfort zone by developing in Rust and making small, simple projects that allowed me to learn (and fail) and iterate quickly.

### 4. Rust's growing popularity
Rust is a relatively new language, but it has been rapidly growing in popularity over the past few years. Many large companies, such as Microsoft, Amazon, and Mozilla, have adopted Rust for in-house projects. Learning Rust now can put you in a good position to take advantage of the growing demand for Rust developers in the future. There are some projects that track programming language popularity such as the [Tiobe index](https://www.tiobe.com/tiobe-index/), which ranks Rust in the top 20 languages. 

### 5. Have your cake and eat it
OK, fine, you might not be ready to wholesale drop our beloved JS and jump ship entirely, I understand. But what if I told you that you can leverage all the power of Rust _within_ your Node projects? Let me introduce you to Neon: 

[https://neon-bindings.com/](https://neon-bindings.com/)

![Screenshot of the Neon Project homepage](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qi7dujazkn4s1x8y2w53.png)

## Wrap up

Rust is a powerful and versatile language: its speed, safety, compatibility with WebAssembly, and growing popularity make it an excellent choice for Javascript developers to learn. 

Whether you're looking to improve your skills, build high-performance web applications, or explore new career opportunities, Rust is definitely worth checking out.

[https://www.rust-lang.org/learn](https://www.rust-lang.org/learn)
[https://www.youtube.com/channel/UCaYhcUwRBNscFNUKTjgPFiA](https://www.youtube.com/channel/UCaYhcUwRBNscFNUKTjgPFiA)