Design Principles
Core Model: Data Flows, Not State Mutates
Mainstream languages center on variables that hold and mutate state. rill centers on data flowing left-to-right through transformations.
Mainstream mental model
- Read variable
- Modify variable
- Write variable
rill mental model
- Data enters pipeline
- Transformations shape it
- Result emerges at the end
Every rill program answers one question: “What happens to this data as it moves through the pipe?”
Seven Principles That Break Mainstream Habits
1. Pipes Replace Assignment
No = operator exists. Data moves via ->, values captured via =>.
# Data flows through transformations
" hello world " -> .trim -> .upper -> .split(" ")
# Result: list["HELLO", "WORLD"]use<ext:app> => $app
# Capture only when a value appears more than once
$app.prompt("analyze") => $result
$result -> log
$result -> .contains("ERROR") ? { error "Analysis failed: {$result}" }Mainstream habit to break: Creating intermediate variables for each step. In rill, let data flow. Capture only for reuse.
2. Null Does Not Exist
No null, undefined, nil, or None. Missing values produce errors. Use ?? for defaults and .? for existence checks.
[name: "alice"] => $user
$user.name ?? "anonymous" # Default if missing
$user.?email # Returns true or falseMainstream habit to break: Checking for null before access. In rill, decide upfront what the default is, or let the error surface.
3. No Truthiness
Conditions must evaluate to boolean. Empty strings, zero, and empty lists are not “falsy.”
# These are errors — conditions must be boolean:
# "" ? "yes" ERROR
# 0 ? "yes" ERROR
# [] ? "yes" ERROR
# Explicit boolean conversion required:
"" -> .empty ? "empty"
0 -> ($ == 0) ? "zero"
[] -> .empty ? "no items"Mainstream habit to break: Using values directly as conditions. In rill, convert to boolean explicitly with .empty, comparisons, or :?type.
4. No Exceptions
Errors halt execution. No try/catch, no error recovery stack. Validate before acting.
# Guard early
$input -> .empty ? error "Input required"
# Assert constraints
$data -> assert :?list "Expected list"
# Check patterns in results
$response -> .contains("ERROR") ? error "Failed: {$response}"Mainstream habit to break: Wrapping operations in try/catch. In rill, validate inputs and check outputs with conditionals.
5. Scopes Are Sealed
Inner scopes read outer variables but never rebind them. Capturing into an outer name from a loop body halts RILL-R001.
# Error: RILL-R001
0 => $count
list[1, 2, 3] -> seq({ $count + $ => $count })Carry state through the loop with an accumulator instead:
list[1, 2, 3] -> fold(0, { $@ + $ })
# Result: 6list[1, 2, 3] -> acc(0, { $@ + $ })
# Result: list[1, 3, 6]dict[result: "", done: false] -> while (!$.done) do {
"a{$.result}" => $r
dict[result: $r, done: ($r.len == 5)]
}
# Result: dict[done: true, result: "aaaaa"]Mainstream habit to break: Mutating a counter or accumulator variable from inside a loop. In rill, $ carries state forward through iterations, and $@ holds the accumulator in fold and acc.
6. Everything Is a Value
No references. All values are immutable. All comparisons are by value. == and != halt with #TYPE_MISMATCH when the operand types cannot overlap, as in 1 == "1". Types lock on first assignment.
[1, 2, 3] == list[1, 2, 3] # true — content equality
[1, 2] => $a
$a => $b # $b behaves independently — values cannot be mutatedMainstream habit to break: Expecting two variables to point at the same mutable object. In rill, values are immutable, so bindings never interfere with each other.
7. Variables Have $ Prefix
All variables start with $: $name, $result, $config. This is a deliberate design choice, not syntactic sugar.
Why $ exists:
The $ prefix enables single-pass, unambiguous parsing without a symbol table. The parser can distinguish constructs at tokenization:
| Syntax | Meaning |
|---|---|
name() | Host function call |
$name() | Function invocation |
$name | Variable reference |
name in dict | Key literal |
Without $, process(data) is ambiguous: is process a host function or a stored function? Is data a variable or a key? Resolving this requires tracking all declarations—turning a simple parser into a multi-pass compiler.
Additional disambiguation:
- Capture syntax:
=> $xrequires$for lookahead. Without it, slice syntaxslice<1:>becomes ambiguous. - Destructuring:
destruct<$a, $b>uses$to mark variables vs. skip patterns or dict keys. - Dynamic field access:
$data.$keydistinguishes variable-as-key from literal field. - Visual clarity: Code is readable without context.
$totalis always a variable.
Alternatives considered:
| Approach | Problem |
|---|---|
Different prefix (@name) | Same complexity, no improvement |
| Type annotations required | Doubles verbosity, needs type registry at parse |
var keyword | Still can’t distinguish fn() (host) from $fn() (function) |
| Context-aware parsing | 3-5x slower, requires symbol table |
The $ prefix follows rill’s “no magic” principle: syntax communicates intent without requiring context or implicit rules.
Mainstream habit to break: Expecting bare identifiers for variables. In rill, $ makes the distinction between variables, functions, and dict keys explicit and unambiguous.
Rillistic Idioms
Flow, Don’t Store
# Not rillistic: unnecessary intermediates
"hello" => $step1
$step1 -> .upper => $step2
$step2 -> .len => $step3
$step3
# Rillistic: let data flow
"hello" -> .upper -> .lenShorthand in Collection Operators
# Not rillistic: verbose function
["hello", "world"] -> fan(fn(x) { $x.upper() })
# Rillistic: method shorthand
["hello", "world"] -> fan({ $.upper })Defaults Over Conditionals
# Not rillistic: verbose existence check
$dict.?field ? $dict.field ! "default"
# Rillistic: default operator
$dict.field ?? "default"Accumulators Over Mutation
# Not rillistic: trying to mutate outer scope
"" => $result
["a", "b", "c"] -> seq({ $result + $ => $result })
# Rillistic: fold produces the value
["a", "b", "c"] -> fold("", { $@ + $ })Explicit Booleans Over Coercion
"hello" => $str
$str -> .empty ? "no" ! "yes"$ in Context, Parameters in Stored Functions
# Rillistic: $ in inline pipes and loops
"hello" -> { .upper }
[1, 2, 3] -> seq({ $ * 2 })
0 -> while ($ < 5) do { $ + 1 }
# Rillistic: named params in stored functions
fn(x) { $x * 2 } => $double
5 -> $double$ binds to the current pipe context. Stored functions use named parameters because $ is undefined when called later.
Summary Table
| Mainstream concept | rill replacement |
|---|---|
x = value | value => $x or value -> transform |
null / undefined | ?? default, .? existence check |
Truthiness (if "") | .empty, == 0, :?type |
try { } catch { } | assert, conditionals, error |
for (i = 0; ...) | seq, fan, filter, fold, acc |
count += 1 in loop | fold(0, { $@ + 1 }) or $ accumulator |
a === b (reference) | == compares by value; types that cannot overlap halt |
a = b (shared ref) | => binds immutable values — no mutation possible |
See Also
- Guide — Beginner-friendly introduction
- Reference — Language specification
- Conventions — Naming and best practices