Repository navigation
Zeno 0.6.0
Zeno 0.6.0 is the release for firmware. A program can now read a
board: a button on an input pin, a byte on a serial port, a voltage on
an analog pin. It has the numbers firmware works in: f32, u64, a
list of a fixed length, bytes read from and written to a file and kept
one byte to an item, enum cases that stand for numbers, and units that
make units, so 3.3 V * 20 mA is 0.066 W. And it can call C, which
is where a board's own code is: import c reaches any library of C,
and of Go and Rust through their C interface, from zeno run and from
every C build.
Beside that, a Zeno program can use the libraries of four more
languages: Ruby, PHP, Lua and C#. And program can end a program with
a number, read its environment and write to the error stream.
Everything a program wrote for 0.5.2 means what it meant. What is new
is something it asks for, and a program that asks for none of it runs
as it did, at the same speed.
Installing
Windows: download zeno-0.6.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/zeno-src/zeno-lang/releases/download/v0.6.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 zeno-src/zeno-lang https://github.com/zeno-src/zeno-lang
brew install zeno-src/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.6.0_amd64.deb # Debian, Ubuntu, Raspberry Pi OS
sudo pacman -U zeno-lang-bin-0.6.0-1-x86_64.pkg.tar.zst # Arch
sudo snap install --classic --dangerous zeno_0.6.0_amd64.snap
flatpak install --user zeno-0.6.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.
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.
Reading a board
from board import input_pin, pull_up, serial, analog_pin, led
let button = input_pin(2, pull_up)
let port = serial(1, 115200 baud)
let battery = analog_pin(0)
if button.is_low() {
led.on()
}
port.write(f"battery {battery.voltage()}\n")
input_pin(n), withpull_uporpull_downif the board should
hold it, gives anInputPin, read withis_high()andis_low()
(docs/inputs.md,
decision 45,examples/doorbell.zeno).serial(n, 115200 baud)gives aSerial:write(text),
write_bytes(bytes),read_byte()andhas_byte(). The speed has a
unit,baud, so a bare9600is refused
(docs/serial.md,
decision 46,examples/console.zeno).analog_pin(n)gives anAnalogPin;voltage()is a quantity in
volts, solevel < 1200 mVworks andlevel < 1200is refused;
count()is the converter's own number
(docs/analog.md,
decision 47,examples/battery.zeno).
They work in zeno run, in the VM, in every C build (plain,
--firmware, --no-collector, --owned, --minimal) and with
--llvm. On a computer, under zeno run, nothing presses a button
or feeds a voltage: an input reads what its pull holds it at, an
analog pin reads 0 V or the whole 3.3 V, and every serial port is the
terminal. zeno build --target still refuses the board module.
A board's own header now has more functions to give, but only for a
program that uses them: zeno_board_input; the four
zeno_board_serial_* with ZENO_SERIALS; zeno_board_analog and
zeno_board_analog_read with ZENO_ANALOG_BITS and
ZENO_ANALOG_REFERENCE. A header written for 0.5.2 builds every
program it built before.
None of this has been run on a real board yet. It is checked on
the simulated board and with test headers that wire a port back to
itself or hold a button down; the code for an STM32 in those three
pages is a sketch.
The numbers firmware uses
let gain: f32 = 0.1 # a float of 32 bits
var buffer: list[u8, 64] = [0] * 64 # always 64 items
let h: u64 = 0xcbf29ce484222325 # 64 bits, no sign
enum Reply {
Ack = 6
Nak = 21
}
let reply = Reply(buffer[0]) # Reply or none
print(3.3 V * 20 mA, 5 V / 2 mA, 1 / 2 ms) # 0.066 W 2500 ohm 500 Hz
f32: about seven digits, done by a board's float unit, four
bytes in a field. A written number becomes the nearestf32
(docs/f32.md,
decision 41).u64: 0 to 18446744073709551615, withu64.wrapfor the
arithmetic of a hash. It is not yet a dict key, a range or an index
(docs/u64.md,
decision 42).- A list of a fixed length,
list[u8, 64], and[0] * 64to fill
any list
(docs/fixed-lists.md,
decisions 36.3 and 36.4). - Bytes.
files.read_bytes(path)andfiles.write_bytes(path, bytes)read and write a file as alist[u8], and in C and LLVM a
list[u8]now takes one byte an item: an 8 MB file needed 64 MB and
now needs 13
(docs/bytes.md,
decision 36,examples/hexdump.zeno). - An enum case can stand for a number:
int(Ack),u8(Ack), and
Reply(6), which gives aReply or none
(docs/enum-numbers.md,
decision 35,examples/protocol.zeno). - Units made of units: voltage times current is power, voltage over
current is resistance, a number over a time is a frequency, and the
rest of the table in
docs/units-made.md
(decision 43).
Each of these is the same in every engine, every build and all fifteen
target languages.
Calling C
import c
let m = c.library("m", ["double cbrt(double x);", "double hypot(double x, double y);"])
print(m.cbrt(27.0), m.hypot(3.0, 4.0))
c.library takes the library and the declarations of what the program
uses, copied from its header. Under zeno run Zeno builds a small
helper for them once, with the C compiler, and keeps it. zeno build
calls the functions directly and links the library in, in a plain,
--firmware, --no-collector, --owned or --minimal build, and the
checker reads the declarations, so a wrong argument is found before
the program runs. A declaration with no brackets is a value: a macro,
an enum constant or a variable (GPIO_PIN_5, HAL_OK). A library of
Go or Rust built for C (c-shared, cdylib, ...) is called the same
way. examples/modbus.zeno calls examples/crc.c
(docs/c.md,
decision 44).
Things to know:
- It was used on Linux x86-64: the system's maths library, zlib,
SQLite, a file of C beside the program, Go and Rust libraries. The
test suite also runs it on Windows (MinGW gcc) and on macOS (Apple
clang), with a file of C and the maths library. It has not been run
with a cross-compiler or on a board. - Not yet there: functions that take
...or a function, a struct by
value,&variable, reading a header.--llvmand--targetrefuse
import c, and for a build the library and declarations must be
written as text in the call. - A crash inside C under
zeno runstops the program;trycannot
catch it.
Four more languages' libraries: Ruby, PHP, Lua and C#
import ruby
ruby.require("date")
let Date = ruby.constant("Date")
print(Date.new(2026, 11, 18).strftime("%A")) # Wednesday
import ruby, import php, import lua and import csharp work as
import python did in 0.5.2: a value stays in its language and Zeno
asks for each field and call, none, numbers, bools and text go
across as themselves, and an error there is an error of Zeno. Gems,
Composer packages, rocks and NuGet packages are used as they are
(docs/ruby.md,
php.md,
lua.md,
csharp.md,
decisions 37 to 40). Each needs its language: Ruby 3, PHP 8, Lua 5.1
to 5.4 or LuaJIT, the .NET SDK.
As with Python, only zeno run and zeno test have them. They were
used on Linux; the test suite also runs Ruby on Windows and macOS, and
the others there only as far as the machine has them. Lua on Windows
needs LuaSocket. A function of Zeno cannot yet be handed to them.
program.exit, the environment and the error stream
import program
if len(program.arguments()) != 1 {
program.warn("usage: count <file>")
program.exit(2)
}
let verbose = program.environment("COUNT_VERBOSE") == "yes"
program.exit(code) ends the program with a number from 0 to 255,
program.environment(name) gives a str or none, and
program.warn(text) writes a line to the error stream. All three work
in every engine, every build and every target
(docs/ending-a-program.md,
decision 34).
Names that are taken now
c, ruby, php, lua and csharp are names of modules that come
with Zeno, so a program's own file of one of those names can no longer
be imported by it. InputPin, Pull, Serial and AnalogPin are
names of types, and baud a unit. Nothing else that ran in 0.5.2 is
refused.
Mended
--target wasmand--target rust:sleepcould wake a fraction
of a millisecond early, sonow() - startaftersleep(20 ms)
could read less than 20 ms. It now waits until the clock says the
time is up, aszeno rundoes.- With no collector, a list that was the default of a field was
freed too soon. A class such asclass Bag { items: list[str] = [] },
made asBag()in a--no-collectoror--ownedbuild (and their
--llvmbuilds), lost its list at the end of the statement while
the object still pointed at it, and the next use read freed memory.
0.5.2 had this too; two samples of the book showed it. The new object
now owns that list, and the check of--minimalbuilds fails a
program that the system stops, which is how both samples had hidden
it. zeno buildrefuses to write over a file of C that the program
names forimport c.
As fast as 0.5.2
The new numbers, the board and program.exit are code that runs only
when a program asks for it, and this release was held to that. It did
not hold by itself. Measured against 0.5.2, zeno run --vm had become
up to 3% slower for programs that use none of it, and zeno run about
1%. Four causes were found, each with the counting tool and not from
the clock, and each was mended (decisions 34.5, 34.7 and 42.11):
program.exit had given the VM's inner loop one more way to end,
== had grown too big to be copied into its callers, every operator
asked whether a side was an f32 and again whether it was a u64, and
the board's new fields had pushed apart what the VM reads on every
step.
Programs built with zeno build, in every form (--release,
--owned, --fast), run the instructions they ran in 0.5.2, to
0.02%. Counted in millions of instructions:
zeno run --vm 0.5.2 |
0.6.0 | zeno run 0.5.2 |
0.6.0 | |||
|---|---|---|---|---|---|---|
| fib | 3,146 | 3,135 | −0.3 % | 12,786 | 12,499 | −2.2 % |
| loop | 21,081 | 21,181 | +0.5 % | |||
| sort | 12,213 | 12,211 | 0.0 % | 49,352 | 48,436 | −1.9 % |
| strings | 4,310 | 4,307 | −0.1 % | |||
| trees | 21,111 | 21,051 | −0.3 % | 50,745 | 50,405 | −0.7 % |
| nbody | 40,469 | 40,420 | −0.1 % |
(The empty places take too long under the counting tool to be worth
it; the timings below cover them.)
Timed, in seconds, the best of five or six rounds, the two versions
run in turn:
zeno run --vm 0.5.2 |
0.6.0 | zeno run 0.5.2 |
0.6.0 | |
|---|---|---|---|---|
| fib | 0.56 | 0.56 | 2.16 | 2.14 |
| loop | 5.76 | 5.77 | 25.04 | 22.96 |
| sort | 2.64 | 2.60 | 10.63 | 10.36 |
| strings | 1.30 | 1.27 | 2.38 | 2.37 |
| trees | 7.15 | 7.21 | 16.48 | 16.72 |
| nbody | 12.33 | 11.83 | 40.53 | 39.91 |
A difference of one or two in a hundred either way is the machine,
not Zeno. loop in the VM runs one instruction more in each turn of
its loop than in 0.5.2 and takes the same time.
The archives
| Machine | File |
|---|---|
| Linux, x86-64: most PCs and servers | zeno-0.6.0-linux-x86_64.tar.gz |
| Linux, ARM64: a Raspberry Pi 3, 4 or 5 with a 64-bit system, ARM servers | zeno-0.6.0-linux-arm64.tar.gz |
| Linux, 32-bit ARMv7: a Raspberry Pi 2 or later with a 32-bit system | zeno-0.6.0-linux-armv7.tar.gz |
| Linux, 32-bit ARMv6: a Raspberry Pi 1 or Zero | zeno-0.6.0-linux-armv6.tar.gz |
| Linux, 32-bit x86 | zeno-0.6.0-linux-x86.tar.gz |
| macOS, Apple silicon | zeno-0.6.0-macos-arm64.tar.gz |
| macOS, Intel | zeno-0.6.0-macos-x86_64.tar.gz |
| Windows, x86-64 | zeno-0.6.0-windows-x86_64.zip |
| Windows, 32-bit x86 | zeno-0.6.0-windows-x86.zip |
| Windows, ARM64 | zeno-0.6.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.6.0-linux-x86_64.tar.gz
cd zeno-0.6.0-linux-x86_64
./zeno --version
./zeno build --release examples/hello.zeno && ./hello
./zeno build --target py examples/hello.zeno && python3 hello.pyOn 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, zeno search
and zeno publish need git. zeno build --target needs nothing to
write the file (but wasm, which needs Rust), and the language to run
it. import python, node, java, ruby, php, lua and csharp
need that language, and import c a C compiler. zeno build --web
and everything else need nothing.
What was checked
As for 0.5.2, 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 and wrote examples/hello.zeno in fourteen
languages. The whole test suite, 622 tests, passes on Linux
x86-64, on macOS on Apple silicon and on Windows x86-64.
The fifteen targets were checked on Linux x86-64, on GitHub's machine,
with the newest Node, TypeScript, Python, PHP, Lua, Ruby, Dart,
Kotlin, Go, Java, .NET, g++ and Rust: 364 of 364 programs each, and
349 of 349 for the page, which is opened in Chromium. --minimal was
checked there and on macOS on 413 programs.
The speed was compared with 0.5.2 on one machine, Linux on x86-64,
counted and timed. The builds for the other systems are made the same
way but were not timed.
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.