C.W.K.
Stream
Lesson 03 of 05 · published

Bun and Deno: Native TS Runtimes

~8 min · tooling, bun, deno, runtime

Level 0Curious
0 XP0/93 lessons0/23 achievements
0/100 XP to next level100 XP to go0% complete
"Bun runs your .ts files. Deno does too. No compile step. No tsc."

What they are

Bun (bun.sh) — JavaScript runtime built on JavaScriptCore. Drop-in replacement for Node for many use cases, with built-in TypeScript support, fast startup, and a comprehensive standard library. bun run script.ts just works.

Deno (deno.com) — JavaScript/TypeScript runtime built on V8. Security-first (explicit permission model), TS-native, built-in linter/formatter/test runner. deno run script.ts just works.

Both eliminate the .ts → .js compile step. The runtime handles transpilation internally on import; you ship .ts files directly. The reduction in tooling is significant for scripts, CLIs, and small services.

Type checking still matters

Both Bun and Deno transpile-but-don't-typecheck by default — they strip the types and run the JavaScript. To run type checks, you still want tsc --noEmit (or in Deno, deno check). The performance trade-off is: transpile fast at runtime, type-check separately when needed.

When to use which

Bun for Node-compatible projects that want speed and simplicity. Npm packages work, the standard library is rich, the dev experience is unified (test runner, bundler, package manager all built in).

Deno when you value the security model (explicit --allow-net, --allow-read, etc.), prefer Web Standards (Deno uses URL imports and Fetch by default), or want a tighter standard library.

Node + tsc + bundler when you need a specific Node version, a specific Node-only library, or are working in a large existing codebase where switching cost outweighs benefit.

For new TypeScript projects in 2026, Bun is the default fast option, Deno is the secure option, Node is the compatibility option. All three are valid; the choice depends on the project's other constraints.

Code

Three TS runtime experiences side by side·bash
# Bun — native TS, fast startup.
bun run hello.ts            # just runs
bun test                    # built-in test runner
bun --hot run server.ts     # hot reload built in

# Deno — native TS, security model.
deno run hello.ts           # asks for permissions explicitly
deno run --allow-net script.ts  # grant network access
deno test                   # built-in test runner
deno fmt && deno lint       # formatter and linter built in

# Node + tsc workflow — multiple tools.
npm install --save-dev typescript tsx
npx tsx hello.ts            # tsx wraps Node + esbuild for TS support
# (or: nodemon + tsx for hot reload)
# (or: tsc --noEmit for type check, then node dist/hello.js for runtime)

External links

Exercise

Install Bun or Deno locally. Take a small TypeScript script you have (or write one). Run it with bun run file.ts or deno run file.ts. Compare startup time and ergonomics with node --import tsx file.ts.
Hint
The startup difference for small scripts is dramatic — often 10x faster than node + tsx. For long-running servers, the startup difference matters less, but the simplicity of one binary often does.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.