Skip to content
doraem-onPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Ascavim

Ascavim is a small programming language built around one idea: ordinary functions should be able to run locally or be dispatched to a remote worker without the programmer writing any RPC glue.

fn add(a: i32, b: i32) -> i32 {
    return a + b;
}

remote fn analyze(value: i32) -> i32 {
    return value * value;
}

fn main() {
    let result = add(10, 20);
    print(result);

    let squared = remote analyze(result);
    print(squared);
}

The remote keyword marks a function as eligible for out-of-process execution — and that's not a simulation: ascavim run --remote ships the call over gRPC to a separate ascavim-worker process, which as of v0.4 can be a pod running on an actual Kubernetes cluster.

Status: v0.4

Stage Status
Lexer / Parser / AST done
Semantic analysis (undefined vars, call arity) done
Tree-walking interpreter done
Ascavim IR + WASM codegen done (numeric/boolean subset - see below)
WASM execution via wasmtime done
gRPC worker + real remote execution done
Kubernetes deployment (control plane) done (see below)
Kubernetes operator / CRDs not started (v0.5)
  • ascavim build compiles a program to a real .wasm module; ascavim run <file>.wasm executes it with wasmtime.
  • ascavim-worker is a standalone gRPC server that registers a compiled WASM module and executes named functions in it on request (proto/ascavim.proto) - it also ships as a Docker image (worker/Dockerfile).
  • ascavim run <file>.asc --remote <addr> runs a program with the interpreter, but every remote fn call is dispatched over gRPC to the worker at <addr> instead of running in-process — a real cross-process call, not a local fallback. <addr> works the same whether the worker is a local process or a Kubernetes pod reached via port-forward.
  • control-plane/ is a small Go program using client-go that deploys ascavim-worker as a real Kubernetes Deployment + Service and reports on its status - not a script wrapping kubectl, an actual Kubernetes API client.

The WASM backend (and therefore anything sent to a worker) currently covers i32/bool, functions, recursion, if/while, and print — arrays, strings and for loops aren't lowered to WASM yet (they still work fine in main under the interpreter, just not inside a remote fn). See docs/ROADMAP.md for why, and the note in docs/ARCHITECTURE.md on why this uses wasm-encoder rather than Cranelift for WASM output.

See docs/ROADMAP.md for the full plan and docs/ARCHITECTURE.md for how the pieces fit together.

Quick start

Requires a recent Rust toolchain.

cargo build --workspace

# run a program with the interpreter
cargo run --bin ascavim -- run examples/hello.asc

# compile to WASM and run it with wasmtime
cargo run --bin ascavim -- build examples/hello.asc -o hello.wasm
cargo run --bin ascavim -- run hello.wasm

# parse + semantic-check only, no execution
cargo run --bin ascavim -- check examples/hello.asc

cargo test --workspace

Try the other examples in examples/:

  • hello.asc — functions, arithmetic
  • fib.asc — recursion, while loops
  • loops.asc — arrays, for .. in loops
  • remote_demo.asc — the remote keyword; see below for actually running it remotely

Running a program with a real remote worker

# terminal 1: start a worker
cargo run --bin ascavim-worker -- 127.0.0.1:50051

# terminal 2: run the program, dispatching `remote fn` calls to it
cargo run --bin ascavim -- run examples/remote_demo.asc --remote http://127.0.0.1:50051

main's loop and array handling run in the interpreter as usual; each remote analyze(item) call is compiled to WASM, registered with the worker, and executed there over gRPC - a different OS process computes the result and sends it back.

Running the same thing on a real Kubernetes cluster

Requires Docker, kind, kubectl, and Go.

# build the worker image and load it into a local kind cluster
docker build -f worker/Dockerfile -t ascavim-worker:dev .
kind create cluster --name ascavim
kind load docker-image ascavim-worker:dev --name ascavim

# deploy it as a real Deployment + Service via client-go
cd control-plane && go run . deploy && cd ..
# -> deployment/ascavim-worker applied, waits for the pod to be Ready

# reach the pod from your machine (stands in for a proper gRPC ingress -
# see docs/ROADMAP.md, Milestone 4)
kubectl port-forward svc/ascavim-worker 50051:50051 &

# same client, same command, now talking to a pod instead of a local process
cargo run --bin ascavim -- run examples/remote_demo.asc --remote http://127.0.0.1:50051

# see it happen from the cluster's side, independent of the client
kubectl logs deploy/ascavim-worker

cd control-plane && go run . status   # or: teardown

Language (v0.1)

A deliberately tiny language: i32, bool, string, arrays; let, assignment, if/else, while, for .. in; functions with typed parameters and return types; remote fn for distribution. No generics, traits, structs, or async yet — those come later, once the core pipeline (parse → IR → WASM → schedule) is proven end to end.

Why this design

The project is split by what each language is actually good at:

  • Rust — the compiler and execution engine (compiler/, runtime/, worker/). Memory safety and mature WASM tooling matter here.
  • Go — the distributed control plane (control-plane/, and later operator/). This is where Kubernetes client libraries, controllers, and gRPC services are strongest.

remote fn is the feature the whole project is organized around, not a bolted-on extra: the compiler pipeline, the IR, and the runtime's executor/scheduler split all exist to make "call this function, maybe somewhere else" a first-class, statically-known part of the language.

Repository layout

compiler/     lexer, parser, AST, semantic checks, IR, WASM codegen, interpreter (Rust)
runtime/      WASM executor (wasmtime) + gRPC client + generated proto types (Rust)
worker/       gRPC server + Dockerfile: registers/executes WASM modules on request (Rust)
proto/        the AscavimRuntime gRPC service definition
control-plane/ deploys ascavim-worker to Kubernetes via client-go (Go)
cli/          ascavim command-line tool (Rust)
examples/     sample .asc programs
docs/         architecture and roadmap
operator/     Kubernetes operator / CRDs (v0.5, not yet implemented)

operator/ contains only a short README describing its intended purpose — see docs/ROADMAP.md for why it's sequenced after control-plane/.

License

MIT — see LICENSE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages