// docs / Language
Language tour
A statically typed language that compiles to WasmGC. It is stricter than you are.
Values and types
vcwl
let name = "vibes" // immutable, type inferred
var total: Int = 0 // mutable local
let ratio: Float = 0.5
let tags: [String] = ["a", "b"] // immutable; push is amortized O(1)
let maybe: Int? = None // optionals
Structs, enums and matching
vcwl
struct Todo {
id: Int,
title: String,
done: Bool,
}
enum Shape {
Circle(Float),
Rect(Float, Float),
}
fn area(s: Shape) -> Float {
match s {
Circle(r) => 3.14159 * r * r
Rect(w, h) => w * h
}
}
Matches must be exhaustive; the compiler names the case you forgot. Generics are monomorphized, x? propagates Err and None, and string interpolation is "{x}".
The pipe operator
vcwl
let score = input
|> trim_all
|> parse_or(0)
|> clamp(0, 100)
x |> f(a) is f(x, a). That's it. That's the feature. We will be accepting our Turing Award by mail.
Modules and tests
vcwl
import "./model.vcwl"
import "@kit" // a package
fn test_area() {
assert(area(Rect(2.0, 3.0)) == 6.0, "math is broken")
}
vcwl test runs every test_* function in tests/. vcwl run file.vcwl runs a program's main in Node.js.