PewPew the language
A programming language built from scratch in C++. Meme-flavored syntax, four swappable vocabularies, a pixel game engine and an Academy, all running in the browser.
One engine, four vocabularies, identical output.
Including the game engine and an HTTP server.
Hands-on, with auto-checked challenges.
Shooter, lander, pong, snake and star catcher.
One engine, four vocabularies
A skin swaps the words, not the language. The same program below is written in each skin and prints identical output, and even the error messages change tone. Pick a skin and press Run.
do add(whole a, whole b) { gimme a + b } yell("starting up") whole total = add(2, 3) check (total == 5) { yell("total is correct: " + total) } nah { yell("something is wrong") } repeat 3 times { yell("pew") }
Press Run. C:\PEWPEW> _
| means | pewpew | professional | piratelang | bismillahlang |
|---|---|---|---|---|
| yell | holler | azaan | ||
| if | check | if | arr | inshallah |
| else | nah | else | vast | illa |
| function | do | func | quest | bismillah |
| return | gimme | return | plunder | ameen |
| integer | whole | int | doubloon | adad |
Games written in PewPew
The language ships a small pixel game engine. Star Catcher is one of five example games, and this is a playable browser replica of it. The real one is a 72 line PewPew file.
Arrow keys, A / D, or move the pointer. Miss three and it is over.
bring "game"
whole W = 160
whole H = 120
game->canvas(W, H)
game->title("Star Catcher")
dotted px = 70
whole pw = 24
whole score = 0
whole lives = 3
loop (game->playing() && lives > 0) {
check (game->key("left") || game->key("a")) { px = px - 3 }
check (game->key("right") || game->key("d")) { px = px + 3 }
check (game->mousex() > 0) { px = game->mousex() - pw / 2 }
// ... move the stars, score, lose lives ...
game->clear("navy")
game->box(px, H - 5, pw, 3, "green")
game->text(3, 3, "SCORE " + score, "white")
game->show()
game->wait(20)
}The other four are a shooter, a lander, pong and snake. Source lines are copied from the real file.
How a class assignment got out of hand
How it started
It began in a Compiler Design class in semester 6. I learned how code turns into machine instructions and decided I should build a real compiler.
A few days into assembly manuals and memory allocation, I found out how hard that is. There are so many phases. I dropped the idea.
An interpreter sounded doable. I treated it as a weekend joke project to flex some C++. I wired up Flex and Bison, wrote a tree-walking evaluator, and made the syntax as goofy as I could. yell prints. check and nah are if and else.
The hardest part was the start
The first version was the hardest thing in the whole project. A language only works once the lexer, the parser and the interpreter all work together, so for a long time there is nothing to show.
Then it got out of hand
I got attached.
I started treating the codebase like my own kid. What began as a joke grew a standard library, a game engine, four skins, a browser version running on WebAssembly, and an Academy with courses. People now run yell("Hello") in a browser, and I still enjoy tuning the pipeline that makes that work.
What I am proud of
I made something that did not exist before: a language with a personality, built by one person. I want to make more things like it.