v0.1.0 The first jihoo2 release is out →

Systems code at the speed of C. Safe without lifetimes.

Every value has one owner. Functions borrow their arguments, borrow them to change them, or take them, and a small kernel makes sure nothing changes what is borrowed. No garbage collector, no reference counting, no annotations.

$curl -L https://github.com/jihoo-language/jihoo2/releases/download/v0.4.1/jihoo-v0.4.1-x86_64-linux.tar.gz | tar xz
fn greet(name: str) -> String {
    "Hello, " + name + "!"
}

fn main() {
    println(greet("jihoo2"))
}
≈ C
speed, with bounds checks on
0
lifetime annotations
5584 B
static freestanding binary
100%
written in jihoo, self-hosted
Why jihoo2

Everything C gives you. None of the footguns.

A language for programs that must be fast and correct: compilers, kernels, tools and the libraries under them.

As fast as C

LLVM compiles every program, with no runtime and no hidden copies. inout parameters cannot alias, so they are marked noalias.

Safe without lifetimes

Borrows are scoped to a function, so the compiler sees every one of them and needs no annotations. A separate borrow kernel checks the rules on the compiler’s IR, without trusting the type checker.

Generics at compile time

comptime T: type parameters, inferred at calls, with traits as bounds. One copy of the code per instance, checked per instance.

Checked effects and extents

#[no_alloc] and #[no_panic] are checked through calls. Certified slice accesses establish their bounds at compile time.

Down to the metal

Raw pointers, C functions, system calls, atomics and volatile access. Native, freestanding and UEFI programs for x86_64 and aarch64.

A library in the language

Vec, String, Map, Box, sorting, files, processes and threads are jihoo code, with or without libc. Errors carry an os.Error, and iterator pipelines fuse into loops.

Tools that come with it

jihoo fmt, jihoo test, jihoo check with JSON diagnostics, and jihoo lsp for editors. The compiler is written in jihoo and builds itself to the same IR.

Ownership

Three ways to pass a value. That’s the whole model.

Borrows last for a call, so the compiler sees all of them. Values that own memory move, and .clone() copies them.

x: T

Borrow

The default. The function reads the value; the caller keeps it. No copy.

fn total(xs: Vec(i64)) -> i64 {
    var s = 0
    for x in xs { s += x }
    s
}
inout

Borrow to change

Changes the caller’s value in place, written f(&v) at the call. Never aliased.

fn add_one(inout xs: Vec(i64)) {
    for i in 0..xs.len() {
        xs[i] += 1
    }
}
sink

Take

Moves the value into the function. The caller can no longer use it.

fn keep(sink s: String) -> Box(String) {
    Box.new(s)
}
Inside the compiler

From source to machine code, checked at every step.

The borrow kernel does not trust the type checker: it checks loans again on MIR, where every access is explicit.

01
parsetokens, newlines end statements
02
sematypes, generics, moves and drops
03
MIRone IR for every pass after
04
elabuse after move, drop flags
05
borrow kernelloans checked on MIR
06
attributesallocation and panic checks
07
LLVMobject, linked, static if asked
Ready when you are

Write your first jihoo2 program.

Download a release for x86_64 or aarch64 Linux: the compiler and its standard library, which need only glibc and LLVM 23.

Esc