Comparison
Tern vs TypeScript
TypeScript gives you types; Node gives you a runtime to ship and feed. Tern checks types the same way before anything runs, then compiles to one native binary that uses every core.
curl -fsSL https://ternlang.dev/install.sh | sh
tern new myapp && cd myappSame spec, same agent
| Agent-built link shortener | Tern | TypeScript (Node) |
|---|---|---|
| Lines of code excluding tests | 273 | 502 |
| Redirects per second | 146k | 47k |
| CPU per redirect | 23 µs | 21 µs one thread |
| Deployed size | 408 KB | 25.8 MB |
| Memory at idle | 4.4 MB | 89.6 MB |
Both apps pass the same 32 black-box acceptance checks. Node used slightly less CPU per request on its one thread; Tern spreads requests over every core. Details on the agents page.
What’s different
- Types are sound and always on. No
anyand noascasts to step around the checker. - No async/await, no event-loop blocking. Handlers are plain functions on green-thread tasks, and
paralleluses every core. - No null or undefined.
Option[T]andResult[T, E]with?. - Nothing to install on the server. No node_modules; a Linux build can be fully static.
Pick TypeScript when
- The code runs in the browser, or you depend on npm packages. (Tern can still compile to WebAssembly with TypeScript types for the hot part.)
- Your team shares types between front end and back end.
Already on TypeScript and want faster builds? ternTS, written in Tern, transpiles exactly like tsc, many times faster.
Questions
Is Tern faster than Node.js?
For the server in our test, yes: 146k vs 47k requests per second, because Tern uses every core. Per request on one thread, Node used slightly less CPU (21 vs 23 microseconds).
Can Tern run in the browser?
As WebAssembly: tern build --lib --target wasm writes a module, a JavaScript loader and TypeScript types.
More about Tern
Tern (ternlang) is an early release: the language will change, and so will these numbers. Benchmarks run on an Apple M4 Pro; the full tables, losses included, are on the home page.