get started

Install W, write a program, run it. Then make a game.

install

brew install moneyrudh/w/wlang

That brings in raylib too, for games. Check it worked:

wlang --version

from source

You need a C compiler, make and flex (on a Mac, the Xcode command line tools have all three).

git clone https://github.com/moneyrudh/w-lang
cd w-lang
make
make install          # /usr/local/bin/wlang; PREFIX=... to change

hello

Save this as hello.w:

fun greet(name: str): str
    ret "hello, " + name

fun w(): num
    log(greet("world"))
    ret 0
$ wlang run hello.w
hello, world

w() is where a program starts; what it returns is the exit code.

commandwhat it does
wlang run hello.wbuilds and runs it (wlang hello.w too)
wlang build hello.wwrites the program ./hello
wlang build hello.w --emit-c... and keeps the C next to it, hello.c
wlang check hello.wonly the errors, nothing built

a game

The standard library has raylib: a window, drawing, keys and time.

use raylib

fun w()
    raylib.open(800, 450, "hello")
    dec x := 0.0
    loop while raylib.is_open()
        x = x + 200 * raylib.frame_time()
        say x > 800, x = 0
        raylib.begin_frame()
        raylib.clear(raylib.black)
        raylib.rect(x, 200, 40, 40, raylib.yellow)
        raylib.text("hello from w", 20, 20, 30, raylib.white)
        raylib.end_frame()
    raylib.close()

Then the real thing: Pong, in examples/games/ of the repo.

wlang run examples/games/pong.w

your editor

VS Code: the W extension colours W, shows errors as you type, and answers hover and go to definition (into modules too). Get wlang-<version>.vsix from the latest release, then:

code --install-extension wlang-0.3.0.vsix

Other editors with a language server client (Neovim, Helix, Zed, ...): start wlang lsp for .w files. It comes with wlang.

-- Neovim (0.11+)
vim.lsp.config("wlang", { cmd = { "wlang", "lsp" }, filetypes = { "w" } })
vim.filetype.add({ extension = { w = "w" } })
vim.lsp.enable("wlang")

next

The tour covers the whole language in one page; the reference has every rule and what's still to come.