Ask HN: What's the best source code you've read?
261–270 of 271 posts
Re: Ask HN: What's the best source code you've read?
#262The 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 r…
Re: Ask HN: What's the best source code you've read?
#263Earlier quoted context omitted.
For Angular, I think the “problem” lies in the level of abstraction. AngularJS was a “Spring / Java” answer to web applications with Angular following the paradigm but introducing reactivity to the system. Not “wrong” per-se, the quality of code is great and so I could recommend it at a tactical level of “good code” but at the strategic it feels off.
> but at the strategic it feels off. The problem with a reactive layout is that, if you're not going to just ask the user how they want to display things, you need to both read their mind and get it right 100% of the time. Nobody can do that, so your web site shifts into mobile mode when I only give it half of my 3' display.
Re: Ask HN: What's the best source code you've read?
#264Since 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?
#265Re: Ask HN: What's the best source code you've read?
#266That compiler served as the blueprint for Borland tools.
philippe@fullpower.com
Re: Ask HN: What's the best source code you've read?
#267I 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…
Hi David, thanks for the kind words. I still have the source for that I think, it was written around 1984 originally for a project of my own, then sold to Logitech, Zorland, and Borland (before I went to work for Borland). The Borland one was probably tweaked a bit - like you my memory does not include details. There were 7 registers to play with. AX, BX, CX, DX, SI, DI, and occasionally BP. MS-DOS had no rules about…
Re: Ask HN: What's the best source code you've read?
#268my choice would-be Professor Niklaus Wirth’s source code for “Tiny Pascal” in his seminal book “ Algorithms + Datastructures = Programs.” Here is a link: https://en.m.wikipedia.org/wiki/Algorithms_%2B_Data_Structur... That compiler served as the blueprint for Borland tools. philippe@fullpower.com
> That compiler served as the blueprint for Borland tools.
When I was disassembling Turbo Pascal more than 20 years ago, I saw the similarities between the two, especially the scanner and parser where pretty much in line with the source code of Niklaus Wirth [1]. Even some of the global variables were the same. Back then I figured that since the source code of Niklaus Wirth was originally in Pascal, Anders Hejlsberg was actually "the Pascal Compiler" for the z80 (and later x86) translating the Pascal source into assembly. For me it seemed that Anders had a very good hand for register allocation, I remember the disassembly of Turbo Pascal was full of tricks, simply fantastic and elegant!
Here is one version Niklaus Wirth Pascal Compiler: [1] https://www.cs.hs-rm.de/~weber/comp/pascals3.html
Re: Ask HN: What's the best source code you've read?
#269Yes, you are right. It is empty. The best code there is - is the code you did not had to write. It have no bugs, no latency. I am not being sarcastic here. I truly think that less code is better.
Re: Ask HN: What's the best source code you've read?
#270Surpised 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.