Show HN: Building a web server in assembly to give my life (a lack of) meaning
This is ymawky, a static file web server for MacOS written entirely in ARM64 assembly. It supports GET, PUT, DELETE, HEAD, and OPTIONS requests, and supports Range: bytes=X-Y headers (which allows scrubbing for video streaming). It decodes percent-encoded URLs, strictly enforces docroot, serves custom error pages for any HTTP error response, supports directory listing, and has (some) mitigations against slowloris-like attacks. I’ve also written a more detailed writeup here: https://imtomt.github.io/ymawky/
Discussion Highlights (20 comments)
imtomt
This post seems to now link to the writeup rather than the repository, sorry! The repo can be found at the top of that page, or directly here: https://github.com/imtomt/ymawky
thatxliner
I'm wanting to read this repository as a learning tool, so it'd also be nice to include docs—even AI-generated docs, but obvious I'd prefer docs with your own design notes and decisions—about the architecture of the code. Really cool project though!
chrisweekly
That fake O'Reilly book cover is pure gold.
trollbridge
Gave me a warm feeling to know that someone would actually still bother to do this by hand. I'm not the only one!
_the_inflator
I feel the guy’s suspicion towards any high level language. I exclusively programmed in assembly on C64, Amiga and the recognized that this ain’t sustainable on PC because there are more and more edge cases or different machine configurations. I had a very hard time simply using and even utilizing C++ or Java. C and Turbo Pascal especially was easier because the compiled code was very much resembling to hand written code. As the author described, you can do in 4.000 lines what others can do with way less pain in 100. So you build macros, come up with your own library and in the end you kind of build a meta language build on top of assembly because some lines are so hard to grasp that you delegate working code into a library for reuse. It is funny how much we take conventions for numbers for granted. If you happen to know assembly and its intricacies you immediately will learn to work with a sign bits which mark negative numbers. But how do you know? Maybe you use the whole addressable space only for positive numbers. Small things that make a huge different. Nice article, I enjoyed your adventures and would do the same.
digitaltrees
I don’t know why, but this project has me irrationally excited!
jjbigs
This is fucking nuts
OutOfHere
An agentic LLM should be pretty good at Arm64 assembly generation, but maintainability of large code could become an issue. Why would it not run on Linux?
rogeliodh
Awesome. Any resource recommendations to learn ARM assembly?
boring-human
Even after we've all retired (pretty soon for those who can afford it) or transitioned out of software engineering (for those who can't), we'll still get to amuse each other with home-brew projects like this. Warm fuzzy feeling - I'll take it!
cylinder714
Here's a piece on writing portable ARM64 assembly: https://ariadne.space/2023/04/12/writing-portable-arm-assemb...
faangguyindia
I've used Python (django/flask/fast api), Java (springboot), Ruby on Rails for writing web applications and APIs. Nothing beats Go. When you use HTMLX (goat) + sqlc (goat) + pgx (another goat) + Chi (yet another goat) and Sqlite (goat). Most apps will not need anything more than Sqlite, i've several sqlite apps doing a couple of million visits per day. Compiles to signal binary blazingly fast. Deploy using systemd service, capture logs with alloy / Loki graphana setup, set up alerts and monitoring and go home. And you can serve millions of requests on a server with 512MB RAM. I don't think you'd ever need more speed than this. Everything else is bloated, slow and doesn't give you enough room for optimization. Here's the latency of one of my hobby projects (network latency not included): https://i.ibb.co/hJ6FQtyw/d3d6c9d15765.png Request rate: https://i.ibb.co/Fq80nfJ4/67fcdbdb7491.png It's running in US and EU (helps avoid atlantic routrip tax), in this one i am doing some 100s of checks, not simple CRUD work. With Go you can optimize a lot without complexity of Rust.
xyst
Need a straight binary port now
JSR_FDED
This is a great resource, thank you! The last time I did anything in assembler was x86 under DOS. Your code makes ARM64 with a modern OS less scary than I thought it would be.
bananaboy
This is amazing, great work! I love it!
nunez
Where's your SKILLS.md? How did your agents make this? jk. Metal as fuck. Love it.
dddddaviddddd
Even though it's a meaningless comparison, I'd be interested to see how performance compares (max requests per second?) for this compared to fully-featured web servers.
mappu
Syscalls on macOS aren't guaranteed to be stable - Go found out the hard way and in 1.12 they changed to call libSystem.dylib instead. In general, stable syscall numbers are just a Linux thing. Everyone else uses blessed system libraries
maomaoati985
Your determination to make this happen was remarkable — and you truly accomplished it. Congratulations
Ati985
Your determination to make this happen was remarkable — and you truly accomplished it. Congratulations