W_
a small language that compiles to C.

Its own keywords, blocks by indentation, memory handled for you, and fast C underneath. Write a game in an afternoon.

brew install moneyrudh/w/wlang

macOS and Linux with Homebrew; or build from source.

pod Ball
    name: str
    speed: real

fun bounce(b: ref Ball)
    b.speed = -b.speed * 1.05

fun w()
    dec ball := Ball(name: "pong", speed: 320)
    bounce(ref ball)
    log(ball.name, "goes", ball.speed)

    dec scores := [3, 5, 2]
    loop i, s in scores
        say s > 4, log("player", i, "leads with", s)
$ wlang run ball.w
pong goes -336.000000
player 1 leads with 5

pong, in w

Pong written in W: two paddles, a ball, the score

About 150 lines of W on raylib. wlang run examples/games/pong.w: W / S against the arrow keys, first to 5.

what's in it

compiles to C

One readable C file, built with your C compiler at -O2. --emit-c shows it.

memory, handled

Strings, pods and vecs are freed for you. Memory stays flat in a game loop.

pods and vecs

Plain data with named fields; growable arrays that copy on write, so passing them is cheap.

errors that help

Type errors that don't cascade, and runtime errors with a trace of the calls that led there.

modules

use lib.shapes, then shapes.area(c). A standard library ships with it.

calls C

ext fun sqrtf(x: real): real and ext lib "m". That's how raylib gets in.

its own words

say score > best
    log("new best")
elf score is best, log("tied")
else
    log("try again")
loop while lives > 0
    lives = lives - 1
    say lives is 1, skip
loop x in [1, 2, 3], total = total + x
loop forever, stop

say is if, elf is else if, lest is unless, dec declares, ret returns, log prints. Take the tour.