Skip to content

Commit d8a0e83

Browse files
committed
Adds language comparisons to the Z introduction page.
Signed-off-by: Amy Ringo <me@remexre.com>
1 parent 632dffc commit d8a0e83

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed

doc/z/concepts.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ It's not necessary for a Z learner to read and understand everything here before
55

66
## Syntax
77

8+
Z's syntax is based on [Shrubbery notation](https://docs.racket-lang.org/shrubbery/index.html).
9+
810
### Reading and parsing
911

1012
## Compilation

doc/z/introduction.md

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,55 @@
11
# Z Introduction
22

3-
The Z language is an efficient Lisp dialect, used for ukoOS's userspace.
3+
The Z language is a compiled, garbage-collected, object-oriented language, used for ukoOS's userspace.
44

5-
Z is relatively similar to Common Lisp; a programmer new to Z without existing Common Lisp experience should assume that idiomatic Z code will often have a broadly similar architecture to idiomatic Python code.
6-
However, Z uses [Shrubbery notation](https://docs.racket-lang.org/shrubbery/index.html) as its syntax instead of S-expressions.
5+
Brief comparisons to some popular languages:
6+
7+
- **Python** (in particular, as implemented by CPython):
8+
- This is the language that's most similar to Z if you consider both syntax and semantics.
9+
- Both are gradually-typed, though Z also checks type annotations at runtime.
10+
- Interactive development is supported in Z, kinda like Jupyter.
11+
- Unlike Python, Z is ahead-of-time compiled: currently, there is no interpreter, even for the REPL.
12+
- Unlike Python, Z has macros.
13+
- **C**, **C++**, and **Rust** (in particular, as implemented by GCC, LLVM, and rustc):
14+
- These would be the normal choices for the "default language" in userspace.
15+
- These languages avoid garbage collection for performance reasons.
16+
Z allows writing low-level code that manually manages memory, but it's not the default.
17+
- Unlike these languages, Z supports interactive development.
18+
Testing changes to a program can be done without stopping running instances of it.
19+
- Unlike C and C++, Z's macro system allows writing macros in Z (like proc macros in Rust).
20+
- **Go:**
21+
- Like Go, Z is both compiled and garbage-collected.
22+
- Like Go, Z's method definitions are separate from its type definitions.
23+
- Like Go, Z has async without "function coloring."
24+
- Unlike Go, Z has a REPL and supports interactive development.
25+
- Unlike Go, Z has operator overloading and macros.
26+
- Unlike Go, Z has inheritance and open recursion.
27+
- **Java** (in particular, as implemented by OpenJDK):
28+
- This is another garbage-collected object-oriented language sometimes used for low-level programming (e.g. in high-performance databases).
29+
- Z's support for low-level programming is broadly similar to Java's (e.g. `sun.misc.Unsafe`).
30+
- Like Java, Z allows loading code at runtime and safely modifying running code.
31+
- Unlike Java, Z does not use a JIT compiler.
32+
To be precise, Z does dynamic compilation but not dynamic recompilation -- once a function's machine code is generated, it is not recompiled at runtime without the programmer writing code to do this.)
33+
- This leads to more predictable performance and faster short-running tasks.
34+
- Unlike Java, Z supports multiple dispatch and multiple inheritance.
35+
- **JavaScript** (in particular, as implemented by QuickJS and V8):
36+
- Like JavaScript's HMR, Z supports interactive development.
37+
- Like TypeScript, Z supports gradual typing.
38+
- Unlike TypeScript, Z checks the type annotations at runtime.
39+
- Unlike JavaScript, Z is strongly typed (it does not perform implicit coercions).
40+
- Unlike JavaScript, Z does not have a "baseline" interpreter.
41+
- Unlike the V8 implementation of JavaScript, Z does not have a JIT compiler.
42+
- Unlike the QuickJS implementation of JavaScript, Z compiles to machine code.
43+
- Unlike JavaScript, Z doesn't have "function coloring."
44+
45+
Brief comparisons to some other languages that are similar to Z:
46+
47+
- **Common Lisp:**
48+
- Z directly takes most of its semantics from Common Lisp.
49+
- The biggest departure from Common Lisp is the use of shrubbery syntax.
50+
- Unlike Common Lisp, Z supports delimited continuations as a control-flow primitives.
51+
- Like `CL:THROW`, these are a low-level primitive; most code just does IO and doesn't worry about control effects.
52+
- This *does* spill into `CL:UNWIND-PROTECT` -- when we capture a delimited continuation, we've exited its dynamic scope, but calling the continuation re-enters it.
53+
- **Racket**, **Rhombus**, and **Scheme:**
54+
- Z shares the shrubbery notation syntax with Rhombus, and uses syntax objects rather than simple data structures.
55+
- Unlike Scheme-family languages, Z has mutable data structures, and they're usually the "default" ones to use.

0 commit comments

Comments
 (0)