News for hackers. Stuff that matters.
Re:Ask HN: What's the most elegant piece of code you've seen? by afrancis on Sunday January 31, 2016 @05:07AM (#11005903)
It has been a while since I looked at it, but I was impressed by Russ Cox's implementation of channels in the LibThread library of Plan 9. All channel operations including blocking on several channels and selecting one that is ready, are described by Alt structures, which under the hood implement a simple but elegant algorithm that appears in Rob Pike's "The Implementation of Newsqueak." I feel you want to understand roughly how Go channels works, read that paper and look at LibThread's channel implementation.

A second choice would not be so much code, but an algorithm: Thompson constructions for regular expressions.

Re:Ask HN: What's the most elegant piece of code you've seen? by frou_dh on Wednesday February 03, 2016 @06:19PM (#11030724)
Yeah, the blocking select on multiple channels inside an infinite for { } struck me as the coolest construct in Go. It's like a little nerve centre.