How Justine Tunney Built a Six‑OS C Web Server and Other Groundbreaking Projects

The article showcases Justine Tunney’s remarkable engineering feats—from the RedBean web server that runs the same binary on six operating systems, to the cosmopolitan libc, a 512‑byte sectorLisp, the Blinkenlights visual debugger, the RoseHub security effort, and the llamafile tool that packages large language models into a single portable executable.

dbaplus Community
dbaplus Community
dbaplus Community
How Justine Tunney Built a Six‑OS C Web Server and Other Groundbreaking Projects

RedBean Web Server

RedBean is a single‑binary web server written in C that runs unchanged on six operating systems (Linux, Windows, macOS, FreeBSD, OpenBSD, NetBSD). It achieves this by compiling to pure x86‑64 machine code and wrapping the code in the APE (Actually Portable Executable) container format, which abstracts the OS‑specific executable header.

Key steps to build and run RedBean:

Clone the repository: git clone https://github.com/jart/redbean Build with the bundled Makefile: make -j$(nproc). The build links against cosmopolitan libc, producing redbean.com (the .com extension is used for the APE file).

Run the binary directly on any supported OS: ./redbean.com -p 8080 -c /path/to/htdocs.

APE (Actually Portable Executable) format

APE is a minimal executable container that stores raw x86‑64 instructions followed by a small loader written in assembly. The loader detects the host OS at runtime, maps the code into memory, and forwards system calls to the appropriate kernel interface. Because the loader is only a few hundred bytes, the same file can be executed on Windows PE, Linux ELF, macOS Mach‑O, and BSD formats without modification.

cosmopolitan libc

cosmopolitan libc is a single‑file implementation of the C standard library that provides:

POSIX‑compatible I/O ( read, write, open, close)

Memory allocation ( malloc, free)

String and locale utilities

Network sockets ( socket, connect, bind, listen, accept)

Thread creation and synchronization ( pthread_create, pthread_join)

The library is written in portable C with a small amount of inline assembly for system‑call entry. It detects the host OS at runtime using the same APE loader, then dispatches to the appropriate syscall numbers for Linux, Windows, or BSD kernels. Because it is a single source file ( libc.c), it can be compiled together with an application, eliminating external dependencies.

sectorLisp

sectorLisp is a 512‑byte Lisp interpreter that boots directly from a PC’s BIOS. It demonstrates how to:

Initialize the 16‑bit real‑mode environment, switch to protected mode, and set up a minimal C runtime.

Parse a tiny S‑expression syntax and evaluate a handful of primitive forms (e.g., quote, car, cdr, cons).

Store the entire interpreter, including a read‑eval‑print loop, in a single 512‑byte sector image that can be written to a floppy or USB drive and launched by the BIOS.

Blinkenlights Debugger and x86 Emulator

Blinkenlights started as a command‑line visual debugger. It prints a textual representation of memory changes after each instruction, using colored characters to highlight modified bytes. The same codebase also functions as a compact x86 emulator:

It fetches, decodes, and executes a subset of x86 instructions (e.g., mov, add, jmp, call).

The emulator is written in roughly 2 000 lines of C, making the control flow easy to audit.

Debug output can be toggled with a command‑line flag, allowing developers to step through execution and observe register and memory state in real time.

RoseHub Open‑Source Security Initiative

In 2016 a deserialization vulnerability was discovered in the Apache Commons Collections library. Tunney launched the RoseHub project to coordinate remediation across the open‑source ecosystem. The workflow was:

Identify vulnerable versions of commons‑collections in public GitHub repositories.

Automate pull‑request generation that upgrades the dependency to a patched version.

Recruit volunteers (including 50 engineers from Google) to review and merge the patches.

The effort resulted in security fixes for roughly 2 600 repositories, demonstrating a scalable model for rapid open‑source vulnerability response.

llamafile – Portable Large Language Model Executables

llamafile packages a pre‑trained LLM (e.g., LLaMA) together with a minimal inference runtime into a single APE binary. Because the binary links against cosmopolitan libc, it runs on all six supported operating systems without installing Python, CUDA, or other dependencies.

Typical usage:

# Download the executable
curl -LO https://example.com/llamafile.com

# Make it executable
chmod +x llamafile.com

# Run inference (the model is embedded)
./llamafile.com --prompt "Explain quantum entanglement"

The approach simplifies deployment on edge devices and CI environments where installing large frameworks is impractical.

Console Video Playback

Using a custom MPEG‑2 decoder, Tunney demonstrated playback of video streams directly in a terminal. The pipeline is:

Decode MPEG frames into raw RGB pixels.

Map each pixel to an ANSI escape sequence that sets foreground/background color.

Render the colored characters at the terminal’s native resolution, achieving a low‑fidelity but recognizable video playback.

This technique showcases the expressive power of terminal graphics and can be used for diagnostics or artistic demos.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

cross‑platformLLMCWeb servercosmopolitan libcLisp
dbaplus Community
Written by

dbaplus Community

Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.