Cosmopolitan 3.0: Write Once, Run Anywhere (and Faster!)

2025-02-01
Cosmopolitan 3.0: Write Once, Run Anywhere (and Faster!)

Cosmopolitan library version 3.0 is here! Nearly a year in the making, this release is a game-changer. A single executable now runs on AMD64 and ARM64 architectures across Linux, macOS, Windows, FreeBSD, OpenBSD, and NetBSD. This is powered by a new linker, apelink.c, cleverly weaving together PE, ELF, Mach-O, and PKZIP file formats. Cosmopolitan 3.0 also boasts massive improvements to Windows and macOS compatibility, plus significant speed and memory efficiency gains. Included is a "fat Linux distro," Cosmos, containing tools like Emacs, Vim, and CoreUtils. This innovative approach delivers not just unparalleled portability, but superior performance as well.

Read more
Development executable

Lambda Calculus Interpreter in 383 Bytes

2025-01-15
Lambda Calculus Interpreter in 383 Bytes

This blog post introduces a brand new 383-byte implementation of a binary lambda calculus interpreter as an x86-64 Linux ELF executable. This tiny interpreter manages to achieve garbage collection, lazy lists, and tail recursion. Programs are encoded in a remarkably small binary format; for example, its metacircular evaluator is only 232 bits. The author provides friendly portable C code and pre-built binaries for other platforms. This project is a fun learning tool for lambda calculus and showcases the possibility of implementing complex computation in extremely resource-constrained environments.

Read more
Development Lambda Calculus

Extreme Minimization: Crafting a Cross-Platform Executable Under 400 Bytes

2025-01-07

This blog post details size optimization tricks from the Cosmopolitan Libc project, using x86 assembly and clever compilation techniques to drastically reduce executable size. Key methods discussed include run-length encoding, decentralized sections, dead code elimination, δzd encoding, overlapping functions, and optimizing printf. The ultimate result? A sub-400-byte ELF executable running on Linux, FreeBSD, NetBSD, and OpenBSD. This demonstrates efficient resource usage and offers new perspectives on the scalability of large codebases.

Read more