Zyn0.1.0

Native programs

zyn build --native compiles a program to an executable that runs without Java: a single small file that starts at once.

zyn build --native app.zyn
./app

The executable prints exactly what zyn run prints for the same program. zyn run --native app.zyn builds and runs in one step, and zyn test --native app.zyn runs the tests natively.

#Nothing to install

Native builds compile Zyn to C, which Zig's C compiler turns into machine code. If you don't have Zig, Zyn downloads it the first time it's needed (about 80 MB, once, into ~/.zyn). The download is checked against fixed SHA-256 sums, so Zyn only runs the exact files it was built with.

Zyn uses, in this order: $ZYN_ZIG, a zig on your PATH, its own downloaded copy, or the ziglang Python package. ZYN_NO_ZIG_DOWNLOAD=1 turns the download off.

#Other systems

Zig compiles for other systems from any system, so you can build a Windows .exe on Linux:

zyn build --native --target windows app.zyn    # app.exe
zyn build --native --target macos-arm app.zyn  # for Apple silicon
TargetSystem
linuxLinux, x86-64
linux-armLinux, ARM64
macosmacOS, Intel
macos-armmacOS, Apple silicon
windowsWindows, x86-64

#Memory

Native programs free memory they no longer use with their own garbage collector, so you never manage memory by hand. It runs when the program has allocated as much again as it was using, so memory stays within about twice what the program really needs. ZYN_GC_STATS=1 shows what it did:

ZYN_GC_STATS=1 ./app

Deep recursion works (programs get a large stack), and endless recursion gives a Zyn error instead of a crash.

#Differences

The language is the same; only a few things differ from the JVM:

  • Native programs can't use Java libraries.
  • uppercase(), lowercase() and isLetter() know ASCII and Latin-1 letters (é → É), not yet every alphabet.
  • Errors show the line they happened on, but not the column.