Skip to content
rusttypescripteducationastro

rs4ts.dev

Rust for TypeScript and JavaScript developers: a free guide that teaches Rust by mapping every concept to the TS/JS you already know.

since June 20264JavaScriptpushed 28 days ago

rs4ts.dev

rs4ts.dev is a free guide to Rust for people who already write TypeScript or JavaScript. Every chapter puts the TS you know next to the Rust that does the same job, so you learn the differences and don't start from zero. The site is built with Astro Starlight, with search, a chapter sidebar and "Edit on GitHub" on every page, and you can read the same Markdown offline in src/content/docs/.

I wrote it for myself a few years ago, when I was comfortable in TypeScript and put off by every Rust intro that assumed you knew C. If you've got a year or so of TypeScript and you're curious about systems programming, fast backends or going from an interpreted language to a compiled one, it's for you. You don't need any Rust to start.

The idea in one comparison

// TypeScript: safe under a strict configuration after boundary validation
interface Item { value: number }
function processData(data: readonly Item[]): number[] {
  return data.map((item) => item.value * 2);
}
// Rust: compile-time safety, zero-cost abstractions, no GC pauses
struct Item { value: i32 }
 
fn process_data(data: &[Item]) -> Vec<i32> {
    data.iter().map(|item| item.value * 2).collect()
    // Safe Rust prevents null dereferences, use-after-free and data races
}

It's the same shape, but the Rust version has no garbage collector, catches the null and the data race at compile time, and runs about as fast as C. Cargo does in one place what npm, webpack and a few other tools do between them, and the same language runs on the web, the command line, embedded boards and WASM.

The chapters

There are thirty-one, numbered 00 to 30, each a folder under src/content/docs/. They cover the toolchain, the type system, ownership and borrowing, traits, error handling, async, testing and shipping. Read it at rs4ts.dev or run it locally:

npm install      # Node 22.12+
npm run dev      # http://localhost:4321

latest on main

  1. db9627efeat: build Rust guide for TypeScript and JavaScript developers3 months ago
  2. all commits →