Use cases · Mobile
iOS and Android libraries in Tern
Write the logic once, compile it for both phones, and call it from Swift and Kotlin. Same language, same race checks, no changes per platform.
curl -fsSL https://ternlang.dev/install.sh | sh
tern new myapp && cd myappSame code, every target
fn main():
squares = [0] * 8
parallel for i in 0..len(squares):
squares[i] = i * i
print(squares)tern run --target ios-sim squares.tn # boots a Simulator if none is running
tern run --target android squares.tn # pushes with adb, runs, cleans up
tern build --lib --target ios lib.tn # a static library + C header for XcodeTargets
--target | Builds for | Needs |
|---|---|---|
ios | iPhone and iPad, arm64, iOS 15+ | Xcode |
ios-sim | the iOS Simulator on Apple silicon | Xcode |
android | Android arm64, API 24+ | Android NDK |
android-x86_64 | x86-64 emulators, Chromebooks | Android NDK |
The iOS and Android guide shows the Swift and Kotlin side, which threads may call in, and what a runtime error does inside an app.
Questions
Can I use Tern in an iOS app?
Yes. Build with --lib --target ios to get a static library and a C header, link it into your Xcode project, and call the exported functions from Swift.
Can I use Tern in an Android app?
Yes. Build for android or android-x86_64 with the NDK and call it from Kotlin or Java through JNI.
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
C interop and embeddingCall C directly; call Tern from Python
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.