A bunch of almost unbelievably clever tech tricks come together into something practical with redbean 2: a webserver plus content in a single file that runs on any x86-64 operating system.
The project is the culmination – so far – of a series of remarkable, inspired hacks by programmer Justine Tunney: αcτµαlly pδrταblε εxεcµταblε, Cosmopolitan libc, and the original redbean. It may take a little time to explain what it does, so bear with us. We promise, you will be impressed.
To begin with, redbean uses a remarkable hack known as APE, which stands for Actually Portable Executable – which its author styles αcτµαlly pδrταblε εxεcµταblε. (If you know the Greek alphabet, this reads as "actmally pdrtable execmtable", but hey, it looks cool.)
The gist of the idea of APE is this: whatever programming language you use, if you compile your code to a native binary, it produces x86-64 machine code – and any x86-64 processor runs the same machine code. If you wrote a program that didn't call on any external code at all, then in principle, the only difference between a Windows binary and (say) a Linux binary is the format of the file that contains the binary. So if you could only get around that, your program would be able to run on any OS.
Linux uses a format called Executable and Linkable Format (ELF). In the old days, proprietary x86 Unixes used Common Object File Format or COFF. That's why the recent conversion of Lotus 1-2-3 for Unix to Linux used a tool called coffsyrup to convert COFF to ELF.
The joke in the name APE comes from the fact that Windows NT still uses a format derived from the old COFF standard, called Portable Executable (PE). The PE format is "portable" only inasmuch as if you run a Windows .EXE file under DOS, it will in fact execute: PE files contain a tiny DOS stub which displays the message "This program cannot be run in DOS mode." But "Portable Executables" aren't really portable at all – unlike, say, family applications, which ran natively under both DOS and OS/2.
APE files are, as the name says, Actually Portable Executables. A single APE file executes correctly on any x86-64 operating system. Take the file and run it on Windows, then it acts as a Windows executable. Run the same file on macOS, and it's a macOS executable. Run it on Linux, and it's a Linux binary… and the same on FreeBSD, and OpenBSD, and NetBSD, even though they all have their own, different, executable formats.
The snag is that almost any real program has to call out to some library, even if only the C standard library… which is where the Cosmopolitan libc comes in. "Cosmo" is a libc for APE, so that C programs can be compiled and run on any OS that APE supports.
With Cosmo and the APE format, you can write a C program and compile it to a single file that will load and run on six totally different operating systems. Oh, and if that wasn't enough, the same binary can be booted directly from the PC BIOS, as well. Which means you can run it under Tunney's Blinkenlights, and watch the PC's registers changing live, like an old-time mainframe.
At this point, many techies' minds may well be reeling in astonishment. So, to give you something pretty to look at, there are some demo programs, too. The demo video on the Blinkenlights page shows printimage.com, which can print JPG files on the text console. If you are still not impressed, printvideo.com does the same for video.
The original redbean made the combination of APE and Cosmo into something slightly more useful. After all, amazing as the combination is, having just a libc is quite limiting in the 21st century. You can't build any kind of graphical application, for instance. But every OS that APE supports can run a web browser, so redbean embedded a web server (and SQLite database, and Lua scripting) into a single binary file too. All you need to do is change the file extension to .ZIP, add in your static web content using an archive manager, save it, rename it again, and bingo: self-contained web app.
Think of it as being a little like an Electron app, except that instead of embedding the entire browser into your innocent little program, you use your existing browser.
Now, redbean 2.o (yes, that does say two-dot-oh, not two-dot-zero) takes the original redbean and adds in a REPL – for non-Lispy types, an interactive command line – and a Unix SysV API (yes, even on Windows), plus logging and more.
Talking about Lisp, another of Tunney's astonishing projects is SectorLisp, which embeds a Lisp interpreter into a PC boot sector. SectorLisp 2 adds garbage-collection too, making it the smallest GC language in the world. Given this interest in programs that can be booted directly, without an OS at all, it may not surprise you that a future goal for redbean is to make it bootable: to embed a TCP/IP stack and network-card drivers, for a completely standalone tool. ®
If you don't just take our word for it, and want to try redbean for yourself, then it's worth knowing that there are issues on some operating systems. Recent versions of macOS (11 and 12) break some of the trickery that allows APE to work, as does Ubuntu. The Hacker News discussion about the project and its antecedents contain some workarounds.
Review The Reg FOSS desk took the latest update to openSUSE's stable distro for a spin around the block and returned pleasantly impressed.
As we reported earlier this week, SUSE said it was preparing version 15 SP4 of its SUSE Linux Enterprise distribution at the company's annual conference, and a day later, openSUSE Leap version 15.4 followed.
The relationship between SUSE and the openSUSE project is comparable to that of Red Hat and Fedora. SUSE, with its range of enterprise Linux tools, is the commercial backer, among other sponsors.
Comment Recently, The Register's Liam Proven wrote tongue in cheek about the most annoying desktop Linux distros. He inspired me to do another take.
Proven pointed out that Distrowatch currently lists 270 – count 'em – Linux distros. Of course, no one can look at all of those. But, having covered the Linux desktop since the big interface debate was between Bash and zsh rather than GNOME vs KDE, and being the editor-in-chief of a now-departed publication called Linux Desktop, I think I've used more of them than anyone else who also has a life beyond the PC. In short, I love the Linux desktop.
It is a truth universally acknowledged that all operating systems suck. Some just suck less than others.
It is also a comment under pretty much every Reg article on Linux that there are too many to choose from and that it's impossible to know which one to try. So we thought we'd simplify things for you by listing how and in which ways the different options suck.
This would be an impossibly long list if we looked at all of them since Distrowatch currently lists 270. So we need to thin the herd a bit.
At The Linux Foundation's Open Source Summit in Austin, Texas on Tuesday, Linus Torvalds said he expects support for Rust code in the Linux kernel to be merged soon, possibly with the next release, 5.20.
At least since last December, when a patch added support for Rust as a second language for kernel code, the Linux community has been anticipating this transition, in the hope it leads to greater stability and security.
In a conversation with Dirk Hohndel, chief open source officer at Cardano, Torvalds said the patches to integrate Rust have not yet been merged because there's far more caution among Linux kernel maintainers than there was 30 years ago.
A Linux distro for smartphones abandoned by their manufacturers, postmarketOS, has introduced in-place upgrades.
Alpine Linux is a very minimal general-purpose distro that runs well on low-end kit, as The Reg FOSS desk found when we looked at version 3.16 last month. postmarketOS's – pmOS for short – version 22.06 is based on the same version.
This itself is distinctive. Most other third-party smartphone OSes, such as LineageOS or GrapheneOS, or the former CyanogenMod, are based on the core of Android itself.
Microsoft has made it official. Windows Subsystem for Linux 2 distributions are now supported on Windows Server 2022.
The technology emerged in preview form last month and represented somewhat of an about-face from the Windows giant, whose employees had previously complained that while the tech was handy for desktop users, sticking it on a server might mean it gets used for things for which it wasn't intended.
(And Windows Server absolutely had to have the bloated user interface of its desktop stablemate as well, right?)
Right after the latest release of the KDE Frameworks comes the Plasma Desktop 5.25 plus the default desktop for the forthcoming Linux Mint 23.
Apple is extending support for its Rosetta 2 x86-64-to-Arm binary translator to Linux VMs running under the forthcoming macOS 13, codenamed Ventura.
The next version of macOS was announced at Apple's World Wide Developer Conference on Monday, and the new release has a number of changes that will be significant to Linux users. The company has disclosed the system requirements for the beta OS, which you can read on the preview page.
One level of Linux relevance is that macOS 13 still supports Intel-based Macs, but only recent ones, made in 2017 and later. So owners of older machines – including the author – will soon be cut off. Some will run Windows on them via Bootcamp, but others will, of course, turn to Linux.
Version 21.3 of Manjaro - codenamed "Ruah" - is here, with kernel 5.15, but don't let its beginner-friendly billing fool you: you will need a clue with this one.
Manjaro Linux is one of the more popular Arch Linux derivatives, and the new version 21.3 is the latest update to version 21, released in 2021. There are three official variants, with GNOME 42.2, KDE 5.24.5 or Xfce 4.16 desktops, plus community builds with Budgie, Cinnamon, MATE, a choice of tiling window managers (i3 or Sway), plus a Docker image.
The Reg took its latest look at Arch Linux a few months ago. Arch is one of the older rolling-release distros, and it's also famously rather minimal. The installation process isn't trivial: it's driven from the command line, and the user does a lot of the hard work, manually partitioning disks and so on.
Canonical's Linux distro for edge devices and the Internet of Things, Ubuntu Core 22, is out.
This is the fourth release of Ubuntu Core, and as you might guess from the version number, it's based on the current Long Term Support release of Ubuntu, version 22.04.
Ubuntu Core is quite a different product from normal Ubuntu, even the text-only Ubuntu Server. Core has no conventional package manager, just Snap, and the OS itself is built from Snap packages. Snap installations and updates are transactional: this means that either they succeed completely, or the OS automatically rolls them back, leaving no trace except an entry in a log file.
The Register - Independent news and views for the tech community. Part of Situation Publishing
Biting the hand that feeds IT © 1998–2022