Skip to content
Search

Cosmopolitan libc

lastmod 2026-01-16created 2020-12-314 edits

build-once run-anywhere c without devops

Features

  • A library that makes C code runnable anywhere
    • Similar to Java, but needs no interpreter or VM
    • Offers Go/Rust-level portability while using plain C
    • Compiling with the 5 provided library files gives Mac/Windows/Linux support as is
  • glibc-level speed
  • Creates and uses a format called ape (αcτµαlly pδrταblε εxεcµταblε)
    • Uses the fact that a Windows Portable Executable can be made into a UNIX 6th Edition shell script
    • Portable, yet 100x smaller than the Go version of Hello World
  • Has a built-in BIOS bootloader, so it can also boot and run on bare metal

Additional comments

  • The well-known hacker Justine Tunney released the APE (αcτµαlly pδrταblε εxεcµταblε) format
  • APE is both a UNIX shell script and a Windows executable, so it runs anywhere: Mac/Win/Linux/BSD
  • Cosmopolitan is a LibC that, in this portable setting, makes C code runnable anywhere
  • With this APE and Cosmpolitan, the Redbean web server, which runs as a single file, was developed
  • Redbean is both an executable and a ZIP file, so it can embed all resources such as HTML/CSS/JS
  • Now, in Cosmopolitan 1.0, the Redbean web server can modify the contents of the Zip file that is itself
  • You can build Dynamic web pages whose content can be modified, yet it is still 1 file
  • Cosmopolitan libc - Build-Once Run-Anywhere C https://news.hada.io/topic?id=3489
  • Redbean - A web server that runs as 1 file https://news.hada.io/topic?id=3815

See also

Favorite site

Articles

author Zer0 sitemap