Live data from Hacker News

Ask HN: What is the most beautiful piece of code you've ever read?

news.ycombinator.com

11–20 of 394 posts

Re: Ask HN: What is the most beautiful piece of code you've ever read?

#12
post #6

For me, the answer is - The code that never existed. Not to sound cheeky but eliminating code, is a beautiful thing. Less code is easier to maintain, understand, and faster to run. So the less code you can achieve, the better overall the software will be.

Deleting code is a beautiful feeling. Python's new walrus operator has gotten a lot of hate recently, but a few days ago I was writing a script and realized I could get rid of a few lines (AND have my meaning be clearer) using the walrus operator. So satisfying.

Re: Ask HN: What is the most beautiful piece of code you've ever read?

#13
post #8

As a student in 2001, Tim Sweeney's template recursive inheritance was next level for me: https://www.flipcode.com/archives/Vector_Math_Quaternions.sh... About 10 years later you would find this stuff everywhere in boost but for the time this was spectacularly elegant for C++

[deleted]

Re: Ask HN: What is the most beautiful piece of code you've ever read?

#15
post #10

10 print "Hello World"; 20 goto 10; run

My first language was QBASIC and much of the first code I read (other than modifying PHP scripts I didn't really understand) was from Pete's QB Site. I'd hardly call it beautiful, but definitely nostalgic and cool.

Re: Ask HN: What is the most beautiful piece of code you've ever read?

#16
The SQLite source tree and DRH code in general are truly piece of art. Almost every line of code is carefully commented. Despite the complexity of the project, you'll learn a lot of practical concepts including expression tree generation, bytecode execution, how to test your code and so forth.

Re: Ask HN: What is the most beautiful piece of code you've ever read?

#17
post #9

It's a bit of a tricky question because you can have a beautiful snippet entangled in a mess of a codebase. I think a much better question would be most beautifully structured codebase. Code, as a snippet, or line, is constantly struggling between poetic conciseness and verbose clarity... To which I will always pick clarity (for "the next guy"), hence not necessarily elegant.

> I think a much better question would be most beautifully structured codebase.

That would be an interesting thread too! I think gorgeous snippets have a different kind of beauty that just generally well done projects.

To me, it's kind of like comparing the beauty of a gem to the beauty of a bridge.

Re: Ask HN: What is the most beautiful piece of code you've ever read?

#20
post #7

John Carmack's Fast Inverse Square Root: https://en.wikipedia.org/wiki/Fast_inverse_square_root#Overv... . The first time I really and truly felt that people approach problems differently from how I, by default, go about them.

This is still one of my favorites. In a list of magic numbers, sorted by magic-ness, 0x5F3759DF would sit pretty high.
Post reply on HN