A simple, expressive programming language inspired by Odin and Rust, compiled to LLVM IR.
- Clean syntax with
<-for assignment and::for declarations - Strong typing with type inference
- LLVM backend for fast native code generation
- Familiar constructs: structs, enums, pattern matching, range-based loops
Requirements:
- Odin compiler
- LLVM (llvm-16 or later recommended)
# Build the compiler
odin build . -build-mode:exe -file
# Run an example
./acorn run examples/00_hello_world.acorn
# Or compile and run separately
./acorn build examples/00_hello_world.acorn -o hello
./hello// Functions use :: syntax
import "core:fmt"
main :: fn() -> int {
fmt.println("Hello, World!")
return 0
}
// Variables with <-
x <- 42
y <- x + 10
// Structs
Point :: struct {
x: int
y: int
}
p <- Point{x: 10, y: 20}
// Loops
for i in 0..10 {
fmt.println(i)
}
// Pattern matching
match value {
Some(x) => fmt.println(x)
None => fmt.println("nothing")
}
Download from the releases page.
git clone https://github.com/Aidan-Stokes/acorn-lang.git
cd acorn
odin build . -build-mode:exe -file
sudo cp acorn /usr/local/bin/# Compile
acorn build <file> # Build executable
acorn build <file> -o out # Custom output name
acorn build <file> -c # Output object file (.o)
acorn build <file> -S # Output assembly (.s)
# Run directly
acorn run <file>
# Type check only
acorn check <file>
# Format code
acorn fmt <file>Import modules with qualified access:
import "core:fmt"
main :: fn() -> int {
fmt.println("Hello!") // Use fmt.println, not print
return 0
}
core:fmt- Formatting (print, println, printf)core:math- Math constants and functionscore:arrays- Array utilitiescore:strings- String operationscore:io- I/O operations
// Basic - use qualified access
import "core:math"
fmt.println(math.PI)
// Selective - import specific symbols
import "core:math" { PI }
fmt.println(PI)
// Alias - rename module
import "core:math" as m
fmt.println(m.PI)
// Combined
import "core:math" { PI } as m
fmt.println(m.PI)
See the examples/ directory for working code:
| Example | Description |
|---|---|
00_hello_world.acorn |
Basic function |
02_variables.acorn |
Variable assignment |
03_arithmetic.acorn |
Math operations |
07_if_else.acorn |
Conditionals |
08_for_range.acorn |
Range loops |
23_structs.acorn |
Struct declarations |
24_enums.acorn |
Enum types |
27_match.acorn |
Pattern matching |
Run all examples:
cd examples && ./run_all.sh| Type | Description |
|---|---|
int |
Default integer (u64) |
i32, i16, i8 |
Signed integers |
uint, u32, u16, u8 |
Unsigned integers |
f32, f64 |
Floating point |
bool |
Boolean (true/false) |
char, rune |
Character (32-bit) |
string, str |
String |
[]T |
Dynamic arrays |
See ROADMAP.md for implementation status and planned features.
- Fork the repository
- Create a feature branch
- Make your changes
- Run examples to verify:
./acorn build examples/*.acorn - Submit a pull request
MIT License - see LICENSE file for details.