Live data from Hacker News

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

news.ycombinator.com

161–170 of 271 posts

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

#161
This might be pretty controversial, but the Chromium source code has been a pleasure to work with for a few years. I was working on a proprietary fork of Electron and it was a delight to work with that code base vs some of the in house code I integrated into it. The web code search was also awesome to use.

https://cs.chromium.org/

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

#162
post #46

Earlier quoted context omitted.

The 7th circle of hell is my own from 3 months ago. I can't even blame someone else for the tragedy.

I think my code is regressing: C++ from 14 years ago: https://github.com/vlofgren/tunguska/blob/master/tunguska_3c... A career of Java development later, and the code I wrote yesterday looks like this: https://git.marginalia.nu/marginalia/marginalia.nu/src/commi... My old code was so tidy. Can't believe I wrote code like that. Although back then I think I mostly used vim. Not having any sort of IDE tooling does sort…

The last "take the time that you need, as long as it's bulletproof" job I had was in the late 90's. The concept of sprints introduced a drumbeat that precludes solid engineering, imho.

> Not having any sort of IDE tooling does sort of tend to force you to be a lot clearer about what you do.

True, but then I wouldn't be able to play whack-a-mole with pointer symbols during weird code-pairing exercises.

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

#163
Eye-opening but probably not "best": the Nullsoft Installer, circa 2002 (https://github.com/kichik/nsis). Its goal, besides being an installer, was to produce a small binary. So the source was remarkably pithy, which taught me a lot about being direct and to-the-point rather than aiming for beautiful abstractions or reusability.

Similar with Notch's Left4KDead, which implemented a fun zombie game for a Java small-code competition. A mirror of the original source is here (https://github.com/codingcampbell/Left-4k-Dead). I rewrote it in JavaScript as a Chrome App, in the process refactoring for readability (and sacrificing some of the code's beauty). https://github.com/sowbug/ChromeLeft4kDead

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

#164

I will always have a soft spot in my heart for Django, the python web framework, even though I don’t use it anymore. https://www.djangoproject.com/ When I was still learning to code, I spent hours and hours and hours poking around the Django source code. In particular I was fascinated by the metaprogramming used in the Model and Query objects, and I ended up learning a ton about how Python works under the hood.

Me but with Flask and its cohorts like Werkzeug. I always found the amount of security advisories with Django vs that to be something alarming. I might still use it once in a while for something like prototyping.

Python is easy to write but writing it "right", in a way that doesn't compromise performance, is a thing.

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

#165
post #161

This might be pretty controversial, but the Chromium source code has been a pleasure to work with for a few years. I was working on a proprietary fork of Electron and it was a delight to work with that code base vs some of the in house code I integrated into it. The web code search was also awesome to use. https://cs.chromium.org/

Why is that controversial? Chromium is often cited as a well-written large codebase.

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

#166

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…

> I thought I wrote good Perl code until I read the Perl core modules. Like night and day.

For some reason the 2nd and subsequent editions of the O'Reilly Perl book completely altered the layout and presentation that Larry Wall had set up. The first edition of Programming Perl is the most *lucid* programming book I've ever read.

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

#167
post #165
post #161

This might be pretty controversial, but the Chromium source code has been a pleasure to work with for a few years. I was working on a proprietary fork of Electron and it was a delight to work with that code base vs some of the in house code I integrated into it. The web code search was also awesome to use. https://cs.chromium.org/

Why is that controversial? Chromium is often cited as a well-written large codebase.

A lot of other examples given in other comments are quite the opposite. Clever code in long functions with single character variable names. Chromium shines in consistent naming, structure without much overelaborate uses of design patterns and general aim for maintainability and readability. I'm not saying there aren't those things in Chromium too (I've seen them), but they are well contained.

I've also seen a talk at CppCon (2019 I think) that spoke somewhat negatively about the code base. Can't find the reference, sorry.

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

#168

I will always have a soft spot in my heart for Django, the python web framework, even though I don’t use it anymore. https://www.djangoproject.com/ When I was still learning to code, I spent hours and hours and hours poking around the Django source code. In particular I was fascinated by the metaprogramming used in the Model and Query objects, and I ended up learning a ton about how Python works under the hood.

https://github.com/django/django Django's codebase is a pleasure to read. The directory structure is intuitive to navigate, and test coverage is great.

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

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

I've been writing a literate multi-file program in Go and Copilot has been partially compensating for the lack of tooling support, especially since Copilot can infer from prose.

I intend to make a post about my experience.

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

#170

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 would have loved to read that code!
Post reply on HN