Ask HN: What's the most elegant piece of code you've seen?

  • Anything I have ever written, until I've re-read it.

  • A wonderfully Go-like piece of magic: https://github.com/golang/go/blob/go1/src/pkg/image/gif/read...

    What's magic there seemed magical at the time because even Go's creators were only just coming to see the power of interfaces then. Now, having a decompressor read from a block reader, which reads in turn from some other place, is not magical, it's just good practice.

    This is from Go 1. Unfortunately, that file accumulated tons of other ugliness over time, as it dealt with the real world. I was one of the people who had to make that line less magic. Sorry Rob.

  • A little dated, but tornado always impressed me:

    https://github.com/tornadoweb/tornado

    Also Norvig’s spell checker:

    https://norvig.com/spell-correct.html

  • Some of my fav. works include

    Bittorrent and Bitcoin

  • The Lambda Calculus. Invented in the 1930s it is still used today as the basis for most advanced CS research and as the foundation of many programming languages.

  • cat /var/log/apache2/access.log | awk '!a[$0]++'

  • I am surprised no one mentioned chatGPT or GPT-3

  • Redis source often gets mentioned in these threads.