Live data from Hacker News

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

news.ycombinator.com

81–90 of 271 posts

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

#81

It’s not the best, far from it, but it was fascinating to me so I will share. I used to work for a large newspaper. Engineering wasn’t the focus of the business, it was only a means to an end, it was just something they needed to have a competitive website. As a result, the churn rate was very high. But more interesting there was also a very high return rate. Engineers would come and go and return and leave again all…

The book "A Deepness in the Sky" features people living on an ship whose operating system is thousands of years old. One of the main characters is considered a software archaeologist of sorts - he's an engineer, but in a sense also a historical researcher. I can't emphasize enough that this notion is only a side point in the story and not a main aspect of the plot, sadly, so I wouldn't go reading it in hopes of heari…

Interesting to note that you’re basically describing the concept of common law.

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

#82
post #46

My own - hell is other people’s code.

The 7th circle of hell is my own from 3 months ago. I can't even blame someone else for the tragedy.

I think my code is regressing:

C++ from 14 years ago:

https://github.com/vlofgren/tunguska/blob/master/tunguska_3c...

A career of Java development later, and the code I wrote yesterday looks like this:

https://git.marginalia.nu/marginalia/marginalia.nu/src/commi...

My old code was so tidy. Can't believe I wrote code like that. Although back then I think I mostly used vim. Not having any sort of IDE tooling does sort of tend to force you to be a lot clearer about what you do.

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

#83
Idk about the best, but, this[1] implementation of hierarchical state machines is beautiful. It uses a few different template metaprogramming tricks to resolve state transitions at compile time! It's truly beautiful.

[1] https://accu.org/journals/overload/12/64/heinzmann_252/

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

#84

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...

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

#85

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

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

#88
post #56

Nobody has mentioned Knuth’s corpus of work in Pascal-Web for the TeX ecosystem. This is code written for an era where there wasn’t an ecosystem of libraries for common tasks and even things like being able to access a file in random access order couldn’t be counted on. Even 7-bit ASCII couldn’t be counted on as a given (EBCDIC-based IBM mainframes were a significant element of the computing landscape still). Against…

I second the nomination. I too have found the TeX Book to be very readable.

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

#89
post #28

Earlier quoted context omitted.

> a lot of essential complexity but little accidental complexity Nice one. I'll copy that.

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?

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

#90

Bitcoin

That’s absolutely not true.

Bitcoin the app is often mixing several layers of abstractions and several usage patterns together.

Is it for actually keeping track of money? Is it for APIs? is it for end users, or for servers? Is it CLI or a GUI app?

And it’s in C++, which is almost never readable.

And of course they have their weird names for everything (all the ScriptSigs etc), and the OP script which is at the same time too complex and too simple.

It’s surprisingly robust and it survived a lot, sure; I don’t take it down on that level; but the code even today got baggage of all the weird decisions Satoshi did when he made it.

It’s really not “good code” IMO.

Although they have improved it a lot in last few years, I will give them that. It was worse…

Post reply on HN