u/matteopolak

A complete Jai toolchain (compiler, lsp, linter, formatter)
▲ 0 r/Jai

A complete Jai toolchain (compiler, lsp, linter, formatter)

Try it in your browser →

Repository: https://github.com/matteopolak/jai

The code was written almost entirely by AI. I of course steered it, reviewed a lot of the code, had many parts rewritten, added fuzzing+benchmarks+tests in CI (among other things), and spent a dozen hours using it myself and fixing all of the developer experience until it felt good to use.

It has four parts:

jaic (the compiler). The whole language is implemented, including #run, macros, #insert, polymorphism, #asm and the Compiler module with workspaces and the message loop. It builds native executables for macOS, Linux and Windows (x86-64 and arm64) through LLVM, and it can also target WebAssembly. About 40 open-source Jai projects build and run in CI. It's fast: a 100k+ line project type-checks in about a second and a debug build takes under 2.

jailsp (the language server). On top of the usual stuff, you can hover a #run to see its value and anything it printed, hover a macro or #insert to see the expanded code, hover an #if to see if it's true or false, and hover a struct to see its size, padding and field offsets. Hover and completion take 1–2 ms on 100k+ line projects.

jailint (the linter). It knows the types of everything, so it can catch real bugs: a loop that reads one past the end of an array, removing from an array while iterating over it, 1 << n - 1 not meaning what it does in C, or a defer in a loop that won't run when you think. It also flags unused variables and imports, and fixes what it safely can, both from the command line and as quick fixes in your editor.

jaifmt (the formatter). A good ol' formatter with the common formatting options. Nothing too special, but it's written in Jai so you can easily use it at compile-time to format generated code, for example.

Let me know what you think :)

u/matteopolak — 5 days ago