Why JavaScript Developers Are Learning Rust

Every major JS tool is being rewritten in Rust: Turbopack, SWC, Biome, Oxlint, Rolldown, Lightning CSS, Tailwind v4’s Oxide engine. If you’re in the JS ecosystem, Rust is becoming unavoidable.

JavaScript β†’ Rust Translation

Variables

// JavaScript
let name = "John";       // mutable
const age = 30;          // immutable

// Rust
let mut name = "John";   // mutable
let age = 30;            // immutable (default!)

Functions

// JavaScript
function add(a, b) { return a + b; }

// Rust
fn add(a: i32, b: i32) -> i32 { a + b }

Null Handling

// JavaScript β€” runtime crash if null
const user = getUser();
console.log(user.name); // πŸ’₯ if null

// Rust β€” compile-time safety
let user: Option<User> = get_user();
match user {
    Some(u) => println!("{}", u.name),
    None => println!("No user found"),
}

The Ownership System (The Hard Part)

This is where JS devs struggle. In JavaScript, the garbage collector handles memory. In Rust, YOU manage it through ownership rules:

  1. Each value has one owner
  2. When the owner goes out of scope, the value is dropped
  3. You can borrow references (read-only or mutable, not both)
let s1 = String::from("hello");
let s2 = s1; // s1 is MOVED to s2, s1 is invalid now!
// println!("{}", s1); // ERROR: s1 was moved
println!("{}", s2); // OK

Where to Start

  1. The Rust Book β€” free at doc.rust-lang.org/book
  2. Rustlings β€” interactive exercises
  3. Build a CLI tool β€” your first practical project
  4. Then try a web server with Axum or Actix