Prerequisites
Walrus is built in Rust and requires the Rust toolchain to build from source.Install Rust
If you don’t have Rust installed, download and install it from rust-lang.org:After installation, restart your terminal and verify the installation:
Walrus requires the latest stable version of Rust. Run
rustup update to ensure you’re up to date.Build Walrus
Build Walrus in release mode for optimal performance:This will create the
walrus binary at target/release/walrus.Optional: JIT compilation support
Walrus includes an optional Just-In-Time (JIT) compiler powered by Cranelift that can dramatically speed up hot loops by compiling them to native machine code.Building with JIT enabled
To build Walrus with JIT support, use thejit feature flag:
Performance impact
The JIT compiler can provide significant speedups for computational workloads:| Benchmark | Interpreter | JIT | Speedup |
|---|---|---|---|
| 10K iterations × sum(0..1000) | 0.68s | 0.01s | ~68x |
JIT compilation is most effective for hot integer range loops. See the JIT documentation for details on what code patterns can be JIT-compiled.
Running Walrus
Once built, you can run Walrus in several ways:- Using cargo run
- Direct execution
- Add to PATH
During development, you can run Walrus directly with
cargo run:Command-line options
Walrus supports several command-line flags:| Option | Description |
|---|---|
<file> | Execute a Walrus source file |
-c, --compile | Use bytecode compilation mode (VM execution) |
-d, --disassemble | Disassemble and display bytecode |
--jit | Enable JIT compilation (requires jit feature) |
--jit-stats | Show JIT profiling statistics |
--no-jit-profile | Disable JIT profiling (baseline comparison) |
--help | Display help information |
VS Code integration
Walrus includes a Language Server Protocol (LSP) implementation and VS Code extension for enhanced development experience.Launch extension development host
Open
vscode/walrus in VS Code and press F5 to launch the Extension Development Host.The VS Code extension is currently in development and requires running the Extension Development Host. Full marketplace publication is planned for a future release.
Platform-specific builds
The Walrus repository includes optimized build scripts for different platforms:Development tools
Running tests
Walrus includes a comprehensive test suite:Benchmarks
Compare Walrus performance against Python:Profiling
- Memory profiling
- CPU profiling (macOS)
Use dhat for memory profiling:
Troubleshooting
Build fails with linker errors
Build fails with linker errors
Ensure you have the necessary system development tools installed:Ubuntu/Debian:macOS:
Rust version too old
Rust version too old
Update Rust to the latest stable version:
JIT feature not available
JIT feature not available
Make sure you built with the The JIT feature requires Cranelift dependencies which are only compiled when explicitly enabled.
jit feature:Next steps
Now that you have Walrus installed, proceed to the quickstart guide to write your first program:Quickstart guide
Write your first Walrus program in minutes