Live data from Hacker News

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

news.ycombinator.com

101–110 of 271 posts

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

#101
My favourite is SerenityOS: https://github.com/SerenityOS/serenity

Not only is the code itself structured much more pleasantly than I ever suspected possible in C++, huge parts of it were also recorded while they were being written (see https://www.youtube.com/c/AndreasKling) so you can see and hear the process that led to the final product.

Some of the code is quite gnarly, which is to be expected from a repo containing an entire operating system, containing everything from the kernel to a bespoke web browser.

However, as SerenityOS isn't trying to be a UNIX clone, its C++ oriented APIs are a nice breath of fresh air compared to the barebones C that Linux and friends use.

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

#103

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 da…

Was this [0] the podcast by chance? Seems to fit the bill. [0]: http://bsdtalk.blogspot.com/2006/10/bsdtalk072-interview-wit...

That’s the one I’m sure

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

#104

I will always have a soft spot in my heart for Django, the python web framework, even though I don’t use it anymore. https://www.djangoproject.com/ When I was still learning to code, I spent hours and hours and hours poking around the Django source code. In particular I was fascinated by the metaprogramming used in the Model and Query objects, and I ended up learning a ton about how Python works under the hood.

I feel much the same about django rest framework

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

#106
I don't know if it was the best, but one of the codebases that really helped me out in the mid-90s was XEmacs. It was portable to many kinds of systems and had lots of features that most applications never have to worry about (e.g., an embedded interpreter). I also got value out of GNU Emacs but XEmacs tried harder to be a good citizen on the X desktop and there were lots of lessons learned in there that I was able to leverage for the applications I was building at the time.

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

#107
post #89
post #28

Earlier quoted context omitted.

You might be interested in reading the paper, No Silver Bullet, in which Fred Brooks coined these terms: http://worrydream.com/refs/Brooks-NoSilverBullet.pdf

Didn't he copy them from Aristotle?

The idea of essence and accident comes from Aristotle, while essential and accidental complexity is new by Brooks.

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

#108
post #41
post #37

The early Go standard library (before it was hyper-optimized.)

That's a fascinating observation. Do you think code inherently gets "worse" as it becomes more "optimised"?

If you plot difficulty to read against optimization, I'd expect to find a u-shape relation between the two.

When code is easy to read, it's easy to find and clean up redundant operations, which naturally makes it faster.

On the other end there's some optimizations that require dealing with lower abstraction levels and additional special cases.

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

#109

Postgres code is very good, redis as well. Some of the core parts of Linux also totally worth learning from. I also remember how Qt UI code and docs were a revelation after the nightmare of win32 and related frameworks. Bellard's original Tinycc was very entertaining and took a while to digest. Most old and well-maintained projects are worth learning from. Apart from some local tips and tricks what is more important…

Which part of linux core? I’ve been wanting to but I don’t know how/where to start

I enjoyed reading the VFS layer down into the NFS client file ops and then the RPCs created from them. (skip the RPC state machine)

An easier entry point might be the ethtool_ops in an earlier Intel network driver like e1000.

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

#110

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 t…

> the Perl core modules

Likewise I've head good things about the Python standard library; I suspect this works for many languages.

Post reply on HN