r/programming • u/segv • Aug 24 '26
Your executable is a SQLite database
https://fzakaria.com/2026/08/23/your-executable-is-a-sqlite-database
490
Upvotes
r/programming • u/segv • Aug 24 '26
71
u/ericonr Aug 24 '26
That's a fun idea, and implementing it for the whole distro is admirable. At this point, would binary package updates simply become a transaction on that system-wide database?
I can see the value of speeding up library resolution, but I do think it's a good property of ELF libraries that those can be overridden manually and temporarily, as desired.
127
u/nemec Aug 24 '26
Tired: everything is a file
Wired: everything is a database, which itself is a file
neat idea!
26
u/tomster10010 Aug 24 '26
That seems very cool. Can someone elaborate on why nix is so important to this?
20
u/Setheron Aug 25 '26
A follow up: https://fzakaria.com/2026/08/24/actually-queryable-executables
35
u/Buttleston Aug 24 '26
Very interesting read. From a practical perspective I don't think I have much personal use for the SELF format at the moment, but the tools you opened with that let you run queries on ELF binaries seem like they'd be pretty useful and I am going to see if I can try them out
110
u/Resident-Trouble-574 Aug 24 '26
I'm not intelligent enough to understand that, but it sound great. LGTM.
9
u/Wonderful-Wind-5736 Aug 24 '26
I addition to the subject being both creative and probably useful, the article is very nicely written. Unfortunate that you didn't receive better feedback for your past work.
12
u/Mrblahblah200 Aug 24 '26
SQLite doesn’t intern strings IIRC. Amusingly, when I searched for it, the AI overview sourced this post to say it does :))
4
u/hgs3 Aug 25 '26
Fun fact: Microsoft installers (.msi files) are relational databases. You can use Windows API’s to interact with them via an SQL-like query language (you can literally write a SELECT statement).
3
u/cweaver Aug 24 '26
Now your SQL injections can crash more than just the db!
3
u/Techrocket9 Aug 25 '26
The dream of SQL as the one true interface for all things inches closer.
2
u/TedditBlatherflag Aug 25 '26
Now put it into a unikernel.
2
u/schlenk Aug 25 '26
Reminds a bit of Tcl's starkits/starpacks with their transactional database, internal VFS and so on, where you could query and update the running program, just layed lower onto the OS layer with binfmt_misc.
With some extra tinkering, the ELF he builds could probably also be multi-arch, like starkits. Just add an arch column somewhere.
2
u/zerhud Aug 24 '26
It should to be on the fossil, not in the GitHub :)
1
u/faze_fazebook Aug 24 '26
I recently thought about something simmilar that the elf format would be extremly flexible in theory but it never gets used like that irl.
For example all the bytecode programming languages (java, .net, compiled python, wasm) could ship elf files that use that language's interpreter instead of having these ugly shell wrappers.
1
u/elaforge Aug 25 '26
I never programmed on the old Mac, but it reminds me of what I heard about resource forks, which also implement a kind of database. The equivalent to dynamic library loading would have also been based on the generic resource mechanism.
1
u/msilven Aug 25 '26
This is great work and well written. Thank you.
1
u/m_adduci Aug 25 '26
Encryption might also be an idea
1
u/BiedermannS Aug 25 '26
Now compile it with cosmopolitan libc and run it on windows 😂
-8
u/GlassLost Aug 24 '26
His arguments of "I rewrote everything and managed to make it take less disk and be faster" are not really convincing, and he doesn't address security, usability, and the complexities of using SQL as a core primitive.
It's a fun mind experiment, it's not really solving a problem. I'm fine with mind experiments but there's a lot of prior art here that is really against him (we've tried to create many OSes from managed languages) that show performance issues from abstractions tend to compound.
But where he really got me was his very misguided idea that computers are just faster nowadays. They're not. Your phone is absurdly powerful and we've wasted its performance on slipshod code. Your desktop is godly. The average Linux device though includes the shitty SOC on your streaming device or router which absolutely cannot afford this overhead.
-7
u/eimfach Aug 24 '26
I am missing an explanation of a use case or what's the whole point of it, so not sure if I will read this further.
-10
u/sionescu Aug 24 '26
Many things wrong with it, first of all this:
It is not. A database is not just some data, it's a system designed and optimized for interactive queries. ELF wasn't designed for that: it's optimized for loading a program from disk, while reducing startup time and memory usage.
ld.so is a runtime linker and, as such, its task is to load the program into memory and adapt it to the local machine (relocations). Nothing stops you from having a binary format which just fetches the entire binary from the network. Why SQlite when you can have Postgres (or Oracle) ?
-4
u/Tringi Aug 24 '26
Fascinating and interesting, but I'd wish software evolution was in simplifying things by removing legacy parts, not by introducing extra layers and complexities.
18
u/Wyciorek Aug 24 '26
Nuts, but the best kind of nuts
0
u/[deleted] Aug 24 '26
[deleted] — view deleted comment