Live data from Hacker News

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

news.ycombinator.com

181–190 of 271 posts

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

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

lovely. it's 2022 and I see unknown-glyph-boxes on my up to date smartphone...

I love the use of mathematical glyphs in math code, too, much more readable, _if_ it's readable.

sigh.

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

#182

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.

SQLite originates from the same author and is hosted in fossy which is similarly concise and beautiful.

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

#184

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!

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

#185
The one that I didn't have to read.

A mistake i see many engineers commit is obsess over their code and how "pretty" it is. What they seem to forget is that code is only read when it isn't doing what it's supposed to do. Granted when you do have to read it there are good and bad examples, but the question you should ask yourself is not "how can I make this code easier to read?" But "how can I make sure noone has to read this code". The code that performs this job is not always pretty. If it is impossible to make the code bulletproof then the best bet is usually to just make it really simple. Good code is nonexistent and if it has to exist it is boring.

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

#187
Since TeX and LLVM were already mentioned, I will casually mention the comments in Laravel's codebase which are all three lines long with each line exactly three characters shorter than the previous line. The art of computer programming at work.

Example (config file, but the entire codebase is like that): https://imgur.com/UnIUZmZ

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

#188

Earlier quoted context omitted.

It’s not really literate programming. It’s just editable/executable code intertwined with text. There’s no tangle and weave, or code reuse.

What about this https://observablehq.com/@tomlarkworthy/redis-backend-1

The same thing. I don’t see chunk reuse, nor the ability to generate standalone documentation or export the code to files.

Have you seen actual literate programming documents? The Noweb tool’s page has examples.

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

#189

Since TeX and LLVM were already mentioned, I will casually mention the comments in Laravel's codebase which are all three lines long with each line exactly three characters shorter than the previous line. The art of computer programming at work. Example (config file, but the entire codebase is like that): https://imgur.com/UnIUZmZ

Honestly...neurotic and counterproductive. You have to add too much useless words to make it fit. Most of these comments could be much shorter and easier to read. Also too much separators and whitespace around those comments.

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

#190

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!

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 knows where the code actually is right now, well, it can be dug out later.

Post reply on HN