Risor vs TypeScript

TypeScript can't be executed directly. Every embedded approach transpiles to JavaScript first, then runs JavaScript in a sandboxed runtime. That's two dependencies, a two-phase pipeline, and the types are gone before execution. Risor is a purpose-built scripting language with TypeScript-aligned syntax, designed for embedding.

Embedded TypeScript Approaches

  1. Type-strip + JS runtime: esbuild strips types, then goja/QuickJS/V8 runs the JavaScript. Two deps, two error surfaces.
  2. Bundle the TS compiler: Run the TS compiler inside a JS interpreter. Self-contained but slow.
  3. Subprocess to Deno/Node: Full TS support but adds process-level dependency and IPC overhead.

Syntax Comparison

TypeScript:

const tier: string = (() => {
    if (account.totalSpend > 10000) return "enterprise";
    if (account.totalSpend > 5000) return "pro";
    return "standard";
})();
 
const discount: number = { enterprise: 0.20, pro: 0.10, standard: 0.05 }[tier];
const total: number = lineItems.reduce((sum, i) => sum + i.price * i.quantity, 0);
const result: number = total * (1 - discount);

Risor:

let tier = if (account.total_spend > 10000) { "enterprise" }
    else if (account.total_spend > 5000) { "pro" }
    else { "standard" }
 
let discount = match tier {
    "enterprise" => 0.20
    "pro" => 0.10
    _ => 0.05
}
 
let total = line_items.map(i => i.price * i.quantity) |> math.sum
total * (1 - discount)

Comparison

PropertyTypeScript (embedded)Risor
Runtime typesNone (stripped before execution)Runtime error on type mismatch
Sandbox modelJS stdlib exposed (opt-out)Empty (opt-in)
Feature controlHost restricts globalsHost chooses which features to enable
EmbeddingTranspiler + JS runtimeSingle function call
Pipes / pattern matchingNo (TC39 proposals)Yes
Error surfaceTranspile errors + JS runtime errorsSingle

When to Choose TypeScript

  • Your scripting users are TypeScript developers who won't use anything else
  • Scripts are developed as files in a repository, not entered by users at runtime

When to Choose Risor

  • You want simple embedding without a transpilation pipeline
  • Scripts are entered by users, stored in databases, or evaluated at runtime
  • You want an opt-in sandbox with host-controlled features
  • You want pipe operators and pattern matching today

Learn More


Risor © 2026 Deep Noodle