Finch: a small, fast programming language on LLVM. C-like syntax, memory without free, structs and arrays, direct C library import, and a compiler written in itself.
  • LLVM 99.7%
  • C 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nexoniarz 873b52565d boot: sized numbers (i8..u64, f32), conversions, unsigned arithmetic
The self-hosted compiler now has the numeric types the C++ one has: int and
float stay the i64 and f64 defaults, the others lower to their LLVM sizes;
literals adapt to the other operand if they fit, smaller types widen into
bigger ones, signed and unsigned mixing is refused, division and shifts and
comparisons pick their signedness, and u8(x), f32(x), bool(x) convert.

boot.sh: 11 passed, 0 failed, 10 skipped (was 9 / 12).
2026-10-25 19:13:46 +01:00
.github/workflows Finch 2.4.0: methods, maps, errors as values; str() of any value; macOS and ARM64 docs; Kate support 2026-10-09 01:11:12 +02:00
assets Branding: logo (light/dark), bird mark, icon, social preview, brand guide; logo in READMEs 2026-10-08 19:24:31 +02:00
boot boot: sized numbers (i8..u64, f32), conversions, unsigned arithmetic 2026-10-25 19:13:46 +01:00
docs Finch 2.4.0: methods, maps, errors as values; str() of any value; macOS and ARM64 docs; Kate support 2026-10-09 01:11:12 +02:00
editors Finch 2.4.0: methods, maps, errors as values; str() of any value; macOS and ARM64 docs; Kate support 2026-10-09 01:11:12 +02:00
examples Delete OpenGL.fn 2026-10-09 10:10:47 +02:00
runtime Fix the two known limits: adding map keys while looping over the map is a runtime error; temporaries held by an expression are freed when try / or-blocks leave early. err usable after or, inner err shadows outer. 2026-10-25 19:13:46 +01:00
src Fix the two known limits: adding map keys while looping over the map is a runtime error; temporaries held by an expression are freed when try / or-blocks leave early. err usable after or, inner err shadows outer. 2026-10-25 19:13:46 +01:00
tests boot: sized numbers (i8..u64, f32), conversions, unsigned arithmetic 2026-10-25 19:13:46 +01:00
.gitattributes VS Code extension (highlighting, snippets, language client, Run/Build); LF line endings; LNK1181 2026-10-08 22:01:13 +02:00
.gitignore Finch 1.0.0 2026-10-08 18:21:06 +02:00
CMakeLists.txt Finch 2.4.0: methods, maps, errors as values; str() of any value; macOS and ARM64 docs; Kate support 2026-10-09 01:11:12 +02:00
LICENSE Finch 1.0.0 2026-10-08 18:21:06 +02:00
notatka.txt Docs for Finch 2.0: beginners, technicians, engineers (en, pl); READMEs; raylib example 2026-10-08 19:20:46 +02:00
note.txt Docs for Finch 2.0: beginners, technicians, engineers (en, pl); READMEs; raylib example 2026-10-08 19:20:46 +02:00
README.md Finch 2.4.0: methods, maps, errors as values; str() of any value; macOS and ARM64 docs; Kate support 2026-10-09 01:11:12 +02:00
README.pl.md Finch 2.4.0: methods, maps, errors as values; str() of any value; macOS and ARM64 docs; Kate support 2026-10-09 01:11:12 +02:00
shell.nix OpenGL and Vulkan examples; ptr(int)/int(ptr); trailing commas in calls; drop .fn hint 2026-10-08 19:37:34 +02:00

Finch

Small, quick, sharp. A programming language on LLVM with C-like syntax, simple enough to learn in an hour and as fast as C.

🇵🇱 Polska wersja

import "math.h"

fn hypot2(float a, float b) -> float {
    return sqrt(a * a + b * b)
}

fn main() {
    name := "Finch"
    print("Hello from", name, "!")

    for i in 1..4 {
        print(i, "→", hypot2(float(i), 1.0))
    }
}

Why Finch

  • Simple. No semicolons, no headers, no preprocessor. Each thing has one way to do it.
  • Fast. It compiles through LLVM's -O2 pipeline to native code, with no garbage collector. Recursive fib(40) runs in about 0.19 s (clang -O2 on the same C: about 0.23 s); bounds-checked array code matches C.
  • Memory without the pain. Lists, text and structs are values: assigning copies, and the end of a block frees them. There is no free to forget, no use-after-free, and every test is clean under valgrind.
  • Safer than C, where it is cheap. No silent narrowing and no signed/unsigned mixing. Out-of-range indexes, division by zero and null pointers stop with a clear runtime error instead of undefined behavior. Operator precedence that does not bite (x & 1 == 0 means what it says).
  • Practical. Maps, methods, errors as values (int(s) or 0, try read_file(p)), modules, any C library, and a language server for your editor. Runs on Linux, macOS and Windows, on x86-64 and ARM64.
  • Errors that talk like a person:
    game.fch:3:13: error: 'y' must be i32, but this is int (use i32(...) to convert)
        3 |     i32 y = x
          |             ^
    
  • Any C library, directly. import "raylib.h" + link "raylib", and you can call it, structs by value and callbacks included. Headers are read by libclang, so there is nothing to declare by hand.
  • Written in itself, too. boot/ is a Finch compiler written in Finch that compiles itself to a byte-identical result.

Quick start

Ready builds are in the releases:

