Show HN: Building a web server in assembly to give my life (a lack of) meaning
A developer painstakingly crafted 'ymawky', a web server written entirely in ARM64 assembly for macOS. This impressive low-level feat resonated deeply with Hacker News readers, who celebrated the technical mastery and nostalgic appeal of programming at the silicon level. The project sparked discussions on the challenges of OS-specific assembly and the unique satisfaction of building fundamental software from the ground up.
The Lowdown
Meet 'ymawky', a static file web server for macOS meticulously written by hand in ARM64 assembly. This impressive project, developed as a 'syscall-only, no libc, fork-per-connection' server, serves as both a functional tool and a profound learning exercise into the inner workings of operating systems and hardware.
- ymawky supports standard HTTP methods (GET, PUT, DELETE, OPTIONS, HEAD) and features like range requests for video streaming.
- It includes essential web server functionalities such as percent-encoded URL decoding, strict docroot enforcement, custom error pages, and directory listing.
- The server implements several "safety" precautions against vulnerabilities, including path traversal prevention, symlink rejection, and atomic PUT operations to prevent data corruption.
- It handles a comprehensive list of HTTP status codes and automatically detects a wide array of MIME types for various file extensions.
- Configuration is managed directly within the
config.Sassembly file, allowing adjustments for docroot, error page directories, various timeouts, maximum body size for PUT requests, and concurrent process limits. - The author transparently notes that while efforts were made for portability, the server is highly macOS-specific due to fundamental differences in syscalls, calling conventions, error reporting, and struct layouts compared to Linux or other Unix-like systems.
Ultimately, ymawky stands as a testament to the power of low-level programming and the dedication required to demystify complex systems, offering a unique blend of functionality and educational value.
The Gossip
Assembly Admiration & Awe
The overwhelming sentiment among commenters was one of admiration and excitement for the sheer technical challenge and dedication involved in writing a web server in ARM64 assembly. Many expressed a 'warm feeling' and a sense of shared joy in seeing such a low-level project, viewing it as a celebration of fundamental programming skills and a refreshing departure from abstract, high-level development. The author's endeavor was seen as 'metal as fuck' and inspiring.
Portability Predicaments & OS Peculiarities
A significant portion of the discussion revolved around the project's macOS-specific nature and the difficulties of achieving portability in assembly. The author provided detailed explanations of why direct porting to Linux is challenging, citing fundamental differences in syscall interfaces (e.g., `x16` vs. `x8` for syscall numbers, `svc #0x80` vs. `svc #0`), error reporting mechanisms, struct layouts (like `sigaction` and `stat64`), and macOS-specific syscalls such as `proc_info()` and `getdirentries64()`. This highlighted the intricate and non-trivial nature of cross-OS assembly development.
Learning's Low-Level Lure
Many commenters, including the author, advocated for the educational and even 'therapeutic' benefits of engaging with assembly language. They described it as an unparalleled way to 'demystify how CPUs and compiled languages work' and gain a deeper understanding of computer architecture. The author noted that the constraints of assembly coding can clear one's head, making it a surprisingly meditative process, and offered advice on learning, such as reading existing code and compiling C/C++ to observe generated assembly.
High-Level Hijacking & The 'Why Not Go?' Interruption
A tangent emerged when one commenter argued that modern high-level languages like Go, combined with efficient frameworks and tools, could achieve comparable performance for web applications without the need for assembly. This perspective was largely met with gentle disagreement, as other users clarified that the project's value wasn't in practical performance competition but in the inherent 'coolness' and intellectual satisfaction of the low-level challenge itself, emphasizing that not all projects need to be purely utilitarian.