Getting started
Install
Section titled “Install”jihoo is packaged with Nix: the jihoo command, the
clang and lld it uses to finish programs, and the standard library.
Try it without installing:
nix run github:jihoolang/jihoo -- run hello.jhInstall it into your profile:
nix profile install github:jihoolang/jihooOr use it from your own flake:
{ inputs.jihoo.url = "github:jihoolang/jihoo";
outputs = { self, nixpkgs, jihoo }: { # jihoo.packages.<system>.default is the compiler; # jihoo.overlays.default adds `pkgs.jihoo`. };}jihoo compiles for x86_64 and aarch64 Linux.
Without Nix
Section titled “Without Nix”Each release has the
compiler for x86_64 and aarch64 Linux with its standard library. It needs
glibc and LLVM 21: 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/jihoolang/jihoo/releases/download/v0.6.0/jihoo-v0.6.0-x86_64-linux.tar.gz | tar xzjihoo-v0.6.0-x86_64-linux/bin/jihoo run hello.jhFrom source
Section titled “From source”git clone https://github.com/jihoolang/jihoocd jihoonix build # bootstraps the compiler: ./result/bin/jihoo./result/bin/jihoo run examples/hello.jhYour first program
Section titled “Your first program”A program starts at main. jihoo run compiles it and runs it;
jihoo build leaves the executable.
import std.envimport 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.txtjihoo build words.jh -o words && ./words notes.txtWhere next
Section titled “Where next”- A tour of the language;
- Values and ownership and Borrowing, what makes jihoo safe without a garbage collector;
- the examples.