A modern programming language built with Rust. Fast, safe, expressive, and easy to read. Documentation · Website · Releases · Issues Why Raven Reads like Python with braces: classes, tuples, comprehensions, x in xs, f-string formatting, len/sorted/enumerate and the other builtins, named and default arguments, x => x 2 lambdas, inferred types. Runs at native speed: compiled through Cranelift into…
Raven is a new systems and application programming language designed to combine the performance and control of C++, the safety and modern features of Rust, the readability of Python, the structure of Java, and the simplicity of Go.
Reads like Python with braces: classes, tuples, comprehensions, x in xs, f-string formatting, len/sorted/enumerate and the other builtins, named and default arguments, x => x * 2 lambdas, inferred types.
Runs at native speed: compiled through Cranelift into a single static binary. On the benchmarks below it is ahead of Go on seven of nine and within 9% on the other two, faster than C on dictionaries and strings, within 7% of C on recursion, mandelbrot, and the sieve, and ahead of C, Go, and Rust on allocation-heavy code.
Compiles fast: a small program builds in about 0.25 seconds, and a 10,000-line program in about 0.75 seconds, roughly four times faster than go build on the same program.
Static typing with generics, traits, and sum types checked by an exhaustive match.
A tracing garbage collector and Result/Option instead of null.
Goroutines and channels that run in parallel across CPU cores (an M:N scheduler over a multi-threaded collector), with mutexes, wait groups, and select, and a C FFI for native libraries.
A package manager (rvpm), one canonical formatter, and a VS Code extension.
Quick Example
class User {
name: str
age: int
}
fun main() {
let users = [User("ada", 36), User("alan", 41), User("grace", 85)]
let names = [u.name for u in users if u.age > 40]
let ages = {u.name: u.age for u in users}
for (i, name) in enumerate(sorted(names)) {
print("${i + 1}. ${name:<6} ${ages[name]:>3}")
}
}
Performance
Best runs in milliseconds on Windows x86_64 (benchmarks/runtime, run with
benchmarks/runtime/run.sh). Times are for the whole process, so each
includes process startup: a program that only prints one line takes about
58 ms in both C and Raven on this machine.
Benchmark
Raven
C (clang -O2)
Go
Rust (-O)
fib(35), recursion
90
84
115
83
1M dict inserts and lookups
117
131
284
190
20M sieve
292
280
317
272
200k string build
74
79
98
84
binary trees, allocation
207
395
265
442
mandelbrot 1600x1600, float loop
280
272
283
268
spectral norm, n = 2000
324
247
317
266
fannkuch(10), list permutations
291
252
268
227
n-body, float math
453
340
463
279
Compile time for the same programs is about 250 ms with Raven. The
benchmarks/compile-time corpus (10,000 lines across 62 modules) builds in
about 0.77 s with Raven against 3.3 s for go build.
Install
Download the installer or archive for your platform from the releases page:
Linux: .deb, .rpm, or .tar.gz
Windows: .msi or .zip
This installs the raven compiler and the rvpm package manager and adds them to your PATH. Compiling a program also needs a C linker on your machine (the MSVC build tools on Windows, cc/clang on Linux).
A Docker image with the toolchain and a C linker is published for every release, as ghcr.io/martian56/raven:<version> and :latest. Build in it and copy the binary into a small runtime image:
FROM ghcr.io/martian56/raven:3.3 AS build
COPY . /app
RUN rvpm build
FROM debian:bookworm-slim
COPY --from=build /app/target/raven-out/myapp /usr/local/bin/myapp
CMD ["myapp"]
# Compile a source file to a native binary
raven build hello.rv -o hello
./hello
Project workflow with rvpm:
rvpm new my_app
cd my_app
rvpm run # builds and runs src/main.rv
rvpm fmt # format the .rv sources
rvpm test # run test_* functions in *_test.rv files
rvpm dist # package the application for distribution
rvpm also supports multi-package workspaces, explicit package selection, and
manifest-defined compiled commands. See the rvpm guide.
Build from source
For contributors, or to track the latest commit:
git clone https://github.com/martian56/raven.git
cd raven
cargo build --release
The raven and rvpm binaries land in target/release/.
评论