Start

Getting started

Build the compiler, point it at a .ts file, and run the native binary it writes.

Requirements

  • Go 1.26+ — to build the compiler itself.
  • clang (LLVM 15+, opaque-pointer support) — the backend that turns emitted IR into a binary.
  • Optional, linked only when your program uses the feature: libcurl (for fetch / http.listen), libnghttp2 (for http.listen), libpcre2 (for RegExp), OpenSSL 3 (for crypto.subtle / tls), bdw-gc (only for -mm=gc).

Build the compiler

shell
$ make build            # produces ./klainmain

Compile and run a file

Compiling produces a native binary next to the source — it does not run it.

shell
$ ./klainmain examples/basics/basics.ts   # → examples/basics/basics
$ ./examples/basics/basics                # run it yourself
$ ./klainmain -o myapp app.ts             # custom output name

Your first program

const who: string = "native world";
console.log("hello, " + who);

Then:

shell
$ ./klainmain hello.ts
$ ./hello
hello, native world

Handy make targets

TargetDescription
make buildCompile the compiler to ./klainmain
make run FILE=f.tsCompile and run a single file
make compile FILE=f.tsCompile a file to a binary (don't run it)
make ir FILE=f.tsEmit LLVM IR only, no binary
make examplesCompile and run every example — the readable regression suite