Projects11 of 15
Officina
A notebook that compiles and runs Python, C, C++ and Java in the browser
What it is
A notebook that runs in the browser and nowhere else. Code and prose cells in Python, C, C++, Java or assembly, with a library of worked examples for each.
Nothing is uploaded anywhere:
- cells live in the browser’s own storage;
- a file is read by the page, not sent;
- a notebook downloads as .ipynb or as source.
Python, with the network removed
Python is CPython 3.14 compiled to WebAssembly (Pyodide), run in a Web Worker from which fetch, XMLHttpRequest, WebSocket and the rest have been deleted. A pasted cell cannot make a request with the site’s cookies.
- A cell that never ends is stopped by the reader, or by a 30-second limit.
- Output stops at 256 KB.
- A second interpreter waits ready, so a stop is recovered from at once.
C and C++, really compiled
C and C++ are not interpreted. clang and wasm-ld, themselves compiled to WebAssembly and served from this site, compile the cell, and the module they produce is run. An error is clang’s own, to the line and column.
Java and assembly
- Java is compiled by the Eclipse compiler and run on CheerpJ’s JVM. It is the one thing on the site loaded from another origin, because its licence allows nothing else.
- Assembly is written and exported rather than run, with the command to build it. The browser is not the processor it was written for, and the page says so rather than offering a button that fails.
Loaded only when asked
Nothing is fetched until a reader asks to run something: Python is 13 MB, and the C toolchain far more. The examples are edited from the site’s CMS, like everything else on it.
Built with
Pyodide, clang and wasm-ld compiled to WebAssembly, and the Eclipse compiler on CheerpJ. No server.