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.
Ask HN: What's the best source code you've read?
201–210 of 271 posts
Re: Ask HN: What's the best source code you've read?
#202Peter Norvig's spell checker: https://norvig.com/spell-correct.html
Peter did done great ground work here and as things transitioned to neural nets, also peter appears randomly in my Chromecast with some nice photos he took lol
Re: Ask HN: What's the best source code you've read?
#203I haven’t read all of it, but the Principia source code has a comprehensive units system and makes effective use of Unicode: https://github.com/mockingbirdnest/Principia/ https://github.com/mockingbirdnest/Principia/blob/master/ast... is a decent example of both: // We compute the mean rate (slope) of the mean anomaly M(t), the mean // argument of latitude u(t), and the longitude of the ascending node Ω(t). … Product…
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.
Re: Ask HN: What's the best source code you've read?
#204Earlier quoted context omitted.
I second the nomination. I too have found the TeX Book to be very readable.
Pedantic note, which I'm writing just in case anyone misunderstands your recommendation: "The TeXbook" is the user manual for TeX. It is not the same thing as the book containing the (literate-program) source code for TeX, which is called "TeX: the program". (Both are excellent, but in quite different ways, and someone looking for interesting code to read would likely be disappointed by the TeXbook, which doesn't con…
Re: Ask HN: What's the best source code you've read?
#205Nobody 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…
> although sadly, literate programming seems all but dead now It seems alive and well in the data-science community to me. Look at jupyter notebooks if you aren't aware of what I am talking about.
Where significant parts of the display remain out of sync with said global state?
Re: Ask HN: What's the best source code you've read?
#206One 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.
Re: Ask HN: What's the best source code you've read?
#207I've never seen C code as clear and well documented as tcl. E.g. https://github.com/tcltk/tcl/blob/main/generic/tclUtil.c , though more examples in that project are not hard to find.
Re: Ask HN: What's the best source code you've read?
#208I was responsible for the Turbo C (later Borland C/C++) run-time library in the late 80s and early 90s. Tanj Bennett created our original 8087 floating point emulator. It was real mode, 16-bit code, that kept an 80-bit float in five 16-bit CPU registers as a working value during its internal math calculations. If you ever coded for the PC you will appreciate just how precious register space was on the 8086/8088. It's…
I have shared this with Tanj. I had the privilege to work with him in Microsoft!
Re: Ask HN: What's the best source code you've read?
#209Re: Ask HN: What's the best source code you've read?
#210It's a good way to document old hardware with emulation code.