Back to front pageView on Hacker News (opens in a new tab)Ask HN: What is the most beautiful piece of code you've ever read?476 pointsby seisvelas (on Hacker News)7 years agoPreferably an elegant snippet rather than an entire (well engineered) codebase.Comments (380) 116 threadsShow all commentsShowing thread 24 of 116[-]yakshaving_jgt7 years ago1 reply#If you create an executable file with the following contents, and run it, it will delete itself. #!/bin/rm[-]Iwan-Zotow7 years ago1 reply#There is a better example - original /bin/true source. Presented to you below.nidificate7 years ago#Compare that with the version in GNU Coreutils[1] that is 50+ lines long so that false[2] can be written as:#define EXIT_STATUS EXIT_FAILURE#include "true.c"[1] https://github.com/coreutils/coreutils/blob/master/src/true....[2] https://github.com/coreutils/coreutils/blob/master/src/false...
Ask HN: What is the most beautiful piece of code you've ever read?476 pointsby seisvelas (on Hacker News)7 years ago
yakshaving_jgt7 years ago1 reply#If you create an executable file with the following contents, and run it, it will delete itself. #!/bin/rm
Iwan-Zotow7 years ago1 reply#There is a better example - original /bin/true source. Presented to you below.
nidificate7 years ago#Compare that with the version in GNU Coreutils[1] that is 50+ lines long so that false[2] can be written as:#define EXIT_STATUS EXIT_FAILURE#include "true.c"[1] https://github.com/coreutils/coreutils/blob/master/src/true....[2] https://github.com/coreutils/coreutils/blob/master/src/false...
Comments (380) 116 threads
Show all comments
Showing thread 24 of 116
#define EXIT_STATUS EXIT_FAILURE
#include "true.c"
[1] https://github.com/coreutils/coreutils/blob/master/src/true....
[2] https://github.com/coreutils/coreutils/blob/master/src/false...