Skip to main content

Prerequisites

Walrus is built in Rust and requires the Rust toolchain to build from source.
1

Install Rust

If you don’t have Rust installed, download and install it from rust-lang.org:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
After installation, restart your terminal and verify the installation:
rustc --version
cargo --version
Walrus requires the latest stable version of Rust. Run rustup update to ensure you’re up to date.
2

Clone the repository

Clone the Walrus repository from GitHub:
git clone https://github.com/sb2bg/walrus.git
cd walrus
3

Build Walrus

Build Walrus in release mode for optimal performance:
cargo build --release
This will create the walrus binary at target/release/walrus.
The first build may take a few minutes as Cargo downloads and compiles dependencies.
4

Verify installation

Test that Walrus is working correctly:
cargo run -- --help
You should see the Walrus command-line help information.

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 the jit feature flag:
cargo build --release --features jit

Performance impact

The JIT compiler can provide significant speedups for computational workloads:
BenchmarkInterpreterJITSpeedup
10K iterations × sum(0..1000)0.68s0.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:
During development, you can run Walrus directly with cargo run:
# Execute a file
cargo run -- program.walrus

# Start REPL
cargo run

# Compile mode (explicit VM execution)
cargo run -- -c program.walrus

# Disassemble bytecode
cargo run -- -d program.walrus

Command-line options

Walrus supports several command-line flags:
OptionDescription
<file>Execute a Walrus source file
-c, --compileUse bytecode compilation mode (VM execution)
-d, --disassembleDisassemble and display bytecode
--jitEnable JIT compilation (requires jit feature)
--jit-statsShow JIT profiling statistics
--no-jit-profileDisable JIT profiling (baseline comparison)
--helpDisplay help information

VS Code integration

Walrus includes a Language Server Protocol (LSP) implementation and VS Code extension for enhanced development experience.
1

Build the language server

cargo build --release --bin walrus-lsp
2

Install extension dependencies

cd vscode/walrus
npm install
3

Launch extension development host

Open vscode/walrus in VS Code and press F5 to launch the Extension Development Host.
4

Open a Walrus file

Open any .walrus file to get:
  • Parse diagnostics
  • Hover information for symbols, keywords, and builtins
  • Scoped completion
  • Signature help
  • Document symbols
  • Go-to-definition
  • Find references
  • Rename symbol
  • Document highlights
  • Syntax highlighting
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:
./scripts/build-linux-optimized.sh

Development tools

Running tests

Walrus includes a comprehensive test suite:
./scripts/run-tests.sh

Benchmarks

Compare Walrus performance against Python:
cd benchmarks
./run_benchmarks.sh

Profiling

Use dhat for memory profiling:
./scripts/dhat.sh

Troubleshooting

Ensure you have the necessary system development tools installed:Ubuntu/Debian:
sudo apt-get install build-essential
macOS:
xcode-select --install
Update Rust to the latest stable version:
rustup update stable
Make sure you built with the jit feature:
cargo build --release --features jit
The JIT feature requires Cranelift dependencies which are only compiled when explicitly enabled.

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

Build docs developers (and LLMs) love