Version 2 of Redbean, a single-file web server running on any x86-64 OS is available, with new APIs, code completion and more.

Justine Tunney, developer of Redbean, recently released the latest version (Redbean 2.0) of the web server. Redbean 2.0 has a new APE (Actually Portable Executable) loader that allows the server to run without modifying headers, allowing execution in memory. If the APE is not installed on the system, the shell script header will automatically extract the APE. Other new features in Redbean 2.0 are a REPL loop (Read Eval Print Loop) built on top of the “Bestline” library, code completion with the tab key, support for GNU Emacs compatible keyboard shortcuts and many other new features.

Redbean is a single-file web server that runs on any x86-64 operating system (GNU/Linux, macOS, Windows, FreeBSD, OpenBSD and NetBSD). It allows sharing web applications that work offline as a single ZIP archive containing your assets. All you have to do is download the “” program, change the filename to .zip, add your content in a zip editor tool, and then change the extension back to .com. A proxy like the nginx server is not required; Redbean is vertically integrated.

According to the developer, Redbean can deliver more than 1 million gzip-encoded responses per second on a cheap PC. Tunney feels that with the release of Redbean 2.0, the project is no longer just a hobby. Over the past year, we’ve made Redbean more than just a hobby project.” Below are the new features of Redbean 2.0.

New APE charger

Redbean uses a hack called “APE” (Actually Portable Executable). The idea is this: no matter what programming language you use, when you compile your code into native binary, it produces x86-64 machine code – and any x86-64 processor runs the same machine code. Basically, if you’re writing a program that doesn’t call external code, the only difference between a Windows binary and (let’s say) a Linux binary is in the format of the file that contains the binary. So if you could work around this problem, your program could run on any operating system.

APE files, as the name suggests, are truly portable executables. A single APE file runs smoothly on any x86-64 operating system. When run on Windows, the file behaves like a Windows executable, and when you run it on macOS, it behaves like a macOS executable. When run on Linux, it’s a Linux binary, and it’s the same on FreeBSD, OpenBSD, NetBSD, although they all have their own different executable formats. However, almost all real programs need to call a library, even the standard C library.

This is where the “Cosmopolitan” or Cosmo library comes into play. Thanks to the Cosmo library, C programs can be compiled and run on any operating system supported by the APE loader. Redbean 2.0 introduces a new APE loader that allows your server to run without having to change its header automatically. Place an order Ape will then place your Redbean (server) in memory as well mmap(). If the APE is not installed on a system, it is automatically extracted from the shell script header. There is support junk and a stand binfmt_misc also under Linux.

Tunney notes that these changes should have a positive impact on distributions and build systems that have had difficulty packaging and distributing APE software. A flag for users who want the original behavior –assimilate introduced which converts your redbean to a format ELEVEN Where macho Local the platform.


Redbean 2.0 introduces a Read Eval Print Loop, or REPL for short. It builds on the “Bestline” library as it offers close parity with GNU Readline in terms of functionality, except that it is licensed under MIT rather than LGPL, so dynamic linking is not required. Redbean can’t link things dynamically because then it wouldn’t be a single file. Tunney said he put a lot of work into developing Bestline, a fork of Linenoise, for exactly this reason.

monkey patching

One of the use cases for a REPL on a live web server is the ability to patch code while the server is running. Redbean is a fork web server. This means that the main process behaves like a master model from which the worker processes are cloned. So anything you change in the REPL is lazily propagated across client connections as new connections are created, without affecting currently active connections. Other notable features of this version are:

  • Code Completion: Redbean 2.0 introduces code completion. As with Bash, you can press Tab to see a list of all available functions and global objects. When you press unix.then you will see all the objects and functions available in the Unix module;
  • GNU Emacs Keyboard Shortcuts: GNU Emacs users will be pleased to know that your redbean REPL supports almost all common GNU-style keyboard shortcuts, including CTRL-R for reverse search;
  • Unix Module: Redbean 2.0 introduces a new Unix module implemented in tool/net/lunix.c ;
  • Logging support: Redbean 2.0 introduces optional logging of system calls;
  • Lua improvements: Redbean 2.0 brings improvements to the Lua language designed to help C/C++ and Python developers feel more comfortable;
  • new APIs: Redbean 2.0 introduces the following native functions: EncodeJson, EncodeLua, Compress, Dcompress, GetMonospaceWidth, ProgramMaxPayloadSize, ProgramSslRequired, ProgramSslClientVerify, MeasureEntropy, Decimate, Benchmark, Rdtsc, Lemur64, Rand64, Rdrand, Rdseed, GetCpuCount, GetCpuCore, GetCpuNode, oct , hex, bin;
  • redbean 2.0 adds support for modern password hashing;
  • Bug Fixes: This release includes many upstream fixes for the Cosmo library. The quality of Windows platform support has been significantly improved. For example, Fork() now works well enough on Windows that this version enables it by default. Many other Windows bugs that prevented Redbean from responding to CTRL-C interrupts have also been fixed.

Source: Redbean 2.0

And you?

What is your opinion on the topic?
What do you think of the Redbean web server?
What do you think of the new features in Redbean 2.0?

See also

Caddy, the only web server that uses HTTPS automatically and in Go language by default

JDK 18: New features in Java 18 include the vector API, a minimal web server, and adopting UTF-8 as the default character set

The 2022 WebAssembly Development Status Report shows that Rust is the most used and searched language and that web applications are the primary use case

Fresh, a next-gen web framework built for speed, reliability, and simplicity, brings some competition to Next.js

Leave a Comment