HeadlinesBriefing favicon HeadlinesBriefing.com

Scriptc: Zero‑Runtime Type Script Native Compiler

Hacker News •
×

Zero‑runtime Type Script. scriptc compiles ordinary Type Script into small, fast native executables — no Node, no V8, no JavaScript engine in the binary.

cat fib.ts\nfunction fib(n: number): number {return n < 2 ? n : fib(n - 1) + fib(n - 2);}\nconsole.log(fib(30));\n

scriptc run fib.ts → 832040\nscriptc build fib.ts && ls -la fib\n-rwxr-xr-x 178K fib # a self‑contained native binary, 2ms startup

No changes to your code. No annotations, no dialect — the same Type Script you run on Node, type‑checked by the real compiler and compiled to native. Install requires clang (preinstalled with Xcode Command Line Tools). macOS arm64 is the primary platform; Linux and Windows binaries are built by cross‑compilation and verified by differential test lanes. scriptc decides, construct‑by‑construct, what can compile to native code, and tells you:

$ scriptc coverage app.ts\nstatements analyzed 4481\ncompile statically 4451 (99%)\nblockers: ×2 functions with optional parameters as values, ×1 Promise.reject, ×1 SC2020

Three tiers, always explicit: compiled statically (default), runs dynamically (with an embedded QuickJS‑NG engine for code that can’t be static), or rejected (everything else fails with a specific error code). Nothing is ever silently miscompiled. Differential testing ensures every corpus program (800+ tests) matches Node byte‑for‑byte, and Address Sanitizer + reference‑count audit guarantees memory safety.

Performance on Apple M‑series: scriptc context startup ~2.4ms, Node ~47ms; binary size 170–200KB static, ~3MB with --dynamic. Runtime JavaScript fidelity is maintained, and the roadmap includes integer inference, ownership analysis, and native FFI.