System Download Also needs
Windows x64 finch-windows-x64.zip LLVM 21, Visual Studio Build Tools (C++); steps
macOS (Apple Silicon) finch-macos-arm64.tar.gz brew install llvm@21; steps
Linux x64 / ARM64 finch-linux-x64.tar.gz / finch-linux-arm64.tar.gz LLVM 21 libraries, a C compiler; steps

Editors: Kate (editors/kate/install.sh), VS Code (the finch-lang .vsix from the release), or any editor with LSP support (finch lsp).

Building it yourself (Linux or macOS, LLVM 21):

git clone https://github.com/Nexoniarz/Finch.git
cd Finch
nix-shell                           # or install LLVM 21 + libclang + cmake + ninja yourself
cmake -S . -B build -G Ninja
ninja -C build

./build/finch run examples/hello.fch
./build/finch build examples/tour.fch -o tour && ./tour
tests/run.sh                        # 74 passed, 0 failed
tests/boot.sh                       # the compiler written in Finch builds itself

Documentation

Pick the guide that fits you:

Guide For English Polski
Beginners Never programmed: students, seniors, anyone curious for-beginners.md dla-poczatkujacych.md
Technicians Know computers, new to programming: install, whole language, C libraries, troubleshooting for-technicians.md dla-technikow.md
Engineers Everything: lexer, grammar, AST, type rules, IR lowering, libclang import, ABI, internals for-engineers.md dla-inzynierow.md
Cheat sheet Every function, method, operator and command on one page cheatsheet.md sciaga.md

The language at a glance

Variables x := 5 (inferred) or int x = 5
Types int float bool char str, sized i8…i64 u8…u64 f32 f64, arrays []T, maps map[K]V, pointers ptr[T]
Functions fn add(int a, int b) -> int { return a + b }
Structs struct Point { … } with one field per line (int x, int y = 0); create with Point(1, 2) or Point(x: 1)
Methods fn Point.move(int dx) { self.x += dx } → p.move(3)
Arrays nums := [1, 2, 3], nums.push(4), nums[0], nums.len, for i, n in nums { }
Maps ages := ["ann": 31], ages["bob"] = 25, ages.has("cy"), counts[w] += 1, for k, v in ages { }
Errors fn parse(str s) -> int! { … return error("bad") } → parse(s) or 0, parse(s) or { … }, try parse(s)
Text "a" + "b", str(42), int("42"), s.split(","), s.upper(), s[0]
Control if / else if / else, while, for i in 0..10, break, continue, defer
Memory automatic for arrays, text and structs; new(...) / free(...) for your own heap structures
Modules import shapes → shapes.area(b)
C interop import "stdio.h", link "glfw", link "mine.c", addr(fn) for callbacks
I/O print(...), input("? "), read_file, write_file, shell
Tools finch run/build/ir/lsp, --target windows/arm64/macos, -g for gdb/lldb, -O0

Examples

File Shows
examples/hello.fch the smallest program
examples/tour.fch variables, functions, conditions, loops
examples/guess.fch a guessing game: input, loops, C's rand
examples/todo.fch structs, arrays, strings and files
examples/wordcount.fch maps, methods and errors as values: the most frequent words in a file
examples/structs.fch structs, arrays of structs, a linked list with new/free
examples/types.fch sized numbers and pointers
examples/c_import.fch printf, math.h, malloc/free, stderr
examples/window.fch a GLFW + OpenGL window
examples/opengl.fch modern OpenGL 3.3: shaders, buffers, a spinning triangle
examples/vulkan.fch Vulkan: list the GPUs, their memory and queues, create a device
examples/raylib.fch raylib with C structs by value
examples/llvm.fch Finch building LLVM IR through the LLVM-C API
boot/ the Finch compiler, written in Finch

Roadmap

  • Lexer, parser, LLVM codegen, O2 optimization
  • Types incl. sized integers, pointers, conversions; functions; if/while/for
  • Readable compile errors; runtime checks (division, null, bounds)
  • Bitwise operators with sane precedence
  • C headers through libclang; link with pkg-config; link-error advice
  • struct, including C structs by value (System V ABI) and callbacks
  • Arrays with .len, bounds checks and methods; for x in list
  • Memory: values freed at the end of their block, defer, new/free
  • Strings: +, .len, indexing, methods, str(x), int(s); input(); files
  • Finch modules (import name)
  • Debug info (-g)
  • Bootstrap: a Finch compiler written in Finch that builds itself
  • Windows: finch.exe, .exe programs, the Microsoft x64 ABI; cross-building from Linux (--target windows)
  • Language server (finch lsp) and a VS Code extension
  • macOS and ARM64 (Linux and Apple Silicon), with their C calling conventions; Kate support
  • Methods on structs, maps, errors as values (!, or, try)
  • Generics, match, enums
  • A standard library in Finch (JSON, paths, time, processes)

Layout

src/        compiler: lexer, parser, AST, codegen, C import + ABI, language server, driver (C++17, ~7k lines)
runtime/    the small C runtime linked into every program
boot/       the Finch compiler written in Finch (~3k lines)
examples/   example programs
editors/    VS Code extension, Kate highlighting and LSP setup
tests/      run/ (golden output), fail/ (expected errors), run.sh, boot.sh, cross.sh, lsp_test.py
docs/       en/ and pl/ guides for three audiences

License

Apache License 2.0. Copyright 2026 Nexoniarz.