Live data from Hacker News

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

news.ycombinator.com

211–220 of 271 posts

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

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

With the sorry state of latex engine error messages and the version number still approximating pi, e, something, it is no longer an ideal to me. It represents stagnation. Being bug-free may be good, but at some point feature development is needed. (I know TeX and LaTeX are not the same)

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

#212

Earlier quoted context omitted.

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?

Two ways: keyboard layout and editor support.

Your OS keyboard layout, at least on Linux, can be customized to include any characters you type frequently. I haven’t gone very deep down this rabbit–hole, but I have turned on some options that make nice quotation marks (“‘«»’”), em–dashes (“–”), ellipses (“…”) and a number of other characters (“²³½⅓¼≠±÷∞×” and so on) readily available with a compose key. I also put arrows on the numberpad, of course (“↙↓↘←↔→↖↑↗⇙⇓⇘⇐⇔⇒⇖⇑⇗”). Very useful for talking about menu items, like File → Save As (it has actually startled people when I can type things like that fluently in conversation).

My editor of choice is Emacs, which has a built–in way to select characters by name. Typing `C-x 8 ` prompts for a character name, with fuzzy searching and autocompletion. It also recently gained a similar facility for Emoji, which is more focused around the visual appearance. `C-x 8 e e` opens it. `C-x 8 e s` lets you search by name.

Between your keyboard layout and your editor’s search capabilities and custom keybindings you can do anything.

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

#216

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.

You get CVE’s inside Django because it’s a large and widely used target, and because in Flask, FastAPI, etc. you end up implementing a lot more stuff yourself instead of using built in things. That doesn’t necessarily mean your code is more secure!

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

#217

Earlier quoted context omitted.

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.

The imports are chunk reuse. Each notebook is an es6 module you can import from any npm package.json You don't need to export it as documentation, it is executable documentation which is better, though you can print it if you want. The footer backs up the source to github

Your stuck on Knuth's definition of literate programming but this is better than that

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

#218
post #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.

I guess you’ll have to install an extra font or two.

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

#219

OpenBSD source code[1], because I think it represents good design. The code is as little as possible and easily understandable. [1] https://cvsweb.openbsd.org

I would always recommend the OpenBSD coreutils over the GNU coreutils as they are much cleaner and less hacky. To be fair many of the tricks being used in the GNU code make the code run much faster but they're not a great starting point for a casual code browse.
Post reply on HN