Live data from Hacker News

Ask HN: What's the best source code you've read?

news.ycombinator.com

61–70 of 271 posts

Re: Ask HN: What's the best source code you've read?

#61
I thought I wrote good Perl code until I read the Perl core modules. Like night and day.

Busybox and uClibc are great examples of efficient C code. I submitted a feature, and they basically rewrote it to be less crap, and that taught me a ton.

Hard to know what good Python code is. Everyone seems to use some framework that fundamentally changes how you write apps. "best source code" is probably just what's best for that specific kind of work.

Re: Ask HN: What's the best source code you've read?

#63
post #9

One of the most surprisingly clear code bases is LLVM. It’s an old complex beast, yet it’s organized beautifully. I mean, it has a lot of essential complexity but little accidental complexity. That’s usually what I strive for when coding. Complexity is sometimes unavoidable, that’s fine, that’s why it’s essential. However, avoidable complexity should be… well… avoided.

Quoted post unavailable.

No post body was provided.

Re: Ask HN: What's the best source code you've read?

#64
post #50

Earlier quoted context omitted.

Quoted post unavailable.

Why? If you don't mind me asking.

Rust is the only language out of those hyped that actually made me excited because it brings interesting features.

Additionally out of the box you have one cli with compiler, package management, etc. instead of 30 choices to pick from

C++ for me is just: terrible compilation times, 17 ways to achieve one goal, not strong ecosystem

Generally not the nicest developer experience in compare to e.g C# or apparently Rust.

I'd feel more motivated to jump into LLVM code base it that was written in Rust because I don't think C++ is the future - which is sad, because C++ has a lot of cool jobs now.

Re: Ask HN: What's the best source code you've read?

#66
Since diving into stable diffusion, I found the original code not very well organized not factored.

Then trying and looking at https://github.com/geohot/tinygrad which can implement SD, it’s really well written and ideas well organized, concise, and it works on multiple platforms well.

Re: Ask HN: What's the best source code you've read?

#67
I had quite some pleasure working with the Source Engine gameplay code. (Some 10 years ago now)

https://github.com/ValveSoftware/source-sdk-2013

It is not that the quality of the code is high, but just that it is well organized, and everything seems like it was written by a beginner. That makes it wonderfully easy to read and follow the logic.

Since have played around with the Source Engine, I follow the KISS principle with coding with high priority. Rarely trying to be clever, or try to over-do abstractions.

Re: Ask HN: What's the best source code you've read?

#68
Poul-Henning Kamp was on a FreeBSD podcast (~15 years ago) and did an approachable walkthrough of the performance considerations he made when he created varnish. It stoked some serious curiosity in me, i was working on a system that heavily cached IO in userspace (and paid LOTS of money to do so - we're talking 100s of nodes) and here he was saying things like (i'm paraphrasing here) it's pretty dumb to cache your data from disk in userspace. One thing led to another and i scored a nice bonus that year. By the end of that year i had learned about (and put to good use) techniques like IRQ pinning and of course understanding the caching tunables in the linux VFS layer. I can't find the podcast to link to but this document is pretty much on the money for what i remember hearing https://varnish-cache.org/docs/trunk/phk/notes.html

Another one is the Postfix codebase by Wietse Venema. It was notable because it's basically had the square root of 0 vulnerabilities despite being written in C and being one of, if not the most popularly deployed MTAs in the world (so basically a constant target for hack attempts - contemporary products like Exchange were basically a laughing stock for vulns in that time period). Anyway, the architecture of that codebase is bordering on beautiful. It's a total goldmine.

Bonus - a popular code base that made my eyes bleed, nginx. I think it's basically been re-written today but the earliest versions of it were horrible to read. It was fast back then but it was like some sick twisted joke of how to write code. This is not to take away from whoever created it, they still created a monumental shockwave when they released nginx, it was far more performant that anything else.

Re: Ask HN: What's the best source code you've read?

#70
I'm probably biased, but I particularly enjoyed going through mpv - https://github.com/mpv-player/mpv

I always found much of the FFmpeg API very unintuitive and much of what I now know about it I learned from reading through mpv. Hardware accelerated encode/decode, etc.

Post reply on HN