Live data from Hacker News

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

github.com

221–230 of 246 posts

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

#221
post #61
post #51

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

Yeah, I know MacOS syscalls aren't stable. Interesting point about Go, I hadn't heard about that. Unfortunately I'm a masochist though, and want to avoid libSystem.dylib as much as possible. The only reason I link against it at all is because MacOS requires it for executables to run, I never actually call into it. Figured I'd just update the syscall numbers if/when they change.

You could also do a trick some Windows stuff does - parse syscall indices from said dylib.

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

#222
post #148

Earlier quoted context omitted.

> "strlen" will always iterate through a string searching for a NULL byte whether it's in C, Rust, Assembly Not all languages use NULL terminated strings. I think Rust actually stores the string length alongside a pointer to the start of the string data. You can do the same in C, but you'd have to do it manually using a struct. In assembly you could do the same thing since you get to decide basically everything. http…

Pascal stores the length of the string next to the string, but the other thing of note is with the advent of Unicode, strlen is strlen, but often not actually the number you need/want.

I argue that strlen is actually still quite often the number you need+want, because possibly the main use case for it is determining how many bytes long a string is.

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

#223
post #115

Earlier quoted context omitted.

Woah! I honestly feel more intimidated writing a CGI script in assembly than I was writing a server, lol. CGI support has been on my mind for a couple weeks, but I haven't really dug into it yet. I'd love to see yours if it's hosted anywhere! Could be a great reference when I do.

Really? It's a bit of a nonsense that I did so long ago so it's weird to hear someone interested in it... The script has been lost to time. I wrote it 5+ computers ago and I don't even know where input that backup... The overall gist is that CGI Bin specification sets Environmental variables, STDIN and STDOUT to various values. A minimal pure assembly that writes Hello World over stdout is your minimalist CGI Script.…

Aw, that’s too bad. Sounds like it was a really fun project.

Thanks for the tips on CGI! Definitely going to look into it more. The server-side execution of CGI scripts definitely interests me more than the CGI scripts themselves, so I’ll probably just look for some existing (simple) CGI scripts and work on building the env vars and executing them.

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

#224

This is fun, thanks for sharing. I have a much more minimalist one for x86 Linux if you want to see what that looks like: https://github.com/jcalvinowens/asmhttpd

Oh wow! Your project was actually really inspiring to me, thank you for making this. I was really impressed reading through it a while back. Is it alright if I add a link to your repo in my README?

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

#225

Earlier quoted context omitted.

So go learn, and stop harassing others who are okay with using an LLM for some tasks.

You're the only person harassing anyone here; someone wanted to show off a handwritten project they did to learn a thing, and you came in with unsolicited LLM crap.

Pay closer attention. Using an LLM is the only way to get it be cross-compatible with Mac and Linux, since the author admitted that it would be too much to do this by hand. What good is code that can't even run? Heck it can't even run on Docker on a Mac.

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

#226

Earlier quoted context omitted.

You're the only person harassing anyone here; someone wanted to show off a handwritten project they did to learn a thing, and you came in with unsolicited LLM crap.

Pay closer attention. Using an LLM is the only way to get it be cross-compatible with Mac and Linux, since the author admitted that it would be too much to do this by hand. What good is code that can't even run? Heck it can't even run on Docker on a Mac.

Have you considered that as a hobby project, cross-compatibility (and especially on a tight timeline) might not be a priority, or even the point?

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

#227
post #148

Earlier quoted context omitted.

> "strlen" will always iterate through a string searching for a NULL byte whether it's in C, Rust, Assembly Not all languages use NULL terminated strings. I think Rust actually stores the string length alongside a pointer to the start of the string data. You can do the same in C, but you'd have to do it manually using a struct. In assembly you could do the same thing since you get to decide basically everything. http…

Pascal stores the length of the string next to the string, but the other thing of note is with the advent of Unicode, strlen is strlen, but often not actually the number you need/want.

Arguably a POSIX assembly programmer would also naturally keep strings along with their size, either explicitly or known implicitly, more similar to Pascal, not null-terminated, as that's how syscalls expect it. Null-terminated would chiefly be a libc-ism.

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

#228
post #223

Earlier quoted context omitted.

Really? It's a bit of a nonsense that I did so long ago so it's weird to hear someone interested in it... The script has been lost to time. I wrote it 5+ computers ago and I don't even know where input that backup... The overall gist is that CGI Bin specification sets Environmental variables, STDIN and STDOUT to various values. A minimal pure assembly that writes Hello World over stdout is your minimalist CGI Script.…

Aw, that’s too bad. Sounds like it was a really fun project. Thanks for the tips on CGI! Definitely going to look into it more. The server-side execution of CGI scripts definitely interests me more than the CGI scripts themselves, so I’ll probably just look for some existing (simple) CGI scripts and work on building the env vars and executing them.

Implementing a web server that can do CGI is actually probably easier than writing a CGI app. All you have to do for your server is set some environment variables and then spawn the executable.

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

#229

Earlier quoted context omitted.

Pay closer attention. Using an LLM is the only way to get it be cross-compatible with Mac and Linux, since the author admitted that it would be too much to do this by hand. What good is code that can't even run? Heck it can't even run on Docker on a Mac.

Have you considered that as a hobby project, cross-compatibility (and especially on a tight timeline) might not be a priority, or even the point?

How is that relevant to a general audience? Why does such an obscure hobby project deserve attention by a broad audience if one can't even run it on a Linux-like VPS? It doesn't, and I was faithfully attempting to bridge that gap, with your nasty trolling interruption coming in the way.

I don't know how much you know about assembly code, but people write it professionally to squeeze performance, typically on a server, and servers are lot more likely to run Linux than Mac. The project in question literally is a web server. Who runs a real production-grade web server on a Mac?

Post reply on HN