Repository navigation
Zeno 0.7.0
Zeno 0.7.0 takes a program from a .zeno file to a chip in one step.
zeno build --board runs the board's own compiler, a board can print
and stop by itself with no C library under the program, and a number
with a fraction is made into text by Zeno itself: primes.zeno, which
shows one, takes 7,884 bytes of flash on an ARM Cortex-M3. The board
module has the three things it lacked: a PWM signal, a steady beat,
and edges counted by an interrupt. And the C that a build writes can
be read by a C compiler that is neither GCC nor Clang.
It is a release for firmware, as 0.6.0 was, and it ends the eighth of
the fourteen items of
docs/missing.md,
the list of what Zeno lacks. No program of Zeno's has run on a real
board yet: everything here was tried on two boards that QEMU
emulates, and the notes say so where it matters.
Everything a program wrote for 0.6.0 means what it meant, and no name
is taken that a program could have used.
Installing
Windows: download zeno-0.7.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.7.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.7.0_amd64.deb # Debian, Ubuntu, Raspberry Pi OS
sudo pacman -U zeno-lang-bin-0.7.0-1-x86_64.pkg.tar.zst # Arch
sudo snap install --classic --dangerous zeno_0.7.0_amd64.snap
flatpak install --user zeno-0.7.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.
A PWM signal, a steady beat, and edges
from board import pwm_pin, ticker, input_pin, pull_up, falling
let lamp = pwm_pin(9, 1 kHz)
lamp.duty(0.25) # on for a quarter of the time
let beat = ticker(10 ms)
let button = input_pin(2, pull_up)
let presses = button.interrupt(falling)
while true {
beat.wait() # the next tick, however long the work took
if presses.edges() > 0 {
lamp.duty(1.0)
}
}
pwm_pin(9, 1 kHz)gives aPwmPin:duty(0.25)for a share of
the time,pulse(1500 us)for a servo.
docs/pwm.mdticker(10 ms)gives aTicker:wait()waits for the next
tick and says how many came, so a loop keeps its time and knows when
it was late.
docs/ticker.mdbutton.interrupt(falling)counts edges in the board's
interrupt, and the program asks for the count. The program's own
code never runs inside an interrupt.
docs/interrupts.md
On a computer the board is simulated, as before.
One step to a board
zeno build --board boards/qemu-cortex-m3 blink.zenoA board is a folder. Its zeno.board names the compiler, the flags,
the start-up files, the linker script and the command that runs the
result, because those are the board's and not the program's. Zeno
writes the C and types the one long command.
Two boards come with Zeno, and both are one chip that QEMU emulates,
an ARM Cortex-M3 with 256 KB of flash and 64 KB of RAM. Every example
that a build with no collector accepts is built for both and compared
with the same program on a computer. No program of Zeno's has run on
a real board yet. The two folders are in each archive below, under
boards/, and install.sh puts them in ~/.zeno/boards. The setup
program for Windows and the packages of apt, pacman, snap, flatpak and
Homebrew do not carry them yet: there, take boards/ from an archive
or from the repository.
docs/board-build.md
A board that prints and stops by itself
A board's header says #define ZENO_BOARD_PRINTS and brings four
functions: for what is printed, what is said beside it, what is typed,
and stopping. Then nothing of the program goes through the C library's
streams or its exit. boards/lm3s6965evb is written that way, on the
chip's own pin, timer and UART registers, and hello takes 936 bytes
of flash there.
docs/board.md
A float with no C library
print(x), {x:.2f} and float("2.5") were the C library's
snprintf and strtod, which are 28 KB of flash on a Cortex-M3. The
runtime now does all three itself, with whole numbers and exactly, in
4 KB.
| program, flash in bytes | boards/qemu-cortex-m3, a C library under it |
boards/lm3s6965evb, the chip's registers |
|---|---|---|
hello.zeno |
9,472 | 936 |
primes.zeno |
16,172 | 7,884 |
tour.zeno |
22,000 | 14,032 |
The first build for a board, with fprintf and snprintf under the
runtime, made the three 9,772, 38,568 and 50,184 bytes.
On a computer a float is written five to eight times faster, and read
as fast as before.
A C compiler that is neither GCC nor Clang
The C of a build asked GCC and Clang for a few things by their own
names: whether a sum, a difference or a product overflowed, first of
all. A compiler with none of those names (IAR's, Keil's older one,
tcc) stopped there. Each is now written a second time in plain C, and
a compiler gets the one it can read, with nothing to ask for.
tcc builds every example, and each does what it does built by gcc. On
a Cortex-M3 the plain C is as small as the other. No program has
been built by IAR's, Keil's or a chip maker's compiler yet.
docs/plain-c.md
The book and the history
The Zeno Book is up to date with this
release, and has caught up with the last one: the chapter on the
libraries of other languages now has Ruby, PHP, Lua and C#, and a new
chapter, "Libraries of C", shows import c from a first call to a
small driver with its header, built into the program by zeno build.
It is 302 pages, and the 356 programs in it were run by this release
as the book was built.
HISTORY.md
is new: every commit of the repository, oldest first, under the
release it went into, each with one plain line on what it changed. The
website shows it at zeno-lang.org/history.
Mended
- 46 powers of two were printed with 17 digits by a build, where
16 name them andzeno runprinted 16:2.0 ** -44.0is
5.684341886080802e-14. The C, the C++ target and the Lua target
had it. - A NaN with decimals,
f"{x:.2f}", wasnanor-nanin a
build. It isNaN, as underzeno run. a * b + con floats is two steps for every C compiler. The
line that says so was given to gcc and Clang alone. It is now the
line C itself has for it, for any compiler.--target cppand--target luaprinted the same 46 powers of
two with 17 digits. They print 16, aszeno rundoes.
As fast as 0.6.0
What a program does not ask for, it must not pay for, and this release
was held to that as the last two were. It did not hold by itself, and
it does not hold in one place.
Built programs. The count found two of them one in a hundred
slower: fib built with --release, and trees with
--fast --owned. The plain C had taken the word that keeps the top of
the program out of main away from every compiler, and called it
through a pointer. GCC then no longer made fib a copy of its own for
that call, and put the top of trees inside main. GCC and Clang now
get what 0.6.0 gave them, and only a compiler that is neither gets the
pointer (decision 55.4). Programs built with zeno build, checked,
with --release, with --release --owned and with --fast --owned,
run the instructions they ran in 0.6.0, to 0.03%, but for one: nbody
with --release --owned runs 0.15% more, one instruction in each step
of its loop. Its own C is what it was. The runtime beside it has the
new code for floats, and GCC lays the loop out with one instruction
more.
zeno run --vm and zeno run run the instructions they ran in
0.6.0. Counted in millions of instructions:
zeno run --vm 0.6.0 |
0.7.0 | zeno run 0.6.0 |
0.7.0 | |||
|---|---|---|---|---|---|---|
| fib | 3,135 | 3,135 | 0.0 % | 12,499 | 12,499 | 0.0 % |
| loop | 21,181 | 21,181 | 0.0 % | 84,061 | 84,061 | 0.0 % |
| sort | 12,211 | 12,213 | 0.0 % | 48,439 | 48,422 | 0.0 % |
| strings | 4,307 | 4,310 | +0.1 % | 8,881 | 8,882 | 0.0 % |
| trees | 21,051 | 21,051 | 0.0 % | 50,377 | 50,417 | +0.1 % |
| nbody | 40,420 | 40,416 | 0.0 % |
(nbody under zeno run takes too long under the counting tool.
trees there does not run the same number twice: three runs of 0.7.0
gave 50,417 to 50,615.)
Timed, in seconds, the best of four rounds, the two versions run in
turn:
zeno run --vm 0.6.0 |
0.7.0 | zeno run 0.6.0 |
0.7.0 | |
|---|---|---|---|---|
| fib | 0.80 | 0.81 | 3.10 | 3.07 |
| loop | 8.31 | 8.19 | 33.39 | 34.51 |
| sort | 3.77 | 3.72 | 14.86 | 14.41 |
| strings | 1.71 | 1.73 | 3.22 | 3.24 |
| trees | 10.03 | 9.67 | 24.45 | 24.35 |
| nbody | 17.07 | 16.77 | 58.31 | 58.32 |
(The machine was slower that day than when 0.6.0 was timed against
0.5.2. Only the two columns of one row are to be compared.)
loop under zeno run is 3% slower by the clock, with the same
instructions to the seventh digit, and that is not mended. It was
traced to the stage that brought interrupts, and is not in what the
code does: the same build started under another name takes up to 3%
more or less, and with both versions built so that their branches lie
elsewhere the difference is 1%. On the machine it was measured on, the
new code happens to lie worse for the interpreter's loop. The board's
tables were moved out of the interpreter, as they were out of the VM
in 0.6.0, which gave back one part in a hundred. Decision 50.7 has the
measurements. A difference of one to three in a hundred either way in
the other rows is the machine, not Zeno.
The archives
| Machine | File |
|---|---|
| Linux, x86-64: most PCs and servers | zeno-0.7.0-linux-x86_64.tar.gz |
| Linux, ARM64: a Raspberry Pi 3, 4 or 5 with a 64-bit system, ARM servers | zeno-0.7.0-linux-arm64.tar.gz |
| Linux, 32-bit ARMv7: a Raspberry Pi 2 or later with a 32-bit system | zeno-0.7.0-linux-armv7.tar.gz |
| Linux, 32-bit ARMv6: a Raspberry Pi 1 or Zero | zeno-0.7.0-linux-armv6.tar.gz |
| Linux, 32-bit x86 | zeno-0.7.0-linux-x86.tar.gz |
| macOS, Apple silicon | zeno-0.7.0-macos-arm64.tar.gz |
| macOS, Intel | zeno-0.7.0-macos-x86_64.tar.gz |
| Windows, x86-64 | zeno-0.7.0-windows-x86_64.zip |
| Windows, 32-bit x86 | zeno-0.7.0-windows-x86.zip |
| Windows, ARM64 | zeno-0.7.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, the two
boards and the editor setup.
tar -xzf zeno-0.7.0-linux-x86_64.tar.gz
cd zeno-0.7.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 --board needs the compiler the board names: for
the two boards that come with Zeno, arm-none-eabi-gcc, and QEMU to
run the result. 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.6.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 and wrote examples/hello.zeno in fourteen
languages. The whole test suite, 648 tests, passes on Linux
x86-64, on macOS on Apple silicon and on Windows x86-64.
On the two boards. Every example, every sample of the book and
the corner programs that a build with no collector takes were built
for both boards and run in QEMU, and each did there what it does on a
computer: 231 of 231 programs on boards/qemu-cortex-m3 and 211
of 211 on boards/lm3s6965evb, and with --minimal 215 of 215 and
196 of 196. Nothing was run on a real board: not the pins, not the
PWM, not the interrupts, not the UARTs. What QEMU does not emulate (a
pull-up, the speed of a UART, a timer's own PWM output) is written
from the data sheet and has been tried nowhere.
In plain C. The C of 269 programs with a collector, 241 with
--owned and 241 with --no-collector was compiled as it is, as
plain C read by the standard of 1999 (gcc and Clang, -std=c99 -pedantic-errors), and by tcc 0.9.27, and the three do the same. No
program has been built by IAR's, Keil's or a chip maker's compiler.
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 243 programs with a collector, and on
223 to 240 in the other three kinds of build.
The speed was compared with 0.6.0 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.