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 myapp

Same 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 Xcode

Targets

--targetBuilds forNeeds
iosiPhone and iPad, arm64, iOS 15+Xcode
ios-simthe iOS Simulator on Apple siliconXcode
androidAndroid arm64, API 24+Android NDK
android-x86_64x86-64 emulators, ChromebooksAndroid 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

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.