Live data from Hacker News

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

news.ycombinator.com

241–250 of 271 posts

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

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

TeX was beautiful. Both the algorithms (it was a masterwork on typesetting, still a good reference for anyone doing text layout) and the book.

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

#242

Earlier quoted context omitted.

I have shared this with Tanj. I had the privilege to work with him in Microsoft!

Awesome!! Would it be possible to release this bit of the library, if not the whole thing (for any definition you like of "whole thing") à la Movie Maker ( https://twitter.com/foone/status/1511808848729804803 )? More specifically there are two components to this question - it being OK for the code to be released, and the code itself being available to be released :). I'm specifically asking after the former; if noone…

Nice idea, but I honestly don't think it has much value for study. It was a solution to a problem which is no longer important, and what impressed David (and was fun for me) was implementing it under constraints (8086) that are no longer relevant. I would vote for some of the other stuff mentioned by others, like TeX as an example of mastery of both the application requirements with beautiful algorithms and inspirational documentation, PostgreSQL as a thriving large system with brilliant modularization that has enabled research, or LLVM as a pinnacle of code generation which has enabled a golden era of language and hardware design over the last 20 years.

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

#243
post #116

Surpised no one has mentioned the Nethack source, small codebase going on close to 40 years. https://github.com/NetHack/NetHack/tree/NetHack-3.7/src

Sorry but I just can't see the beauty in it. Most files are arbitrarily named, without an abstract or overview. Few functions have comments, variables names are inconsistent or abbreviated to obfuscation level. Most code seems printf hackery to account for singular-plural, male-female, human-monster variations of the messages shown to the player. Not particularly easy nor gratifying to read.

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

#245

Earlier quoted context omitted.

Using Unicode symbols wisely in mathematical code is a godsend. I regularly use Julia, which favors this style, and find that this feature improves the readability of code enormously.

How do you then type these characters? google, copy, paste? Or is there a better workflow?

[deleted]

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

#246
Perhaps not the "best" source code I've ever read, but libVF.io had some beautiful code for what's generally gnarly system-glue code.

The libVF.io iommu setup code is a good example and inspires me to think that system-glue code doesn't need to be gross or impenetrable: https://github.com/Arc-Compute/LibVF.IO/blob/master/src/libv...

Another one I've appreciated reading (and learned more about 2d graphics from) is Pixie, a 2d graphics library written in Nim. It's strongly affected how I write similar code.

Here's the implementation of a fair subset of SVG paths: https://github.com/treeform/pixie/blob/master/src/pixie/path...

And one last one for basic algorithms which I'd use to teach intro to data structures any day: https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/al...

Of course Knuth's original code is still some of the best classic code. K&R's original C book is a classic.

(edited formatting and tweak descriptions)

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

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

With the sorry state of latex engine error messages and the version number still approximating pi, e, something, it is no longer an ideal to me. It represents stagnation. Being bug-free may be good, but at some point feature development is needed. (I know TeX and LaTeX are not the same)

There are some serious legacy issues with the LaTeX ecosystem. The lack of being able to version individual package dependencies for a document is a huge one. You’re at the mercy of lots of independent packages which often have complex webs of interdependency.

Probably the biggest mistake was the choice to abandon the idea of having a LaTeX 3 version with its implicit breaking of backwards compatibility. Backwards compatibility means that there’s a tangle of fragility that only grows with time which is part of why the error messages are so frequently bad. Changes are a fraught proposition. This is part of what inspired my decision to start work on finl.

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

#250

Redis. After struggling with extending QBE I thought that was how C was written in general, but Redis restored my optimism.

Redis is the only C or C++ project that I happily read the source to. Though I haven't done that since @antirez stepped back from the project. I imagine the code is still excellent...
Post reply on HN