Live data from Hacker News

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

news.ycombinator.com

221–230 of 271 posts

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

#221
post #181

Earlier quoted context omitted.

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.

The problem is (apparently) no monospace version of the /ʃ/ character, which renders fine in non-monospaced fonts (on Android).

yes in this font I can indeed see it on the same device :-D

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

#222
D3.js was a pleasure to read. Especially as a developer who was starting to get out of my junior phase and really understand what I was doing in terms of JS.

It’s a very simple code-base in many ways. At the time it was 10k lines of mostly short pure functions.

The code examples were also really nice and explained a lot about how to work with SVG.

I owe some Thanks to Mike Bostok and his fellow developers.

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

#223

Earlier quoted context omitted.

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…

Borland made some copies of Turbo C available for free. E.g. https://cc.embarcadero.com/item/26014

Some sites probably also have versions for download without the registration requirement

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

#224

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?

Julia mode for Emacs, Vim, and VSCode lets you to use LaTeX-like sequences: write \pm, press , and you get ±

Of course, this only works if your editor supports this and you are using a language similar to Julia. But there are two more general methods that are applicable everywhere. The first was mentioned by db48x: I have customized my Xmodmap file so that greek letters and a few typographic characters I use often can be typed using AltGr combinations. (Unfortunately, this is much more complicated if you use Windows.)

Secondly, I heavily use Espanso [1], so that I can easily type complicated letters/sequences (e.g., my email address) for which it would be too overkill to assign an AltGr keybinding.

Finally, in Emacs and Kitty (my terminal emulator) there is a keybinding that asks for the name of an Unicode symbol and enters it. (In Emacs it's C-x 8 , in Kitty Shift+Ctrl+u.)

From the point of view of my workflow, the problem of quickly typing Unicode characters is completely solved.

[1] https://espanso.org/

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

#225

Postgres code is very good, redis as well. Some of the core parts of Linux also totally worth learning from. I also remember how Qt UI code and docs were a revelation after the nightmare of win32 and related frameworks. Bellard's original Tinycc was very entertaining and took a while to digest. Most old and well-maintained projects are worth learning from. Apart from some local tips and tricks what is more important…

Redis, yes, even if you do not like/know C, that code is so clean that is readable/understandable by most programmers.

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

#227
post #191

Earlier quoted context omitted.

Speaking anecdotally, I have nothing but issues with LSP. It's a pain to use, a pain to configure, gives sub-par results and is usually wraps with extra "features" that change how code gets edited between different languages (I know this is less LSP's fault). Not to dismiss the mountain of work people have put into it, but it feels very hacked together and clunky rather than a shining achievement.

Case in point, Microsoft develops an editor (VSCode) and LSP so that N*M language integrations wouldn't be necessary. But in the development of their language (TypeScript), LSP support is not a priority (in part because LSP is inadequate in its current form): https://github.com/microsoft/TypeScript/issues/39459

> We're working on this, albeit slowly. tsserver's implementation predates LSP so it's nontrivial work to move forward in a way that doesn't adversely affect old clients or result in code duplication.

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

#228

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?

Some years back I wrote myself a small SublimeText extension to to pick & insert my favorite math characters but nowadays I prefer using rofimoji[0] because it is application-independent.

[0]: https://github.com/fdw/rofimoji

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

#229
post #78

Earlier quoted context omitted.

> I can't emphasize enough that this notion is only a side point in the story and not a main aspect of the plot Is it sprinkled throughout the story, or a mostly uninterrupted block of text? As in: is there an easily findable chunk of the book one could read for that idea alone? If so and you could provide a few keywords or a direct quote, I’d be interested in grabbing the book to read that.

I just went and glanced over the text by searching a pdf for a few key terms - no, it's really just sprinkled. The idea doesn't get much attention and is mostly mentioned in passing.

There is the bit where the story of Pham’s youth is told. He was third son of a King on a medieval–tech world (one with ancient stories of flying machines and long–distance communication devices) when some traders from a distant world landed. To everyone’s surprise they were human, and had expected this world to have a much higher technology level when they arrived. Pham’s dad did some kind of deal where his son Pham was given to the traders as an apprentice; even Pham didn’t know the details. Pham spent the next 20 years or so living on the ship because he refused to use the suspended–animation system (too coffin–like). He learned use use the many layers of emulation to use older and older programs, and eventually learned even trivial details. For example, he learned that the epoch of the time system used by the traders wasn’t actually the date of the first moon landing, but was a couple of years after that. He even hypothesized that over the millennia, many ship’s captains would have installed back doors in the system that might now never be rediscovered (which turns out to be foreshadowing :).

One funny detail I remember is a throw–away line where someone rapidly keys in “a column of text”. If you’re paying attention you can combine that with names like Pham, Vinh, Nau, and Qung Ho, the rarity of the red–headed gene, and the descriptions of some traders from the far end of human space you can reconstruct how things went after Humanity reached the stars.

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

#230

It’s not the best, far from it, but it was fascinating to me so I will share. I used to work for a large newspaper. Engineering wasn’t the focus of the business, it was only a means to an end, it was just something they needed to have a competitive website. As a result, the churn rate was very high. But more interesting there was also a very high return rate. Engineers would come and go and return and leave again all…

People here on HN have compared the evolution of large and old code base to the evolution of DNA before and I think it makes perfect sense: E.g., in both cases, complexity has grown organically over the years/millennia and logic tends to be spread out over dozens of files/genes; change one line of code/gene and suddenly it will impact lots of other things; et cetera.
Post reply on HN