delta is a programming language and runtime for games and interactive applications. Currently in early concept stage.
delta is designed with a focus on functional programming patterns, pattern matching, and expressive syntax for game development. The language features a pipeline-based function calling syntax, robust pattern matching with guards, and a type system optimized for interactive applications.
- Integers:
1,42,-5 - Floats:
3.14,-0.5 - Booleans:
true,false - Strings:
"Hello","World" - Tags:
:ok,:err "Something went wrong"
1 + 2 + 3 # Addition: 6
10 - 5 # Subtraction: 5
3 * 4 # Multiplication: 12
8 / 2 # Division: 4
7 % 3 # Modulo: 1
true and false # Logical AND: false
true or false # Logical OR: true
not true # Logical NOT: false
Equality
5 == 5 # Equality: true
3 != 4 # Inequality: true
Integer comparisons
10 > 5 # Greater than: true
3 < 7 # Less than: true
5 >= 5 # Greater than or equal: true
2 <= 8 # Less than or equal: true
Float comparisons
10.3 >. 5.2 # Greater than: true
3.2 <. 7.4 # Less than: true
5.0 >=. 5.0 # Greater than or equal: true
2.1 <=. 8.7 # Less than or equal: true
delta supports string interpolation with expressions inside {} braces:
"Result: {40 + 2}" # "Result: 42"
Functions are defined using the \ (lambda) syntax:
add = \v1 v2
v1 + v2
is_even = \v
v % 2 == 0
greet = \name
"Hello {name}!"
Functions are called and composed using pipes.
3 | add 1 | is_even # Returns true (4 is even)
The result on the left-hand side of the pipe is passed as the first argument to the function on the right-hand side of the pipe. For instance, in arg | func1 arg2 | func2, arg is passed as the first argument to func1 and the result of func1 is passed as the only argument to func2.
delta supports tagged unions:
# Creating tagged values
:ok # Success without payload
:error "oh noes!" # Error with payload
:the_answer 42 # Tag with an integer payload
Pattern matching is performed using the is keyword:
# Basic pattern matching
2 is
1
"one"
2
"two"
3
"three"
_
"something else entirely"
# Pattern matching on tags
result = :ok "it worked!"
result is
:ok "great success"
"Hurray, great success!"
:ok value
"Success: {value}"
:error
"An error occurred"
other
"Unknown value: {other}"
Patterns can include conditional guards using if:
number is
1
"exactly one"
other if other >= 2
"two or greater: {other}"
other if other % 2 == 0
"dunno, but it's even"
_
"none of the above"
Here's a complete example showing multiple language features:
match = \tag
tag is
:container x
"container with value {x}"
other
"other value: {other}"
(:container 4) | match
# Returns: "container with value 4"
- Rust toolchain (latest stable)
- Cargo package manager
To run a delta program:
cargo run -- examples/workbench.∆For detailed execution information including bytecode and VM statistics:
cargo run -- examples/workbench.∆ --debugThis will show:
- Compiled bytecode
- Disassembled instructions
- VM execution statistics (stack allocations, instructions executed, etc.)
You can run any delta file by providing its path:
cargo run -- path/to/your/file.∆
cargo run -- path/to/your/file.∆ --debugThe project uses comprehensive snapshot testing to ensure language behavior consistency. The test suite is located in the snapshots/tests/ directory and covers.
To run and update all snapshot tests:
cd snapshots
cargo runEach test is defined in a TOML file with this structure:
script = """
# delta code goes here
1 + 2 + 3
"""
[output]
result = "6"
type = "integer"
[output.compiler]
bytecode = "[...]"
bytecode_length = 42
disassembled = """
# Disassembled bytecode instructions
"""
[output.vm]
bytes_read = 43
instructions_executed = 5
jumps_performed = 0
max_stack_height = 2
stack_allocations = 6The test suite is organized into categories:
base/- Basic language features (arithmetic, booleans, strings, comparison)functions/- Function definition, calling, and chainingpattern_matching/- Pattern matching with various complexity levelstags/- Tagged value creation and matchingtypes/- Type system behaviorerrors/- Error handling and edge cases
src/- Main language implementation (compiler, VM, runtime)examples/- Example delta programssnapshots/- Test runner and snapshot test filessnapshots/tests/- Comprehensive test suite organized by feature
delta emphasizes:
- Pipeline-first design: Function composition through pipelines
- Pattern matching: Robust pattern matching with guards for control flow
- Type safety: Strong typing with inference
- Expressiveness: Concise syntax for common game development patterns
- Performance: Bytecode compilation for efficient execution
This project is in early development. The snapshot test suite provides a comprehensive specification of current language behavior and serves as both documentation and regression testing.
To contribute:
- Add tests for new features in
snapshots/tests/ - Run
cd snapshots && cargo runto validate changes - Ensure all existing tests continue to pass