Skip to content

Introduction — Why Rust for TypeScript Developers

You write TypeScript. You ship Node.js services, CLI tools, and React applications. You understand types, async/await, modules, and package management. That knowledge transfers — this course uses it as the bridge into Rust.

TypeScript solves a real problem: it adds types to JavaScript so bugs surface at compile time rather than in production. Rust takes that idea to the extreme — it makes an entire category of bugs (memory corruption, data races, null dereferences) impossible by construction, without a garbage collector.

Here is the core value proposition:

  • Memory safety without a GC. No garbage collector pausing your program. Memory is tracked at compile time via the ownership system. You get the safety of a managed language with the performance of C.
  • Fearless concurrency. The same ownership rules that prevent memory bugs also prevent data races. If your code compiles, concurrent access is safe — the compiler says so.
  • Predictable, near-zero latency. No GC pauses, no JIT warm-up, no VM overhead. Rust programs start fast and stay fast.
  • Great tooling from day one. cargo is the best package manager and build tool in any systems language. rustfmt formats your code. clippy catches common mistakes. The ecosystem will feel familiar.
  • The compiler as a helpful teacher. Rust’s error messages are legendary. When you make a mistake, the compiler explains what went wrong and often suggests the exact fix. It is strict, but fair.

TypeScript (and Node.js) is excellent for:

  • Web APIs and backend services where developer velocity matters
  • Frontend and full-stack JavaScript applications
  • Rapid prototyping

Rust shines for:

  • Performance-critical services (low-latency APIs, data pipelines)
  • WebAssembly modules compiled from Rust and called from your TypeScript frontend
  • CLI tools and developer tooling
  • Systems programming, embedded, and anywhere a GC is unacceptable

The good news: you do not have to choose. Many production systems use both — TypeScript for the web layer and Rust for the hot path or WASM modules.

This course is structured as a series of side-by-side comparisons. Every concept starts with what you already know in TypeScript, then shows the Rust equivalent.

Intro module (you are here):

  • Why Rust? Mental model shifts.
  • Installing the toolchain (rustup, cargo)
  • Hello, world
  • Project anatomy (Cargo.toml vs package.json)

Rust 101 — Fundamentals:

  • Variables, mutability, shadowing
  • Functions and expressions
  • Control flow (if, match, loops)
  • Structs (vs interfaces and classes)
  • Enums and pattern matching
  • Collections (Vec, HashMap)
  • Option and Result (vs null/undefined and try/catch)
  • Modules and crates (vs ESM and npm)

Both snippets do the same thing. Notice that Rust looks structured and familiar, but has some notable differences: no semicolon on the last line of a function means “this is the return value”, println! is a macro (not a function), and there is no runtime — just native machine code.

TypeScript
// TypeScript
function add(a: number, b: number): number {
return a + b;
}
const result = add(3, 4);
console.log(`3 + 4 = ${result}`);
const language: string = "Rust";
console.log(`Time to learn ${language}!`);
Rust
fn add(a: i32, b: i32) -> i32 {
a + b // no semicolon = this is the return value
}
fn main() {
let result = add(3, 4);
println!("3 + 4 = {result}");
let language = "Rust";
println!("Time to learn {language}!");
}

Run the Rust snippet above directly in your browser. No installation needed.

fn add(a: i32, b: i32) -> i32 {
a + b
}
fn main() {
let result = add(3, 4);
println!("3 + 4 = {result}");
let language = "Rust";
println!("Time to learn {language}!");
// No null, no undefined -- use Option
let maybe: Option<i32> = Some(42);
if let Some(n) = maybe {
println!("Got a value: {n}");
}
}
What is the primary reason Rust has no garbage collector?
In Rust, what does omitting the semicolon on the last line of a function mean?
Which Rust feature prevents data races at compile time?
What does Rust use instead of null or undefined?