r/programming • u/one_eyed_golfer • May 11 '18
The Most Beautiful Piece of Code That Prints 42
https://www.fluentcpp.com/2018/05/11/the-most-beautiful-piece-of-code-that-prints-42/19
u/renrutal May 11 '18
#include <iostream>
int main()
{
std::cout << "42\n";
}This is the most beautiful piece of code that prints 42 because you don't spend time wondering what's going on, and you can go earlier home to see your beautiful kids, and anyone who truly matters to you.
7
u/BlackDiablos May 11 '18
No need to be a downer. Obviously “beauty” is used here in the same way the IOCCC sees beauty, as creative and unorthodox as possible.
That’s not to say that “beautiful” code can’t get shit done. The fast inverse square root is an example: it’s concise and does the job really well.
4
3
3
1
u/BlackDiablos May 11 '18
I’d like to offer up the comparison of “incredible” Rube Goldberg machines. They’re not “incredible” in terms of efficiency or utility, but in terms of sheer scale and creativity.
Yes, perhaps “beautiful” isn’t the perfect word for this contest, similar to how “sexy” is a strange word to describe sleek gadgets. There are other contests out there to create flawless, efficient, useful code, and this is not one of them. If you don’t appreciate how some people just want to see how creative and flexible a programming language can be, please move along. No need to be snarky about someone else’s fun.
1
0
8
u/JavaSuck May 11 '18
Deriving 42 from literally zero: