Skip to content
matteopolakPublic

About

Independent (unofficial) Jai toolchain: compiler, language server, formatter and linter

Topics

Resources

Contributing

Stars

103 stars

Watchers

0 watching

Forks

Latest commit

 

History

4,468 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jacket

CI Latest release Chat on Zulip

Jacket is a toolchain for the Jai programming language, written from scratch. It has a compiler (jaic), a language server (jailsp), a formatter (jaifmt), a linter (jailint), and jacket, which runs all of them from one jacket.toml and adds tests, benchmarks, API docs and git dependencies. Its standard library is written in Jai and adds extension modules such as JSON, HTTP, Postgres, Regex, TOML and WebGPU.

Note

Jacket is unofficial and is not affiliated with or endorsed by Thekla, Inc. or the official Jai project.

Documentation

Example

#import "Basic";
#import "Extensions/Json";

User :: struct {
    name: string;
    languages: [..] string;
}

main :: () {
    text := #string JSON
{"name": "Ada", "languages": ["Jai", "C"]}
JSON;
    user, error := from_json(User, text);
    assert(error.kind == .NONE, "%", error.message);
    defer free_json(*user);

    print("% writes %\n", user.name, user.languages);
    print("%\n", to_json(User.{ name = "Grace" }));
}
$ jacket run users.jai
   Compiling users (users.jai)
    Finished debug [unoptimized] in 0.39s
     Running `users`
Ada writes ["Jai", "C"]
{"name":"Grace","languages":[]}

Usage

Install on macOS or Linux with Homebrew or the install script:

brew install matteopolak/tap/jacket
curl -fsSL https://jacket.matteopolak.com/install.sh | sh

On Windows, in PowerShell:

irm https://jacket.matteopolak.com/install.ps1 | iex

jacket upgrade updates an installation. Nix, prebuilt archives and CI setup are in install channels.

Start a project and run it:

$ jacket new hello
created program hello in hello: jacket.toml, build.jai, main.jai
$ cd hello
$ jacket run
   Compiling hello (build.jai)
    Finished debug [unoptimized] in 0.19s
     Running `hello`
Hello from hello!

Tests are procedures with a @test note, in files under tests/:

// hello/tests/greeting.jai
#import "Basic";
#import "Extensions/Testing";

greets_by_name :: () {
    greeting := tprint("Hello from %!", "hello");
    expect_equal(greeting, "Hello from hello!");
} @test
$ jacket test
    Starting 1 test
        PASS [   0.069s] greets_by_name
     Summary [   0.197s] 1 test run: 1 passed

jacket.toml holds the settings of every tool, so the editor, the build and CI agree:

[project]
entry = ["build.jai"]
import-path = ["src"]          # folders `#import` searches

[format]                       # jaifmt
indent-width = 4
max-width = 100

[lint.rules]                   # jailint
unused_variable = "deny"

[test]                         # jacket test
timeout = 30

[target.pi]                    # jacket run --target pi
triple = "armv7-unknown-linux-gnueabihf"
runner = "qemu-arm -L {sysroot} {exe}"

For editors, install the VS Code extension (also on Open VSX) or jacket.nvim for Neovim 0.11+. Any other editor can run jailsp over stdio.

Tools

Tool What it does
jaic Compiles Jai to native executables and libraries through LLVM, or runs it in its interpreter (-interp).
jailsp Language server: errors and lints as you type, hover with types and layout, completion with auto-import, go to definition, rename, inlay hints, code actions.
jailint Reports mistakes, memory bugs and performance pitfalls; jacket lint --fix applies the safe fixes.
jaifmt Formats Jai code (rules).
jacket Runs the tools, tests, benchmarks, API docs, dependencies and migrate for older Jai code.

Platform support

Jacket runs on macOS (arm64, x86-64), Linux (x86-64, arm64) and Windows (x86-64, arm64). Programs build for those, for WebAssembly, for 32-bit and big-endian Linux, and for boards with no operating system down to the 8-bit AVR (other targets). Cross targets are experimental.

Contributing

Bug reports and feature requests are welcome as issues. Pull requests are not accepted; see CONTRIBUTING.md. Jacket is a clean-room implementation: contributors must not read the official Jai sources.

License

AGPL-3.0-or-later, with a runtime library exception: programs you compile with Jacket can use any license. The standard library (stdlib/) is also available under MIT OR Apache-2.0, and the specifications (docs/specs/) are public domain (CC0).

About

Independent (unofficial) Jai toolchain: compiler, language server, formatter and linter

Topics

Resources

Contributing

Stars

103 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages