Skip to content

jihoo

As fast as C, memory-safe without lifetimes. Every value has one owner, functions borrow their arguments, and a small checker makes sure nothing changes what is borrowed. No garbage collector, no reference counting, no annotations.
hello.jh — jihoo run hello.jh
fn greet(name: str) -> String {
"Hello, " + name + "!"
}
fn main() {
println(greet("jihoo"))
}
borrowing: lend, lend to change, give away
fn total(xs: Vec(i64)) -> i64 { ... } // reads, no copy
fn add_one(inout xs: Vec(i64)) { ... } // changes in place: add_one(&v)
fn keep(sink xs: Vec(i64)) { ... } // takes it
for x in v {
v.push(x) // error: `v` is changed here while it is borrowed
}
tiny.jh — no libc: a static binary that talks to the kernel
#![freestanding]
fn main() {
var v = Vec(i64).new()
v.push(42)
println(v[0])
}

As fast as C

LLVM compiles every program, with no runtime and no hidden copies; on the benchmarks jihoo matches C compiled by clang, with bounds checks on. inout parameters cannot alias, so the compiler marks them noalias.

Safe without lifetimes

Borrows are scoped to a function, so the compiler sees every one of them and needs no annotations. A small checker, separate from the type checker, enforces the rules on the compiler’s IR.

Generics at compile time

comptime T: type parameters, inferred at calls; traits with default methods and generic impls; one copy of the code per instance.

A library in the language

Vec, String, Map, Box, sorting and files are jihoo code over unsafe pointers, and work with or without libc.

Down to the metal

Raw pointers, static globals, C functions, system calls and atomics in unsafe code; x86_64 and aarch64 Linux.

Built with Nix

nix run github:jihoolang/jihoo gives you the compiler, clang, lld and the standard library.