35 Why Zeno Is as It Is
Every chapter of this book has had boxes that give the reason for a choice. This last chapter steps back and looks at the choices together: the principles they come from, what Zeno took from the languages before it, what it left out on purpose, and what version 0.1 does not have yet.
35.1 Unambiguous and intuitive
One sentence was set down at the start, and every feature was held to
it: the entire language must be unambiguous and intuitive.
Unambiguous means a line has one reading, and a reader never has to work
out which of two things a symbol means. Intuitive means the reading it
has is the one a newcomer would guess. When the two pulled apart, a
message from the compiler bridged them: elif,
&&, def and ; are each
met with the Zeno spelling.
35.2 The five principles
Most decisions fall out of five principles. When two choices are otherwise equal, the one higher on the list wins.
Catch the mistake as early as possible. Before the program runs is better than while it runs; while it runs is better than a wrong answer. Zeno should never quietly do something the programmer did not mean.
Read like plain words. Code is read far more often than it is written. A whole word beats a symbol or an abbreviation.
Punctuation has to earn its place. A mark stays only if removing it would make code harder to read or easier to get wrong.
One way to say a thing, with one meaning. An operator or keyword should not change meaning with the values it is given.
Nothing a microcontroller cannot afford. Every feature must compile to small, predictable C with no hidden runtime.
Where Python already had a spelling that passed these tests, Zeno used it, because more people can read Python than any other language.
35.3 What came from where
Zeno set out to blend the good parts of the big languages. Here is where each part came from:
| From | Zeno took |
|---|---|
| Python | and/or/not,
in,
try/except/raise, f-strings,
comprehensions, import and from,
// and **, the precedence of the bit
operators, chained comparisons |
| C | braces, 0x numbers, the bit
operators, compiling to C itself, integer promotion (without its silent
cut) |
| C++ | generics checked for each use, compiled to a copy for each type |
| Rust | let, one owner for a value,
unsafe blocks, the sized number names, enums that carry
data and a match that must be complete |
| Java | interface, and a class that
says which ones it is |
| JavaScript | functions as values with closures, written in place |
| Go and Swift | no semicolons; Go’s square brackets for generics and its one layout for every file |
| Kotlin and TypeScript | a checker that follows
if x is not none |
35.4 What was left out, and why
As much of Zeno’s design is in what it does not have:
- No null that can appear anywhere.
-
Only
T or nonecan benone, and it must be asked about. - No quiet conversions.
-
An
intdoes not become afloat, aboolor astrby itself, and nothing is true or false but abool. - No wrapping arithmetic by default.
-
An overflow is an error; wrapping is a word,
wrap. - No negative indexes.
-
A position below zero is a mistake, not the other end of the list.
- No inheritance.
-
A class is read in one place; interfaces do what inheritance was mostly for.
- No constructor of your own.
-
The fields are the constructor, and a named function builds what needs checking.
- No exceptions that unwind.
-
Errors are declared with
raisesand compile to jumps or to return values, with no tables and no cost where they are not used. - No mutable default arguments shared between calls,
-
no
isfor comparing values, noelif, nolambda, no=>.
Each of these is something a language before Zeno had, and that somebody, somewhere, lost an afternoon to.
35.5 How decisions were made
Every decision in Zeno has a written reason, in the file
docs/decisions.md of the repository: what was decided, why,
and what was turned down. A decision made on less than it deserved was
marked provisional. Before version 0.1 each of the eighty or so
was read again and given one of three answers: settled, a stated limit
of 0.1, or changed. A choice with no good reason should not be in the
language, and if a better reason turns up for the opposite choice, the
choice should change.
The decisions are numbered, and the boxes in this book cite them, so anyone who wants the full argument for a rule can find it.
35.6 What 0.1 does not have
Every limit is refused today with a message, so each can be added later without changing what any program written now means. The main ones:
On a board: reading a pin, an analogue converter or a serial port, interrupts and timers. These must be designed against real hardware.
Numbers: a
u64, units made from other units, and reading a file as bytes.Types: unions other than
or none, interfaces with type parameters, and bounds on generics.The library:
sortby a function, reading a file in pieces,program.exit, random numbers.Builds: compiling for another processor in one step, and a few corners such as a named function inside a function.
Appendix G has the full list.
35.7 The name
Zeno is named after Zeno of Elea, whose paradoxes say that Achilles can never catch the tortoise: before he reaches it, he must reach halfway, and before that, halfway to halfway, for ever. And after the quantum Zeno effect, where a system watched closely enough never changes. Its motto is every journey is halfway done, forever: a fitting name for a language that will always be almost finished, and a good thing for a language to be, since it means there is always the next half to build.
Zeno is held to one sentence, unambiguous and intuitive, and five principles: catch mistakes early, read like words, earn every mark, one way with one meaning, nothing a microcontroller cannot afford. It takes from Python, C, C++, Rust, Java, JavaScript, Go, Swift, Kotlin and TypeScript, leaves out what has cost programmers most, and writes the reason for every choice down.