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:

ExampleDescription
hello.veraHello World
fibonacci.veraFibonacci sequence
file_io.veraFile operations
strings.veraString functions
math.veraMath functions
heap.veraHeap allocation
mutex.veraMutexes and threads
tcp_echo_server.veraTCP echo server
tcp_client.veraTCP client
http_get.veraHTTP GET request
http_server.veraHTTP server with routing
http_e2e_test.veraHTTP end-to-end test
json_test.veraJSON parse/serialize tests
dns_test.veraDNS resolution tests
postgres_test.veraPostgreSQL integration tests
env_test.veraEnvironment variable tests