Comparison
Tern vs Python
If you like how Python reads but not how it deploys or how fast it runs, Tern keeps the indentation and the feel, and checks every type before anything runs.
curl -fsSL https://ternlang.dev/install.sh | sh
tern new myapp && cd myappSide by side
struct Account:
owner: str
balance: int
fn deposit(a: mut Account, amount: int):
a.balance += amount
fn main():
acct = Account("ada", 0)
acct.deposit(50)
print(acct.owner, acct.balance) # ada 50Classes become structs plus functions, and acct.deposit(50) still works. The coming-from guide has the full mapping.
What you get
- Errors before it runs. Static types everywhere, inferred inside functions.
- Real parallelism. No GIL:
parallel foruses every core, checked for races. - One binary. No virtualenv, no interpreter on the server.
- Hints for Python habits.
range(n),appendand friends get an error that says what to write instead.
What you give up
- PyPI. Tern’s package index is small; you can still call Tern from Python with ctypes.
- A REPL and notebooks, and dynamic tricks like monkey-patching.
- Exceptions: errors are
Resultvalues with?.
Questions
Is Tern a compiled Python?
No. It borrows Python's syntax, but it is its own statically typed language and doesn't run Python code.
Is Tern faster than Python?
Yes. It compiles to native code and benchmarks ahead of Rust and Go on our compute tests.
More about Tern
Web servers and APIs169k requests/s on one thread, 254 KB binary
Command-line toolsFlags into a struct, one static binary
Data processingCSV, JSON, regex and gzip faster than Rust
WebAssembly40 KB modules with TypeScript types
iOS and AndroidOne library for Swift and Kotlin
Start the tourInstall Tern and write a first program
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.