A modern transpiler for the Rosy scientific programming language, designed for beam physics and differential algebra applications.
Rosy transpiles source code into self-contained, native Rust executables — optimized native code with zero runtime dependencies.
The complete Rosy language reference — every operator, function, statement, and type — is in the Rustdoc documentation.
BEGIN;
VARIABLE (RE) x;
VARIABLE (RE) y;
x := 3;
y := SIN(x) + 1;
WRITE 6 'y = ' ST(y);
END;
$ rosy run example.rosy
y = 1.141120008059867E-001
Requires the Rust nightly toolchain (needed for --optimized SIMD support):
# Install Rust (if you don't have it)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Switch to nightly (required for --optimized builds)
rustup default nightly
# Build and install Rosy
git clone https://github.com/hiibolt/rosy.git
cd rosy
cargo install --path rosyTo update:
cd rosy
git pull
rustup update nightly
cargo install --path rosyIf you previously installed Rosy with Rust stable, switch to nightly for --optimized support:
rustup default nightly
cd rosy && git pull
cargo install --path rosy --force# First-time setup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
rustup default nightly
git clone https://github.com/hiibolt/rosy.git
cd rosy && cargo install --path rosy
# For MPI programs (PLOOP)
module load openmpi/openmpi-5.0.7-gcc-14.2.0-cuda-12.8
# Run a program
rosy run examples/basic.rosy
rosy build examples/basic.rosy --optimized -o my_programTo update:
cd ~/rosy && git pull
rustup update nightly
cargo install --path rosy --forcePrebuilt binaries for Linux (x86_64) and macOS (x86_64, aarch64) are available on the Releases page.
nix develop # Enters a shell with nightly Rust + all dependenciesrosy run examples/basic.rosy # run directly
rosy build examples/basic.rosy -o out # build a binary
rosy build examples/basic.rosy --release # release build
rosy build examples/basic.rosy --optimized # max performance (recommended)Use --optimized for any real computation. It produces significantly faster binaries at the cost of longer compile times.
| Flag | Compile time | Runtime | Use case |
|---|---|---|---|
| (none) | ~1s | Slowest | Syntax checking, debugging |
--release |
~2s | Fast | Quick iteration during development |
--optimized |
~5s | Fastest | Production runs, benchmarks, beam physics |
--optimized enables:
- LTO (link-time optimization) — whole-program optimization across all crate boundaries
- Single codegen unit — allows inlining of DA hot paths across
taylor/andintrinsics/modules - SIMD DA operations —
portable_simdacceleration for differential algebra (requires nightly Rust) panic = abort— eliminates unwinding overhead
Recommendation: Always use
--optimizedfor actual physics runs. The extra ~3s of compile time is negligible compared to the runtime savings on any non-trivial computation. Reserve--releasefor rapid edit-run cycles during development.
Programs using PLOOP require an MPI implementation and LLVM/Clang at compile time (the transpiler itself does not):
- Ubuntu/Debian:
sudo apt install libopenmpi-dev openmpi-bin libclang-dev - Fedora:
sudo dnf install openmpi-devel clang-devel - macOS:
brew install open-mpi llvm - NIU Metis:
module load openmpi/openmpi-5.0.7-gcc-14.2.0-cuda-12.8
For setup instructions, run either:
rosy setup zedrosy setup vscode
See repository for license details.