Crates.io | zubbers |
lib.rs | zubbers |
version | 0.0.1 |
source | src |
created_at | 2023-01-12 18:39:30.81585 |
updated_at | 2023-01-12 18:39:30.81585 |
description | A fast, stack-based virtual machine for dynamic languages, with an intuitive IR-builder, garbage collection and NaN-tagging. |
homepage | https://github.com/sawcce/zubbers |
repository | https://github.com/sawcce/zubbers |
max_upload_size | |
id | 757401 |
size | 142,672 |
A super-fast, stack-based virtual machine for dynamic languages
This library has recently been forked and is being reworked on to add new features, don't expect a lot of stuff to be stable.
Getting your backend up and running shouldn't have to be hard.
The following code builds IR for evaluating sum = 20.0 + 30.0
:
let mut builder = IrBuilder::new();
let a = builder.number(20.0);
let b = builder.number(30.0);
let sum = builder.binary(a, BinaryOp::Add, b);
builder.bind(Binding::global("sum"), sum);
When you feel like the IR is looking smooth. Simply let VM throw it through the compiler, and run it.
let mut vm = VM::new();
vm.exec(&builder.build());
Hugorm is a dynamic, python-like language being built for small data science and game projects.
https://github.com/nilq/hugorm
The examples/
folder includes two small language implementations running on the ZubVM.
Atto is a functional, minimal language that showcases how little code is needed to implement a working, Turing-complete language. The syntax can be seen in the following teaser:
fn sum x is
if = x 0
1
+ sum - x 1 sum - x 1
fn main is
sum 12
Mini is a simple language that looks basically like a mix of Rust and JavaScript. It covers a bit wider set of features than Atto. This does show in the size of the language though.
let bar = 13.37;
fn foo() {
fn baz(c) {
return c + bar;
}
return baz(10);
}
global gangster = foo();