Zith's syntax is designed to be explicit, readable, and consistent — drawing from C-family familiarity while removing ceremony.
// Line comment
/* Block comment */
/** Doc comment — attached to the following declaration */
Identifiers use camelCase. Start with a letter or _, followed by letters, digits, or _.
playerName // OK
_private // OK
2beOrNot // Error: starts with digit
| Category | Keywords |
|---|---|
| Declarations | fn, let, var, const, global, struct, enum, union, component, trait, implement, type |
| Control flow | if, else, for, when, is, ->, or |
| Functions | async, yield, flow, marker, dock, jump, entry, raw, unsafe |
| Ownership | lend, view, unique, share, belong |
| Modules | import, from, export, pub, mod, alias, use |
| Error handling | ?, !, or, with, catch, fail, must, throw |
| Other | spawn, await, comptime, scene, dyn, opaque, Trust |
Almost everything is an expression. The last expression in a block is the return value (implicit return).
fn add(a: i32, b: i32): i32 { a + b }
fn main() {
let result = if (x > 0) { x * 2 } else { 0 };
@println("{result}");
}
| Category | Operators |
|---|---|
| Arithmetic | +, -, *, /, % |
| Comparison | ==, !=, <, >, <=, >= |
| Logical | and, or, not |
| Chain | -> (pipe forward), .. (previous value) |
| Error | ? (optional), ! (failable), ?? (null coalesce) |
| Type | is (type check), as (cast), : (type annotation) |
| Ownership | lend, view (borrow modifiers on types) |
camelCase — playerName, processDataPascalCase — Player, PositionSCREAMING_SNAKE_CASE — MAX_PLAYERSkebab-case.zithNext: Types →