Top
Best
New

Posted by imtomt 11 hours ago

Show HN: Building a web server in assembly to give my life (a lack of) meaning(github.com)
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/

324 points | 155 commentspage 4
JSR_FDED 9 hours ago|
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.

t-3 9 hours ago|
Arm is very nice to write assembly for. Having a proper load/store register-centric architecture rather than a stack-centric like x86 makes the mental load of writing code go waaay down, so the attractiveness of HLLs for ease of writing code is greatly diminished on RISC.
userbinator 4 hours ago||
Hell no. Far too many registers, not enough instructions, and (especially with ARM64) weird restrictions that arose from trying to pack things into 32-bit instructions as efficiently as possible.

I've been writing x86 Asm for a few decades. RISCs are simpler in all the wrong ways. After all, "just use a (stupid) compiler" was the whole philosophy.

xyst 10 hours ago||
Need a straight binary port now
imtomt 9 hours ago|
Why stop there? Next, I'm prying open a CPU and poking the transistors with a 9V battery and paperclips to make it execute what I want. Slower, but you get so much control.
polotics 2 hours ago||
do you know about rwasa?

https://2ton.com.au/rwasa/

...

nunez 9 hours ago||
Where's your SKILLS.md? How did your agents make this?

jk. Metal as fuck. Love it.

imtomt 9 hours ago|
Ahh you caught me. I just kept telling ChatGPT dot com "no, make it less efficient" and copied whatever output it gave me. jk, thank you!
jjbigs 10 hours ago||
This is fucking nuts
faangguyindia 10 hours ago||
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.

losteric 9 hours ago||
Can you share what some of those apps are?
arrty88 8 hours ago|||
I’ve written all of these languages and more professionally. I agree none match the speed and simplicity of golang. Go is that efficient.
iamgopal 9 hours ago|||
How are you merging sqlc and pgx with sqlite ?
lelandbatey 9 hours ago||
Specifically how can you use pgx with sqlite while pgx is a postgres-specific library? Sqlc works great with Postgres or Sqlite, Sqlc works with pgx when connecting to Postgres, but pgx can't be used with Sqlite AFAIK
sampullman 9 hours ago|||
Did you reply to the wrong submission?
tonyedgecombe 9 hours ago|||
They replied to the title.
plusplusungood 9 hours ago||
What's your point?
faangguyindia 9 hours ago||
You don't need to use assembly for high performance web app when you can just use Go.
ericbarrett 9 hours ago||
You don't, but it's so much cooler when you do! Not everything needs to be a beige utilitarian module optimized for business consumption.

I didn't need to implement an Intel RDRAND streamer in C and assembler, but it was a ton of fun: https://github.com/ehbar/rdrand-stream

OP, I really liked this project. Kudos for publishing it!

imtomt 9 hours ago||
Woah, that's really cool! I'm glad you did that even if you didn't need to. I honestly think everyone needs to write more assembly, because it's so much cooler.
imtomt 11 hours ago||
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
dang 11 hours ago|
Whoops that was my fault. Fixed now. (I emailed you, btw, that we'd changed your title, but I forgot to switch the URL back to the repo. Both links are cool.)

I'm sure I'm not the only one who has fantasized about doing something like this as a self-soothing enterprise. Kudos to you for actually doing it!

imtomt 10 hours ago||
Hey, thank you! Means a lot. It's an odd sort of meditation, but is surprisingly the most almost-therapeutic project I've worked on. Something about the constraints of Assembly that really pull you into the minutiae and clears your head, maybe.
idovmamane 4 hours ago||
[dead]
vladsiu 7 hours ago||
[dead]
feiz45607 9 hours ago|
[flagged]
More comments...