Skip to content

Latest commit

 

History

History
82 lines (54 loc) · 2.41 KB

readme.md

File metadata and controls

82 lines (54 loc) · 2.41 KB

Zephyr

A language built for WebAssembly

You are early to the party 🎉 Zephyr is still a work in progress, feel free to try it out though!

Zephyr is a language that compiles to WebAssembly, its main goal is to showcase the concept of runtime interfaces as a language feature to allow the exact same code to run on a wide variety of WebAssembly runtimes, or even to behave differently on the same runtime by choosing the underlying implementation of runtime interfaces.

For instance what should print do when compiling to WebAssembly? It depends. When working on a CLI it should write to stdout, on the web to the console, on an arduino to an LCD screen or maybe send the logs back over the wire.

Zephyr will eventually define a standard Printer runtime interface and let you choose or write the implementation that works for you, this way you can choose how your code behave without waiting for someone to extend the compiler to support your use case.

Status

feature
Type inference ✔️
Package system ✔️
Runtime packages ✔️
Runtime interfaces
Memory allocator ✔️
Automatic memory management
Structs 🚧
Tuples (product types)
Sum types

Trying Zephyr

Zephyr is still a work in progress and currently lacks some major features, but still you can try it out.

First clone this repository:

git clone git@github.com:CharlyCst/zephyr.git
cd zephyr 

Some programs may need the Zephyr standard library, you must set the ZEPHYR_LIB environment variable to the location of the lib folder for them to compile properly:

export ZEPHYR_LIB=`pwd`/lib

If you plan on using Zephyr on a regular basis, add this export to your .bashrc (or equivalent).

Then write a Zephyr program:

standalone package hello

use std.r.wasi

expose hello as _start

fun hello() {
    wasi.print("Hello, world!\n")
}

Compile it

cargo run -- hello.zph

And run it with your favorite WASM runtime, for instance Wastime

wasmtime hello.zph.wasm
Hello, world!