by matheusmoreira · 3y ago · 0 comments
Completely agree: freestanding C is a superior language. I'm so happy to discover I'm not alone in thinking like this. The author is very thorough in his criticism of libc, I learned a lot from the post.
> The platform code is small in comparison: mostly unportable code, perhaps raw system calls, graphics functions, or even assembly.
For me this is what made programming fun again! I don't even bother with multiplatform implementations anymore, I go straight for Linux system calls. Turns out to be a much better interface compared to libc.
> On some platforms it will still link libc anyway because it’s got useful platform-specific features, or because it’s mandatory.
If anyone would like to know why such a thing would be mandatory, I began writing about this subject literally just a few days ago.
https://www.matheusmoreira.com/linux/system-calls
Still very much a work in progress but it does provide context for his claim.
It's sort of amazing how little userspace code a crude webserver using Linux syscalls can be: https://github.com/jcalvinowens/asmhttpd
One 4K page of code! No stack!
FROM alpine as build
RUN apk add --no-cache build-base gcompat nasm
RUN mkdir /src
COPY \* /src
RUN cd /src \
&& make
FROM scratch
COPY --from=build /src/asmhttpd /asmhttpd
CMD ["/asmhttpd", "/http"]
(Run: `podman build -t $IMAGE .; podman run -p 8080:80 -v $PATH:/http -d $IMAGE`)How much traffic can it handle, have you benchmark it?