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(forfetch/http.listen),libnghttp2(forhttp.listen),libpcre2(forRegExp), OpenSSL 3 (forcrypto.subtle/tls),bdw-gc(only for-mm=gc).
Build the compiler
$ make build # produces ./klainmainCompile and run a file
Compiling produces a native binary next to the source — it does not run it.
$ ./klainmain examples/basics/basics.ts # → examples/basics/basics
$ ./examples/basics/basics # run it yourself
$ ./klainmain -o myapp app.ts # custom output nameYour first program
const who: string = "native world";
console.log("hello, " + who);Then:
$ ./klainmain hello.ts
$ ./hello
hello, native worldHandy make targets
| Target | Description |
|---|---|
make build | Compile the compiler to ./klainmain |
make run FILE=f.ts | Compile and run a single file |
make compile FILE=f.ts | Compile a file to a binary (don't run it) |
make ir FILE=f.ts | Emit LLVM IR only, no binary |
make examples | Compile and run every example — the readable regression suite |