Getting Started
Prerequisites
- Rust toolchain (stable)
- macOS on Apple Silicon (for
vera build— the interpreter works on any platform)
Build from Source
git clone https://github.com/ewrogers/vera-lang.git
cd vera
cargo build
Hello World
Create hello.vera:
import "vera:io"
data greeting: "Hello, World!\n"
function main() -> i32 {
constant.ptr message, greeting
constant.i64 length, 14
call bytes_written, write_stdout, message, length
constant.i32 exit_code, 0
return exit_code
}
Run it with the interpreter:
cargo run -- run hello.vera
Hello, World!
Or compile to a native binary:
cargo run -- build hello.vera -o hello
./hello
CLI Commands
vera run
Interpret a VERA program directly. No compilation step — useful for development and testing.
vera run examples/fibonacci.vera
vera check
Parse and validate a VERA program without executing it. Reports syntax errors and type mismatches.
vera check examples/hello.vera
vera build
Compile to a native binary. Currently targets Darwin ARM64 (macOS Apple Silicon).
vera build examples/hello.vera -o hello
./hello
Set VERA_DEBUG_ASM=1 to preserve the generated assembly file for inspection:
VERA_DEBUG_ASM=1 vera build examples/hello.vera -o hello
# Assembly preserved at /tmp/vera_output.s
vera explain
Generate a natural English description of any VERA program, standard library module, or package:
vera explain examples/hello.vera # Explain a source file
vera explain vera:math # Explain a stdlib module
vera explain pkg:data/json # Explain a package
Example output:
VERA Explain — hello.vera
Dependencies:
- vera:io
Data:
greeting: string "Hello, World!\n" (14 bytes)
Function main() -> i32:
1. Set `message` to `greeting` (ptr).
2. Set `length` to 14 (i64).
3. Call `write_stdout`(`message`, `length`), storing the result in `bytes_written`.
4. Set `exit_code` to 0 (i32).
5. Return `exit_code`.
Examples
The examples/ directory contains working programs demonstrating the standard library and packages:
| Example | Description |
|---|---|
hello.vera | Hello World |
fibonacci.vera | Fibonacci sequence |
file_io.vera | File operations |
strings.vera | String functions |
math.vera | Math functions |
heap.vera | Heap allocation |
mutex.vera | Mutexes and threads |
tcp_echo_server.vera | TCP echo server |
tcp_client.vera | TCP client |
http_get.vera | HTTP GET request |
http_server.vera | HTTP server with routing |
http_e2e_test.vera | HTTP end-to-end test |
json_test.vera | JSON parse/serialize tests |
dns_test.vera | DNS resolution tests |
postgres_test.vera | PostgreSQL integration tests |
env_test.vera | Environment variable tests |