Live data from Hacker News

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

news.ycombinator.com

201–210 of 271 posts

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

#201

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.

The stdlib is pretty impressive because you see stuff that at first glance looks like there's an obvious simpler way, but then notice the edge case their way handles or the extra thing it enables, and it's clear that it's all been polished over time.

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

#202
post #8

Peter Norvig's spell checker: https://norvig.com/spell-correct.html

Nice example, note to do autocomplete with something neural based these days like https://text-generator.io or huggingface or spelling with neuspell etc

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?

#203
post #71

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

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

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

#204
post #154
post #88

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

You’re right! I had to go pull my copy off the shelf and check, but it really is TeX: The Program.

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

#205
post #175
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…

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

You mean a system with heavy dependence on global state yet allowing for arbitrary command/code chunk execution order?

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?

#206
post #9

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

Really? Go and read the assembly parser and get back to me.

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

#207

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

Kind of ironic given how bad TCL itself is. Reminds me a bit of the CMake source code which is nicely written and easy to follow but... it's CMake.

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

#208

I 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!

You just have to love HN, thank you!

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

#209
I found the RetroArch source (https://github.com/libretro/RetroArch) very accessible, when I added a simple title sanitisation it was easy to figure out what I had to change and where the changes needed to be. The accessibility of the source was particularly helpful as it was the first non-trivial C code I had come in contact with.
Post reply on HN