|
1 | 1 | # Z Introduction |
2 | 2 |
|
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. |
4 | 4 |
|
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