sloppy: a simple game dev language

A small, statically typed language that feels like Python and runs like C. One command compiles and runs your program in milliseconds, as a native Linux or Windows executable or as a single web page.

curl -fsSL https://sloppy-lang.org/install | bash

In a terminal, on x86-64 or arm64. Installs to ~/.sloppy; the command works at once.

curl -fsSL https://sloppy-lang.org/install | bash

In Terminal, on a Mac with Apple Silicon (M1 or later). Installs to ~/.sloppy; no Xcode needed.

irm https://sloppy-lang.org/install.ps1 | iex

In PowerShell, on Windows 10 or 11 (x64). Installs to %LOCALAPPDATA%\sloppy; the command works at once.

On a phone or tablet? Sloppy installs on a computer; here, try it in the browser.

pos = vec2(400, 300)

update = (dt: f64):
    pos += input_axis() * 300 * dt

draw = ():
    clear(rgb(0.08, 0.08, 0.12))
    circle(pos, 24, rgb(1.0, 0.6, 0.2))
    text("arrow keys", vec2(20, 20), 24, WHITE)

A whole program: a window, and a ball the arrow keys move. Run it in the playground

Made with Sloppy

Rebound: a shield arcs around a glowing core; a chain of blasts runs through a line of turrets

Rebound

An arcade game. Turn the shield to catch the turrets' bolts and send them back: blasts set off the turrets beside them, catches near the shield's edge bank off to other turrets, and every few turrets you choose an upgrade. Menus, settings, a saved best score, and sound made by the built-in synthesizer.

Breakwater: robots advance across a platform at sea; a shielded warden is in the shotgun's sights

Breakwater

A first-person shooter: hold a platform at sea against waves of robots. A shield that recharges, two weapons at a time from racks and fallen robots, grenades and melee. Animated glTF models (robots and weapons by Quaternius), shadows, bloom and synthesized sound; mouse, keyboard alone, or a gamepad.

More examples and templates, to play and change

Why Sloppy

Instant compiles

About 250,000 lines a second. Hello world compiles and runs in about 10 ms; there is no build system, options live in the source.

Fast programs

Release builds run within about 1.5× of gcc -O2, with bounds checks on. parallel_map uses every core; GPU arrays run on the GPU.

Easy

Type inference everywhere, indentation syntax, closures, partial application, generics without ceremony, unions, value semantics with no garbage collector.

Made for games

Windows, input, 2D drawing, a 3D renderer with shadows and bloom, shaders written in Sloppy, audio, pixel art and any screen shape, all built in.

Runs anywhere it lands

Native programs are static executables with no dependencies; web builds are one HTML file. Graphics drivers are optional: there is a software renderer.

Self-hosted

The compiler is written in Sloppy and compiles itself, even in this site's playground, where it runs as WebAssembly.

What the code looks like

Structs, changed in place

Values are copied, never shared; loop mut changes the elements themselves.

struct Ball:
    pos: vec2
    vel: vec2
    bounces = 0

balls = [Ball(vec2(0, 90), vec2(80, 40))]
balls.push(Ball(vec2(0, 20), vec2(60, 10)))
loop mut b in balls:
    b.pos += b.vel * 0.5
    if b.pos.y > 100:
        b.vel.y = -b.vel.y
        b.bounces += 1
print(balls)

Run it in the playground

Errors are values

A function returns its result or what went wrong; after the check, n is an int.

struct BadLine:
    line: int
    text: str

total = (text: str) -> int | BadLine:
    sum = 0
    loop i in 1.. and l in lines(text):
        n = to_int(l)
        if n is none: return BadLine(i, l)
        sum += n
    sum

print(total("4\n5\n6"))
print(total("4\nfive\n6"))

Run it in the playground

Saving a game

Any value is kept as text and read back by field name, so old saves still load after new fields.

struct Progress:
    level = 1
    coins = 0
    unlocked: str[]

# (the defaults the first time)
p = load_value("progress", Progress())
p.coins += 25
p.unlocked.push("double jump")
save_value("progress", p)
print(p)

Run it in the playground

Editors: sloppy lsp is a language server (and there is a VS Code / Cursor extension). An interactive prompt: run sloppy with no file.