Getting started

Install

Each release has the compiler for x86_64 and aarch64 Linux with its standard library. It needs glibc 2.38 or later and LLVM 23: libLLVM, clang to link native programs and lld for freestanding ones. If they are not found under their usual names, set JIHOO_LLVM to the shared library, JIHOO_CC and JIHOO_LD.

curl -L https://github.com/jihoo-language/jihoo2/releases/download/v0.4.1/jihoo-v0.4.1-x86_64-linux.tar.gz | tar xz
jihoo-v0.4.1-x86_64-linux/bin/jihoo run hello.jh

From source

The checkout describes its toolchain for graft: Debian 13 packages, LLVM 23 and the seed compiler in bootstrap/.

git clone https://github.com/jihoo-language/jihoo2
cd jihoo2
graft build -o result           # bootstraps the compiler: ./result/bin/jihoo
graft develop                   # a shell with LLVM 23 and the seed as `jihoo`

Your first program

A program starts at main. jihoo run compiles it and runs it; jihoo build leaves the executable.

import std.env
import std.fs

fn main() -> i32 {
    let args = env.args()
    if args.len() < 2 {
        eprintln("usage: words <file>")
        return 2
    }
    let text = match fs.read_file(args[1]) {
        Ok(t) => t
        Err(e) => {
            eprintln(e)
            return 1
        }
    }
    var counts = Map(String, i64).new()
    for line in text.as_str().lines() {
        for w in line.split(" ") {
            if w.len == 0 {
                continue
            }
            match counts.get_mut(w) {
                Some(n) => n += 1
                None => {
                    counts.insert(w.to_string(), 1)
                }
            }
        }
    }
    println(counts.len())
    0
}
jihoo run words.jh -- notes.txt
jihoo build words.jh -o words && ./words notes.txt

Where next

Esc