logoalt Hacker News

silvajoao • today at 1:28 PM • 1 reply • view on HN

Thanks for sharing the school story. I totally get behind that sentiment -- knowing how to build things yourself is very satisfying and you should believe that you can do it too. The earlier you get that lesson in life, the better!

I love how John Carmack put it: [1]

  You can't know everything, but you should convince yourself that you can know anything.
The Handmade Hero series [2] channels this feeling really well, and I wanted to convey it again by building a browser from scratch but with a limited scope (Wikipedia, HN; no Javascript, but also no libraries and no AI).

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!

  might I ask how you load images? Are you using libraries, or did you write any decoders yourself?
No libraries means no libraries! :-) The decoders are written by hand, following the specs. They don't support every single configuration (e.g. JPEG has TONS of variants), but good enough for the media in Wikipedia.

This browser is a learning experience and it's definitely NOT secure (e.g. TLS "works" but it doesn't verify server certificates at all...). The decoders use a set of shared utilities for decoding big-endian/little-endian, 16 bits, 32 bits, etc and checking for overflows (using setjmp/longjmp for convenience). I think it's pretty good, and I also bet that Claude would find many problems. I'm prioritizing (1) code that works, then (2) code that's performant, and then (3) code that's clear.

I'm ambivalent about throwing AI at this codebase. It would definitely find issues and improve it, but I also want to keep the spirit of "Do It Yourself" and the feeling of "We built this and it works".

[1] Searched the quote from memory, Google found it here: https://transcript.baribarilab.com/video/HOv_dWDgIRM/

[2] https://guide.handmadehero.org/


Replies

MrMetric • today at 2:17 PM

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?

➕ show 1 reply