Live data from Hacker News

Show HN: Building a web server in assembly to give my life (a lack of) meaning

github.com

21–30 of 246 posts

Re: Show HN: Building a web server in assembly to give my life (a lack of) meaning

#22
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!

Re: Show HN: Building a web server in assembly to give my life (a lack of) meaning

#24
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.

Re: Show HN: Building a web server in assembly to give my life (a lack of) meaning

#25

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?

I wrote it for MacOS because I don't have a Linux machine right now :( Once I get one up and running again, I'll probably work on porting this.

As for why it wouldn't run on Linux, there are some pretty big differences in the actual assembly. One pretty superficial difference is calling conventions -- MacOS uses the x16 register for syscall numbers, Linux uses x8. Calling the kernel in Mac uses "svc #0x80", in Linux it's "svc #0". That's ~120 lines that need to be replaced, but easy enough to just use sed. Syscall numbers are all different, as are the struct layouts for sigaction(), MacOS has an "sa_tramp" field that Linux doesn't have. Enforcing max processes is done here using the MacOS-specific proc_info() syscall, which can be used to get the number of children any given process has. Linux doesn't have an equivalent, so process tracking would need to be done differently. Finally, Linux has the getdents64() syscall, rather than getdirentries64(), which uses a different struct and is called differently.

I'm sure an LLM could make all those changes, but it's a pretty large codebase, so it would probably make some mistakes or miss things.

Re: Show HN: Building a web server in assembly to give my life (a lack of) meaning

#27

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 se…

Did you reply to the wrong submission?

Re: Show HN: Building a web server in assembly to give my life (a lack of) meaning

#28

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 se…

How are you merging sqlc and pgx with sqlite ?

Re: Show HN: Building a web server in assembly to give my life (a lack of) meaning

#29

Here's a piece on writing portable ARM64 assembly: https://ariadne.space/2023/04/12/writing-portable-arm-assemb...

Thanks for the link, bookmarking. I should note ymawky's main portability issues are unfortunately at the syscall layer rather than the asm layer. proc_info() and getdirentries64() are pretty Darwin-specific, so making it portable would require reworking that whole area rather than adjusting register/calling conventions.

Re: Show HN: Building a web server in assembly to give my life (a lack of) meaning

#30

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 se…

Did you reply to the wrong submission?

[deleted]
Post reply on HN