1 Getting Zeno
Zeno is one program, called zeno. It checks your
programs, runs them, compiles them, tests them, lays them out, and talks
to your editor. This chapter puts it on your machine.
1.1 What you need
Zeno is written in Rust, and you build it from its source. You need:
Rust, with its build tool
cargo. The usual way to get both isrustup, from https://rustup.rs. Zeno uses no libraries beyond Rust itself, so nothing else is downloaded when it is built.git, to get the source, and later to fetch packages that live in other people’s repositories.
A C compiler,
cc,gccorclang, if you want to compile Zeno programs into programs that run on their own (Compiling).zeno runneeds none.clang, only if you want the second compiler, which goes through LLVM.
Zeno is built and tested on Linux, macOS and Windows, with the same
steps on each. On Windows, every path Zeno writes uses /,
as it does elsewhere, so a package or a message reads the same on every
machine.
1.2 Building it
Get the source and build it:
git clone https://github.com/partham20/zeno-lang
cd zeno-lang
cargo build --release
The finished program is target/release/zeno. To use it
from any folder, either put that folder on your PATH, or
let cargo copy the program into its own folder of programs, which
rustup has already put on your PATH:
cargo install --path .
Check that it works:
$ zeno --version
zeno 0.1.0
If you want to be sure that the compiler you built is a good one, run its own tests. There are several hundred of them, and each program in them is run by every engine and built every way Zeno can build it:
cargo test --release
1.3 Your first project
zeno new makes a folder with a small program in it,
ready to run:
$ zeno new greeter
Made the program `greeter` in greeter/
zeno.package the name of the program, and the packages it needs
main.zeno the program
greeting.zeno a module, with a test
Run it with `zeno run greeter/main.zeno`, and its tests with `zeno test greeter`.
$ zeno run greeter/main.zeno
Hello, world, from greeter.
$ zeno test greeter
greeter/greeting.zeno
ok hello says who it greets
1 test: 1 passed, 0 failed.
Three files were made. main.zeno is where the program
starts. greeting.zeno is a module, a second file
of the program, with a test at its end. zeno.package names
the program and, later, the packages it needs. You will meet each of
them properly: modules in Programs
in Several Files, packages in Packages, and tests in Testing. For now, a program can
be a single file with any name.
1.4 The commands
Everything Zeno does is a word after zeno. These are the
ones you will use most; The
zeno Command has all of them with every option.
| Command | What it does |
|---|---|
zeno run file.zeno |
Check the program, and run it if there is nothing wrong |
zeno check file.zeno |
Only check it, and report every mistake |
zeno test |
Run the tests written in the files of a folder |
zeno build file.zeno |
Compile it to C, and then to a program of its own |
zeno format file.zeno |
Lay the file out the one way Zeno lays programs out |
zeno new name |
Make a new program in a new folder |
zeno fetch |
Get the packages a program needs |
zeno lsp |
The language server that an editor starts |
1.5 An editor
Any editor that can save plain text will do. Zeno files end in
.zeno and are UTF-8 text. The Zeno repository has colours
and setup for VS Code, Vim, Neovim and Helix in its editors
folder, and zeno lsp lets those editors show mistakes as
you type, jump to where a name was declared, show a name’s type, and lay
the file out when you save it. The
Tools shows how to set each of them up.
Run
zeno --helpand read the list of commands. Which ones need a C compiler?Change the text that
greeting.zenogives back, and runzeno test greeteragain. Read what a failed test prints, then change the test so that it passes.Run
zeno new 2fastandzeno new while. What does Zeno say, and what does it suggest instead?