ELSEIF
Your brief EB
447 stories from 135 feeds 604 clusters Refreshed 7 minutes ago next pull 05:42

DATABASES Signal 564 2 feeds carried it

Executables stored as SQLite databases enable queryable state and code in single files

Illustration only Photo by Tyler on Unsplash

A proof-of-concept format treats executables as SQLite databases, allowing programs to store and query their own state transactionally within the same file they run from

WHY IT MATTERS

This approach collapses binary tooling and application state into SQL, eliminating the need for separate filesystems like /var or /tmp. For engineers, it introduces a novel way to manage program state and configuration, but may complicate debugging and security auditing due to mutable executables. The trade-off between simplicity and operational risks will determine adoption

Written by elseif from the cluster below · every claim links back to a source

The three things worth knowing

01

Programs can store runtime state in the same SQLite file they execute from, enabling transactional updates to their own code or data

02

The proof-of-concept webserver `self-httpd` demonstrates serving routes, logging visits, and persisting state entirely within a single executable database file

03

The format relies on Linux’s `binfmt_misc` to trigger a custom interpreter, which maps database rows to executable segments and passes the file path as `argv[0]`

THE READ

What the cluster adds up to.

ORIGINAL ANALYSIS

The SELF format reimagines executables as SQLite databases, where code, configuration, and runtime state coexist in a single file. This collapses traditional filesystem boundaries by embedding application data, such as logs, user sessions, or dynamic content, directly into the executable. For engineers, this simplifies deployment and state management, as a single file can be copied, backed up, or versioned atomically. However, it also introduces operational challenges: mutable executables complicate integrity checks, and accidental corruption could render the program unusable. The approach trades filesystem complexity for database complexity, requiring robust transaction handling to avoid data loss during crashes or concurrent access

The proof-of-concept `self-httpd` demonstrates the practicality of this model by serving a website, logging visits, and recording button presses, all within the same SQLite file. The server’s state is queryable via SQL, enabling real-time introspection without additional tooling. For example, counting visits or retrieving logs becomes a matter of running `SELECT` statements against the executable itself. This blurs the line between code and data, but it also creates a single point of failure: if the database becomes corrupted, both the program and its state are lost. Engineers would need to weigh the convenience of unified storage against the risks of coupling runtime state to the executable’s lifecycle

Implementation relies on Linux’s `binfmt_misc` to intercept execution and launch a custom interpreter, which maps database rows to executable segments. The interpreter passes the file path as `argv[0]`, allowing the program to open and query its own database. This design avoids the need for `/proc/self/exe`, which currently doesn’t support `binfmt_misc`-triggered executables. While elegant, the approach is Linux-specific and requires kernel-level support, limiting portability. Additionally, the interpreter must release its SQLite connection before handing off to the program, ensuring no resource leaks. This introduces a small but critical dependency on the interpreter’s correctness, as failures could prevent the program from starting

The format draws inspiration from `redbean`, a single-file webserver that uses a self-extracting ZIP archive. Unlike `redbean`, which embeds Lua for dynamic responses, SELF leverages SQL for both configuration and state management. For instance, adding a new route in `self-httpd` involves inserting a row into a `handlers` table, rather than writing Lua code. This shift simplifies tooling but requires engineers to think in terms of database schemas for program logic. While SQL is familiar to many, it may not be the most intuitive language for defining application behavior, particularly for complex workflows. The trade-off here is between the flexibility of a general-purpose language (Lua) and the declarative simplicity of SQL

The long-term viability of this approach hinges on its ability to handle edge cases, such as concurrent writes, file locking, and performance at scale. SQLite’s write-ahead logging (WAL) mode, as demonstrated in `self-httpd`, mitigates some of these issues, but high-throughput applications may still struggle with contention. Additionally, the format’s reliance on a single file could become a bottleneck for large applications, where database size impacts startup time and memory usage. Engineers evaluating this model should consider whether the benefits of unified storage outweigh the potential downsides of mutable executables and database-specific constraints

Written by elseif from the cluster below · checked for specifics the sources never contained

THE CLUSTER

Same story, 2 feeds.

ORDERED BY FIRST SEEN
Farid Zakaria’s Blog Actually Queryable Executables Open ↗
Farid Zakaria’s Blog via Hacker News Queryable Executables Open ↗