Repository navigation
Zeno 0.3.0
Zeno 0.3 is about speed, and about choosing how memory is freed. On
six benchmarks a compiled program now runs within about a quarter of
the same program in C, and a program can say that it wants no
collector at all.
Installing
Windows: download zeno-0.3.0-windows-setup.exe below and run it.
It is not signed, so Windows warns the first time: "More info", then
"Run anyway".
macOS and Linux:
curl -fsSL https://github.com/partham20/zeno-lang/releases/download/v0.3.0/install.sh | shBoth put zeno on the PATH and offer to install a C compiler and git
if the machine has none.
docs/install.md
says what they do. The archives further down are for installing by
hand.
Homebrew, on macOS and Linux:
brew tap partham20/zeno-lang https://github.com/partham20/zeno-lang
brew install partham20/zeno-lang/zenoWith another package manager. There is a package for apt, pacman,
snap and flatpak, installed from its file:
sudo apt install ./zeno_0.3.0_amd64.deb # Debian, Ubuntu, Raspberry Pi OS
sudo pacman -U zeno-lang-bin-0.3.0-1-x86_64.pkg.tar.zst # Arch
sudo snap install --classic --dangerous zeno_0.3.0_amd64.snap
flatpak install --user zeno-0.3.0-x86_64.flatpakThe .deb is also there for arm64, armhf (every Raspberry Pi with
a 32-bit system) and i386, the snap for arm64 and armhf, and the
flatpak for aarch64. apt installs a C compiler and git along with
Zeno if the machine has none.
On Arch the package is now called zeno-lang-bin. It was zeno-bin,
and the AUR has a zeno that is another program. pacman offers to
put the new one in place of the old.
docs/stores.md
says where each manager finds Zeno by itself, with no file, and what is
still to be done for the ones that do not yet.
Choosing how memory is freed
A program that makes lists, objects and text has to give their memory
back. Until now a compiled program had a garbage collector, unless it
was built for a chip. Now a program chooses, and says so in one line of
zeno.package:
package server
memory owned
With memory owned there is no collector. Every list and object has
one owner and is freed on the line its owner ends, as in Rust, and the
program asks the system for more memory as it needs it. zeno check
and zeno run hold the program to the same rules, so a mistake about
who owns what is found before the build.
| Where it is said | What it covers |
|---|---|
memory owned in zeno.package |
the program |
zeno build --owned, or --collector |
one build, over what the file says |
memory owned at the top of a file |
the classes of that file, also in a program with a collector |
owned class, owned list[int] |
one value, as before |
So a program can keep the collector for most of its code and free the
objects of one busy file exactly.
docs/memory-modes.md
walks through it.
--release
zeno build --release main.zeno--release leaves out the check for overflow: +, - and * of
whole numbers wrap round, as the processor does, and do not stop the
program with an OverflowError. Everything else is still checked: an
index past the end, // by zero, u8(300). zeno run checks
everything, as it always did. It is what a release build of Rust does,
and for the same reason: the check costs a little on every step of a
tight loop.
A faster collector
The collector was rebuilt, twice over.
- Blocks live in pages. It used to sort its table of every block
at each collection. Now blocks of one size share a page of 64 KB, and
a page keeps one bit for each block. - Two generations. Most blocks are garbage soon after they are
made, and one that has lived through a collection usually lives
through many. So most collections look only at the blocks made since
the last one. The system's own protection of memory tells the
collector which old pages were written to since, so nothing in the
compiled code had to change. This is on Linux only for now. On macOS
and Windows every collection still looks at everything.
A program that makes millions of small objects ran nine times slower
than the same program in C when built with 0.2. With 0.3 it is a
quarter slower, with the collector still doing all the freeing.
How fast it is now
Six small programs, each written in Zeno, C, Rust and Python, each
checked to print what the C one prints. Seconds, on a 4-core Xeon at
2.1 GHz, best of three:
| Program | C | Rust | Zeno 0.2.0 | zeno build |
--release |
--release --owned |
|---|---|---|---|---|---|---|
| fib 40 | 0.156 | 0.249 | 0.468 | 0.480 | 0.121 | 0.138 |
| loop 10⁹ | 0.920 | 0.880 | 1.43 | 1.258 | 1.010 | 0.947 |
| sort 10⁷ | 1.09 | 1.14 | 1.33 | 1.43 | 1.44 | 1.35 |
| strings 10⁷ | 0.919 | 0.704 | 28.3 | 1.157 | 1.337 | 1.285 |
| trees 20 | 6.14 | 7.49 | 59.8 | 7.70 | 6.66 | 3.98 |
| nbody 10⁷ | 0.488 | 0.368 | 1.37 | 0.511 | 0.479 | 0.515 |
The column for 0.2.0 is zeno build of that version, timed in a run
of its own on the same machine. Times move by about a tenth from run
to run there, so a smaller difference means nothing. The programs, the
script that runs them and the numbers are in
bench.
zeno run --vm is faster too: it runs a tight loop of whole numbers
quicker than Python 3.13 does, and is two to four times slower than
Python on objects, calls and text. zeno run and the VM are there to
check a program and to try it, and zeno build is the fast way.
Besides the collector and the two options, three smaller things made
the difference:
for item in itemswalks the list in place when the body cannot
change it, where it used to walk a copy.for ch in textwalks the text, and makes no list of its characters.- A field that a function never writes is read once, not at each use.
sort with a function
people.sort(function(person: Person) -> int { return person.age })
sort takes a function that says what each item is ordered by, a
number or text, so a list of anything can be put in order. Items
with the same key stay as they were. It is the same in zeno run,
the VM and both compilers, and with --no-collector it leaves
nothing behind.
docs/library.md
walks through it.
The playground
zeno-lang.org/playground runs Zeno
in a browser, with nothing installed. It has a new editor: the program
is in colour, it is checked as you write, a mistake is shown at its
line, and there is a button to format it. It has fifteen examples and
fits a phone.
It also has a C tab, which shows the program as zeno build
writes it in C, made again as you write, for each of the three builds:
zeno build, --firmware and --no-collector. It is the plainest
answer to "what does this line cost?".
A page that draws now works with a finger as well as a mouse:
examples/sketch.zeno uses pointer events, and a canvas says where an
event was in its own pixels, however wide it is shown.
Mended
- A function given to
map,filterorreducethat changed the
list it was walking crashedzeno run. Built programs were right. - A built program could hold far more memory than it used: a block
that was still in use kept the block before it from being freed,
and that one the one before it. One benchmark held 2.3 GB where it
needed 130 MB.
The archives
| Machine | File |
|---|---|
| Linux, x86-64: most PCs and servers | zeno-0.3.0-linux-x86_64.tar.gz |
| Linux, ARM64: a Raspberry Pi 3, 4 or 5 with a 64-bit system, ARM servers | zeno-0.3.0-linux-arm64.tar.gz |
| Linux, 32-bit ARMv7: a Raspberry Pi 2 or later with a 32-bit system | zeno-0.3.0-linux-armv7.tar.gz |
| Linux, 32-bit ARMv6: a Raspberry Pi 1 or Zero | zeno-0.3.0-linux-armv6.tar.gz |
| Linux, 32-bit x86 | zeno-0.3.0-linux-x86.tar.gz |
| macOS, Apple silicon | zeno-0.3.0-macos-arm64.tar.gz |
| macOS, Intel | zeno-0.3.0-macos-x86_64.tar.gz |
| Windows, x86-64 | zeno-0.3.0-windows-x86_64.zip |
| Windows, 32-bit x86 | zeno-0.3.0-windows-x86.zip |
| Windows, ARM64 | zeno-0.3.0-windows-arm64.zip |
Unpack it and put zeno (zeno.exe on Windows) somewhere on your
PATH. To build web pages, put zeno.wasm from the same folder
beside it. The folder also holds the docs, the examples and the editor
setup.
tar -xzf zeno-0.3.0-linux-x86_64.tar.gz
cd zeno-0.3.0-linux-x86_64
./zeno --version
./zeno build --release examples/hello.zeno && ./helloOn macOS, a program downloaded with a browser is held back because
Apple has not signed it. xattr -d com.apple.quarantine zeno lets it
run.
zeno build hands the C it writes to a C compiler, so it needs one:
cc, gcc or clang, whichever it finds first, or the one CC
names. zeno build --llvm needs clang. zeno fetch needs git. zeno build --web and everything else need nothing.
What was checked
As for 0.2.0, every build but the Windows one for ARM64 was run before
it was released, and each one that was run also built the page of
examples/todo.zeno. The whole test suite, 506 tests, passes on
Linux x86-64.
The setup program for Windows was installed, run and uninstalled on a
Windows machine, and install.sh the same on Linux and on macOS. Each
package was installed, run and removed: the .deb, the snap and the
flatpak on Ubuntu, the pacman package in Arch, and the Homebrew
formula on macOS.
The benchmarks were timed on one machine, Linux on x86-64. The two
generations of the collector are on Linux only. On macOS they made
compiled programs hang when the release was rehearsed, so there, as on
Windows and on a chip, every collection looks at everything, as it did
before. The collector in pages is on every system.