Live data from Hacker News

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

news.ycombinator.com

121–130 of 271 posts

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

#121
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…

Back in the day I worked quite a bit with Knuth's early SAIL (an extended Algol on the PDP-10) implementation of Metafont. They could have used some of the documentation the later WEB versions had as he tended to get tricky with squeezing everything out of the 36-bit words (which I was porting to a 32-bit word machine). But the code was an education and a joy to read well before he polished it for publication.

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

#122
post #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.

Yeah! The low line count for the code makes it all that more comprehendible compared to Compvis/stable-diffusion or huggingfaces/diffuser's code.

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

#123
post #79
post #26

Earlier quoted context omitted.

That's from "The mythical man-month". Old, and some parts are obsolete, but still worth a read as it does have a bunch of good insights.

I have not read it in a while but it would be interesting to debate what essays are no longer relevant. I'll be grabbing it off the shelf next to my original copy of the Byte issue on C mentioned yesterday and having a look for expired relevancy.

I haven't read it in a while either, but from memory the team organization of one "architect" and a bunch of implementers seems obsolete, for example.

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

#124
Ok just to come at this from another angle: my own (embedded C) code, after it had been gone over by a much more experienced and skilled maintenance programmer to bring it up to company standards. It wasn’t beautiful, even then, but it was crisp, super readable, and ironically closer to how I remembered it than the original. He hesitated to show it to me! Programmer ego and tact are funny things. Humbling, sure, but on the whole I was delighted.

The best - it compiled to the sane hex file.

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

#125

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…

+1 for redis, first code I read that felt like artisan craftsmanship, approaching art.

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

#126
post #27

I quite like the FreeBSD src tree, as it comprises both the system kernel as well as the userland applications. The folders are organized similarly to the OS file system hierarchy, which I find helpful for navigating the source tree. I found it accessible to slowly learn how various parts of the OS work under the hood and compound my knowledge faster due to less context shifting, since it’s self-contained in one sour…

Tangentially related, I found The Design and Implementation of the 4.4 BSD Operating System fascinating back in the day. I don't know how well it holds up now (or more importantly how relevant it is) but it was genuinely interesting, especially as I was using FreeBSD at the time.

https://dl.acm.org/doi/10.5555/231070

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

#127

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…

Seconding redis, and noting that the original redis source code is _also_ an interesting read and demonstrates how approachable well-written tcl is, even for those entirely unfamiliar with it as a language: https://gist.github.com/antirez/6ca04dd191bdb82aad9fb241013e...

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

#130
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…

Back in the day I worked quite a bit with Knuth's early SAIL (an extended Algol on the PDP-10) implementation of Metafont. They could have used some of the documentation the later WEB versions had as he tended to get tricky with squeezing everything out of the 36-bit words (which I was porting to a 32-bit word machine). But the code was an education and a joy to read well before he polished it for publication.

I’ve heard some wild things about the old SAIL stuff. I never had the chance to encounter it though. I got on the TeX train in 1985¹ with TeX82/MF84. AMS/TUG still were using the am* fonts for their publications.

1. My very first exposure was DEK’s article “TeX and Metafont” in a copy of Dr Dobb’s Journal that was part of a trove my brothers got a hold of—and then in 1984 seeing someone in the IIT computer lab paging through a copy of The TeXbook, so when I found out that UIC had just installed TeX on their mainframe, I was one of the first people to use it there.

Post reply on HN