Skip to content

Finch 2.0.0

Choose a tag to compare

@Nexoniarz Nexoniarz released this 08 Oct 17:24
· 64 commits to main since this release

Finch

Finch 2.0 turns the small core of 1.0 into a complete small language, and a compiler that can build itself.

New in the language

  • Structs with default values: Point(1, 2), Player(name: "Ola"), nested structs, print shows them
  • Arrays []T with bounds checks: push pop insert remove clear resize find contains join slice reverse sort, for x in list
  • Text that knows its length: +, .len, s[i], sub find contains starts_with ends_with split trim upper lower replace repeat, str(x), int(s), float(s)
  • Memory without free: arrays, strings and structs are values; assignment copies, the end of a block frees, results move, parameters are lent. Every test runs clean under valgrind
  • defer, and new(...)/free(...) for your own heap structures (lists, trees)
  • Modules: import shapes → shapes.area(b), shapes.Box
  • input(), read_file, write_file, file_exists, shell, exit, fn main([]str args)

C interop

  • C structs by value with the System V x86-64 calling convention (raylib's Vector2/Color, libclang's CXCursor, …), C struct fields and fixed arrays
  • addr(fn) gives C a callback
  • link "mycode.c" compiles and links your own C files

Tools

  • -g: DWARF debug info for gdb/lldb (breakpoints, locals, struct fields)
  • finch run file.fn args... passes arguments to the program

Bootstrap

boot/ is a Finch compiler written in Finch (about 3,000 lines). Built by the C++ compiler, it compiles itself, and stage 2 and stage 3 produce byte-identical LLVM IR. tests/boot.sh checks it.

Branding

A logo (light and dark), an icon and a social preview: see assets/.

Docs

The guides for beginners, technicians and engineers, in English and Polish, now cover everything above. The engineers' guide includes the ownership model and the ABI work, with real compiler output.

Breaking changes from 1.0

  • str now carries its length and is never null: s == null is an error (use s.len == 0). To pass text to a void* C parameter, use s.ptr.
  • char * inside C structs and globals is ptr[char] (read it with str(p)); in function parameters and results it is still str.