Clone me on GitHub

OCaml Elm Playground

Pictures, animations, games and applications in OCaml, in 2D and 3D

What's New · Play Online · The Code Map · The Library · Documentation · AI Disclaimer

The playground is a set of OCaml libraries for making video games, and other programs too. It started as a port of Evan Czaplicki's Elm playground package, and has since grown far beyond it into a whole game engine: 2D and 3D renderers, physics, sound synthesis, game AI and multiplayer networking, all written from scratch. It keeps the original's spirit:

This is the package I wanted when I was learning programming. Start by putting shapes on screen and work up to making games. I hope this package will be fun for a broad range of ages and backgrounds! — Evan Czaplicki

Built with that engine, the repository holds 145 games and 53 applications: the programs that made computing history, from Pong, Breakout and Pac-Man to Doom and Quake, from VisiCalc and MacPaint to Turbo Pascal and Smalltalk-80. Each one is rebuilt in miniature but working, with its story, and small enough to read whole: a few hundred lines to a few thousand. Each runs natively on your desktop and in your browser, from the same source file.

TinyBreakout TinyTurboPascal
Breakout (Atari, 1976): 525 lines, in one file. Turbo Pascal 7 (Borland, 1992): the editor, the compiler and the debugger, 3,213 lines.

What's New


Play Online


The Code Map

the code map: the whole repository, each folder a region, each file a block the size of its code

The code map shows the whole repository as a map: each folder a region, each file a block the size of its code, each block the code itself once you zoom in. h lists every key, and its manual says the rest. A link can open it on one program's own code, as the README's tables do:

It is tinybox's code visualizer, after the author's codemap, and runs on any directory: xix and IX have theirs.


The Library

The library is there to teach people. A graphics stack, a game engine, a codec library or a web browser is millions of lines, and nobody understands the whole of it. Here each subject is small enough for one person to read whole. Most of it is written by AI (AI disclaimer), which here, as in IX, rewrites giant programs in far less code, so that humans can understand them again, and extend them. Ultimately these libraries may become literate programs, as in Principia Softwarica: books that tell the code as a story, in the order a reader needs, to teach even better.

AI makes the programs smaller. Humans understand more.

Everything is written from scratch, one idea per module, each interface explaining its idea: the playground, graphics, physics, audio, AI, GUI, networking, cryptography and compression, the terminal, application engines, game kits, languages.


Documentation

The OCaml package documentation, generated by odoc. The most important package is elm_playground.

  1. elm_playground 0.3.0
  2. elm_playground_3d 0.3.0
  3. elm_playground_software 0.3.0
  4. elm_playground_3d_software 0.3.0
  5. elm_playground_gamekits 0.3.0 — the games' genre kits (platformers, racing, shoot 'em ups, fighting, ...), on the Playground
  6. tiny_libs 0.3.0 — the from-scratch libraries under the Playground (graphics, audio, compression, crypto, networking, ...), usable without it
  7. tiny_languages 0.3.0 — the languages, parsed and run (Scheme, Lisp, Smalltalk-80, Pascal, BASIC, JavaScript, HTML, CSS, ...), usable without it too
  8. tiny_appkits 0.3.0 — the applications' engines (a spreadsheet, rich text, paint, draw, CAD, the editors, a web page's layout, ...), usable without it too

And beyond the API:


AI disclaimer

The 2D playground API and the ideas behind it are the work of Evan Czaplicki, for Elm. I (Yoann Padioleau) ported the API and its ideas, and some of the web backend, to OCaml, and added a native backend: that is the playground up to version 0.1.7 (December 2024), with a few games (Pong, Snake, Tetris, Asteroid). Playground3d is adapted from Luca Mugnaini's elm-playground-3d.

Since September 2026, almost everything around that library is written by AI: by Claude, Anthropic's model, in Claude Code. The repository is now about 280,000 lines of OCaml, tests included: the games and apps, the other APIs (Physics, Audio, Ai, Gui, ...), the rasterizers, tinybox, the code map, and this website.

What I do is direct the work: I choose what to build, its design, which programs to rebuild and at what size, and I review the code. The originals, and their designs, are the work of their authors, named in each program's header and in the README's Trademarks and originals; the README's AI disclaimer says more.


The OCaml Elm Playground is by Yoann Padioleau, after Evan Czaplicki's Elm playground, mostly written by Claude (AI disclaimer), and a companion to xix, IX and Principia Softwarica.