Skip to content

nooga/fy

Repository files navigation

fy

ZigZig Top guys enjoying fy

Short for funky yak, flying yacht, or funny yodeling depending on your mood. Also fuck yeah.

fy is a tiny concatenative programming language JIT compiled to aarch64 machine code.

fy is a toy, of the kind where the batteries constantly leak and only that weird guy in suspenders plays with it.

Join #fy on concatenative Discord.

Highlights

  • ~1.8MB static binary — the entire compiler, JIT, assembler, REPL, and runtime
  • JIT compiler in <4k LoC Zig — compiles directly to ARM64 machine code at runtime
  • No interpreter — every word compiles to native instructions before execution
  • Advanced FFI — call macOS frameworks (AppKit, CoreAudio), raylib, libm, or any C library
  • Compile-time macros — run real fy code at compile time, emit machine code
  • Structs — define C-compatible memory layouts with auto-generated accessors
  • Callbacks — create C-callable function pointers with thread-safe private stacks

Quick Taste

: fib  dup 1 <= [ drop 1 ] [ dup 1- fib swap 2 - fib + ] ifte ;
10 fib .   ( 89 )
[1 2 3 4 5] [dup *] map 0 swap [+] reduce .   ( 55 )
:: _lib "/usr/lib/libSystem.B.dylib" dl-open ;
: strlen  _lib "strlen" dl-sym bind: s:i ;
"hello" strlen .   ( 5 )

Building

fy requires macOS on Apple Silicon (aarch64). The JIT uses MAP_JIT and pthread_jit_write_protect_np which are macOS-specific. You'll need a Zig compiler (0.13+).

zig build
./zig-out/bin/fy

Check --help for available flags and arguments.

Documentation

Full language documentation is in docs/:

Examples

Examples can be found in examples/. Highlights:

Example Description
fib.fy Fibonacci
fact.fy Factorial
tak.fy TAK benchmark with locals
sierp.fy Sierpinski triangle PPM generator
libm.fy Math functions via FFI
raylib_hello.fy raylib window
raylib_synth_poly.fy Polyphonic synthesizer
glass.fy macOS Liquid Glass via ObjC FFI
macro.fy Compile-time macros

Editor Support

A VSCode extension with syntax highlighting and live hot-patching is in editors/vscode/fy-lang/. Run your program with fy --serve, place your cursor on a word definition, hit Cmd+Shift+Enter, and the running program picks up the new code instantly — no restart needed. See the Editor Support docs for details.

Features

  • If you make a mistake, fy simply crashes. No hand-holding, no "did you mean...?", no stack traces. Just silence and a nonzero exit code. This is a feature - the authentic 1970s mainframe experience, now on your $3000 laptop.
  • There is no plan.

About

A a tiny concatenative programming language JIT compiled to aarch64 machine code.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors