Redbean version 2, a single web server running on any x86-64 operating system, is available with new APIs, code completion, and more.


Justine Tunney, developer of Redbean, recently released the latest (Redbean 2.0) version of the web server. Redbean 2.0 features an APE (Physical Portable Executable) loader that allows the server to run without modifying the headers, thus enabling in-memory execution. If APE is not installed on the system, the shell script header automatically extracts the APE. Other new features in Redbean 2.0 include a REPL loop (read short print review) built on top of the “bestline” library, code completion using the Tab key, support for GNU Emacs compatible keyboard shortcuts, and many other new features. Still other.

Redbean is a single file web server that runs on any x86-64 operating system (GNU/Linux, macOS, Windows, FreeBSD, OpenBSD, NetBSD). Allows sharing of your offline web applications as a single zip archive containing your assets. You just need to download “redbean.com”, change the file name to .zip, add your content in the zip editor tool, and then change the extension back to .com. There is no need for a proxy as in the case of nginx server; Redbean is vertically integrated.

According to the developer, Redbean can deliver more than 1 million gzip-encrypted responses per second on a cheap PC. Tony feels that with the release of Redbean 2.0, the project is no longer just a hobby. Over the past year, Redbean has made us more than just a hobby project, said the developer. Here are the new features of Redbean 2.0.

New APE Charger

Redbean uses a hack called “APE” (Actually Portable Executable). The idea is this: Whatever programming language you use, if you compile your code into a native binary system, it produces x86-64 machine code – and any x86-64 processor runs the same machine code. If you are writing a program that does not call any external code, then in principle the only difference between a Windows binary and (for example) a Linux binary is the file format that the binary contains. So if you can solve this problem, the software can work on any operating system.

APE files, as their name suggests, are actually portable executable files. A single APE file works fine on any x86-64 operating system. When the file is run on Windows, it behaves like a Windows executable file and when you run it on macOS, it behaves like a macOS executable. When running on Linux, it’s a Linux binary, and the same on FreeBSD, OpenBSD, and NetBSD, although they all have different executable formats. However, all real programs must call a library, even the standard C library.

This is where the “Cosmopolitan” library, or Cosmo, comes in. Thanks to the Cosmo library, C programs can be compiled and executed 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 adjust its header automatically. the place of the matter Monkey It will then put the red bean (server) into memory with mmap (). If APE is not installed on a system, the shell script header will extract it automatically. There is support hut and attitude binfmt_misc Also on Linux.

Tony says these changes should have a positive impact on distros and build systems, which have struggled to package and distribute APE software. For users who want the original behavior, tag – absorb Introduced which will turn red beans into format dwarf where Mach-O local platform.

REPL

Redbean 2.0 is offering Evaluative Reading Reading for Print Loop, or REPL (Evaluating Reading for Print Loop) for short. It is built on top of 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 there is no requirement for dynamic linking. Redbean can’t link things dynamically, because it wouldn’t be a single file. Tony said he put in a lot of work to come up with the best line, the fork from “Linoys,” for this very reason.

patching monkey

One use case for REPL on a live web server is the ability to apply corrections to code while the server is running. Redbean is a forked web server. This means that the main process behaves like a main form from which the worker processes are cloned. So anything you change in a REPL slowly propagates through client connections as new connections are created, without affecting the currently active connections. Other notable features of this version are:

  • Code completion: Redbean 2.0 offers code completion. As with Bash, you can press Tab to see a list of all available functions and public items. if you press unix. then you will see all the objects and functions available in the Unix module;
  • GNU Emacs keybindings: GNU Emacs users will be happy to know that the redbean REPL file supports nearly all popular GNU style keybindings, including CTRL-R for reverse lookup;
  • Unix Module: Redbean 2.0 introduces a new Unix module implemented in tool / net / lunix.c ;
  • Recording support: Redbean 2.0 offers optional system call recording;
  • Lua improvements: Redbean 2.0 introduces improvements to Lua aimed at helping 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, Rdtspu, GetCountore, Bin, Hex,
  • redbean 2.0 adds support for modern password hashing;
  • Bug fixes: This release includes several initial fixes for the Cosmo library. The quality of Windows platform support has been significantly improved. for example, fork() It now works well enough on Windows that this version allows it by default. Several other Windows errors that prevented Redbean from responding to CTRL-C interrupts have also been resolved.

Source: Redbean 2.0

And you?

What do you think about it?
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 by default, is written in Go

JDK 18: New features in Java 18 include a Vector API, a small web server, and UTF-8 support as the default character set

WebAssembly Development Status Report 2022 reveals that Rust is the most used and wanted language, and web applications are the primary use case

Fresh, the next generation web framework, built for speed, reliability and simplicity, brings some competition to Next.js

Leave a Comment