Hacker News new | past | comments | ask | show | jobs | submit
Now, when you say no libraries, exactly how far does that go? I unfortunately, a couple years ago, suffered through insisting I wanted to use C++ without the standard libraries, not even crt0, and finding documentation on how anything works was a huge pain in the ass.

Actually, what sold me on bothering with LLMs was asking one, last year, how to call a kernel syscall with GCC's inline assembly syntax, and seeing the answer be exactly what I needed... after I had already cobbled everything together myself! (I do not consider random mailing list archives to be adequate documentation!)

I didn't mean to say you should have an AI inspect your code, though. (I've personally found value in that technique, because current frontier models can recognize problems way better than their lackluster ability to avoid writing those same problems repeatedly into their own disgusting code. I can still just write the code myself, with another eye on it.)

I just really like fuzzing and really like differential analysis. For example, one of the images in my test suite decodes to one set of pixels with FFmpeg, libpng, stb_image, among others, and decodes to a different set of pixels with libspng, lodepng, Java's ImageIO, and other others (as far as I can tell, the reason is ambiguous 2nd-ed spec wording that isn't obviously ambiguous when you read it). You can quite easily fuzz one implementation against another, running them in parallel against the same inputs, and make a mismatch crash the test runner so the fuzzer flags an error.

Incidentally, asking Claude Fable 5 to do that usually triggers a cybersecurity block for me. Another point in favor of knowing things by hand...

Not that I'm saying you should drop everything and do this. I just like talking about it. Learning-experience projects get easily spoiled by trying too hard, which I did learn the hard way. Then again, I hella enjoyed practicing becoming aware of code coverage when I wrote a few prototype compilers. Researching online when I was making my first one is how I learned about Jonathan Blow and Casey Muratori, by the way. I don't follow Handmade Hero, but I do wholeheartedly approve of its existence.

  I also loved tutorials in the 90s like "build your own OS", "build your own bootloader", "build your own C compiler", etc; build your own printf(), your own malloc, etc. Learned a lot this way!
You must be older than me! I was born in the 90s, and the usual reaction I expect to saying I built my own memory allocator is incredulity because "why make something that already exists?" or "ew, you should've used Rust".

I haven't run across that Carmack quote before, but I've told plenty of people the same thing in my own words. I think one of the most important parts of it that I've learned is this: You can't get something right without screwing it up first. I don't mean that making mistakes is a goal to target. I mean that you can't learn without the errors along the way. If you're always right the first time, that's just luck, and you haven't learned yet.

And I must say, I miss the days when "grok" was a weird word some programmers use, not an AI brand.

Anyway, I'd be quite curious to see your project if you ever put it up in public. I wouldn't worry about polishing it, really. In high school, I still didn't know people normally write rough drafts of stories and draw sketches long before making the finished piece. Never saw any of that, so I thought my inability to "oneshot" these things with the results of a high-skill artist meant inherent lack of talent. If all you ever see is finished refined products, how can you possibly know better?

  Now, when you say no libraries, exactly how far does that go?
No libraries at all like stb_image, openssl, libcurl, etc. But it does use the platform APIs to create a window, get keyboard and mouse events, create TCP sockets, etc. It uses some libc calls like printf and malloc, but then it has its own memory allocators and arenas for DOM objects, CSS rules, and other common objects.

On Windows it just targets Win32.

On macOS it uses a bit of Objective-C to create an NSWindow and for the main message loop.

On Linux it uses libxcb to connect to X11. I planned on using Xlib originally, but libxcb is closer to the protocol and IMO cleaner. After using it I also got a sense that the X11 protocol is pretty straightforward, so I might just replace libxcb with a custom implementation.

For example, I need to query DBus for things like the desktop theme preference (dark/light) but didn't want to link build the DBus protocol messages from XML in the build, so it just queries libdbus directly and parses all the messaging. Maybe it should have a custom DBus client too...

(Linux doesn't have a "native" UI, so I made this exception on that platform to be able to make windows, etc as in the other platforms)

---

There are lots of reasons to "do it yourself" (and lots of good reasons NOT to do it too -- I wouldn't do this professionally!)

My goal here was to make a presentable and polished product, so I spent some time on code quality, correctness, performance, etc. and in presenting a nice browser that feels familiar. Here's a screenshot: https://imgur.com/a/ojWvciR

More than anything, I really like being in the flow and feeling the joy of programming -- building something step by step and seeing the results incrementally. A browser is quite a nice project for that, since you have the whole web to interact with and lots to implement.