Best Comments in Source Code Ever
This article lists some of the best comments ever encountered in source code taken from a very famous StackOverflow thread. The question was asked in 2008 and gained immense popularity, but it was pulled from the site by some moderator with a misplaced sense of abidance by rules. However, it has been made public again (in locked mode) due to popular demand.
|
1 2 |
// When I wrote this, only God and I understood what I was doing // Now, God only knows |
|
1 2 3 4 5 6 7 8 |
/* * For the brave souls who get this far: You are the chosen ones, * the valiant knights of programming who toil away, without rest, * fixing our most awful code. To you, true saviors, kings of men, * I say this: never gonna give you up, never gonna let you down, * never gonna run around and desert you. Never gonna make you cry, * never gonna say goodbye. Never gonna tell a lie and hurt you. */ |
|
1 2 3 |
// I dedicate all this code, all my work, to my wife, Darlene, who will // have to support me and our three children and the dog once it gets // released into the public. |
|
1 2 3 4 5 6 7 8 9 10 |
/* * Dear maintainer: * * Once you are done trying to 'optimize' this routine, * and have realized what a terrible mistake that was, * please increment the following counter as a warning * to the next guy: * * total_hours_wasted_here = 42 */ |
|
1 2 3 4 5 6 7 8 |
/* * You may think you know what the following code does. * But you dont. Trust me. * Fiddle with it, and youll spend many a sleepless * night cursing the moment you thought youd be clever * enough to "optimize" the code below. * Now close this file and go play with something else. */ |
|
1 2 3 |
Catch (Exception e) { // who cares? } |
|
1 2 3 4 |
# To understand recursion, see the bottom of this file At the bottom of the file: # To understand recursion, see the top of this file |
|
1 |
/* You are not meant to understand this */ |
From the 2004 Windows leak,
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
__inline BOOL SearchOneDirectory( IN LPSTR Directory, IN LPSTR FileToFind, IN LPSTR SourceFullName, IN LPSTR SourceFilePart, OUT PBOOL FoundInTree ) { // // This was way too slow. Just say we didn't find the file. // *FoundInTree = FALSE; return(TRUE); } |
|
1 2 |
// If you're reading this, that means you have been put in charge of my // previous project. I am so, so sorry for you. God speed. |
|
1 |
// Remove this if you wanna be fired |
|
1 |
// For the sins I am about to commit, may James Gosling forgive me |
|
1 2 3 4 5 6 7 8 9 |
// Constructs a tuple with 2 elements (fucking idiot, use std::pair instead!) template <typename T0,typename T1> inline tuple <T0,T1> make_tuple (const T0& t0, const T1& t1) { tuple <T0,T1> t; t.get<0>() = t0; t.get<1>() = t1; return t; } |
|
1 2 |
Exception up = new Exception("Something is really wrong."); throw up; // ha ha |
|
1 |
// Autogenerated, do not edit. All changes will be undone. |
|
1 2 3 4 5 6 |
// // 3.4 JeK My manager promised me a lap dance if I can fix this release // 3.5 JeK Still waiting for that dance from my manager // 3.6 JeK My manager got changed, the new manager is hairy, dont want the dance anymore // 3.7 Jek Got that dance, yuck! // |
|
1 |
// sometimes I believe compiler ignores all my comments |
|
1 |
// drunk, fix later |
|
1 |
// Abandon all hope ye who enter beyond this point |
|
1 |
// Below code will make compiler blush |
|
1 2 |
// Dear future me. Please forgive me. // I can't even begin to express how sorry I am. |
|
1 |
// Magic. Do not touch. |
|
1 |
/* Please work */ |
|
1 2 |
#define TRUE FALSE // Happy debugging suckers |
This is followed by four nested for-loops
|
1 |
/* This is O(scary), but seems quick enough in practice. */ |
|
1 |
// I am not sure if we need this, but too scared to delete. |
|
1 |
// I am not sure why this works but it fixes the problem. |
|
1 |
// Catching exceptions is for communists |
|
1 |
// THIS PROGRAM HAS CODE THAT DOES NOT MEET STANDARDS |
|
1 |
// If you're reading this, then my program is probably a success |
|
1 |
// This code worked before, but my cat decided to take a trip across my keyboard... |
|
1 |
long long ago; /* in a galaxy far far away */ |
|
1 |
/////////////////////////////////////// this is a well commented line |
|
1 |
double penetration; // ouch |
|
1 |
long john; // silver |
From source code of some chinese website,
|
1 2 3 |
// The company pays no bonus - forgot about it dude. Don't come! // I'm ready to leave. This project contains huge amount of "bugs", // you won't stand long. Bye, best luck! |
|
1 2 3 |
// This is black magic // from some stackoverflow link // Don't play with magic, it can BITE. |
|
1 2 |
/* My compiler does anything i ask for. Wanna see ? Dear compiler, Please ignore this statement. */ |
|
1 |
using namespace std; /* So Sue me for this ;) */ |
|
1 |
/* If this code works then Paul wrote this otherwise, I don’t know who wrote this. */ |
|
1 2 3 4 5 |
/* Well this method surely returns the random number. Chosen by a fairly rolen dice. */ int getRandom() { return 4; } |
|
1 2 3 4 5 |
try { } catch (SQLException ex) { // Basically, without saying too much, you’re screwed. Royally and totally. } |
|
1 |
// I can’t even begin to express how sorry I am. |
|
1 |
// I'm not paid for this... |
|
1 2 |
// I am not responsible of this code. // They made me write it, against my will. |
|
1 2 3 4 5 6 |
/* * * Always returns true. */ public boolean isAvailable() { return false; } |
|
1 |
virgin = 0; /* you're not a virgin anymore, sweety */ |
|
1 |
// $you = live("free") or die("hard"); |
|
1 |
return true; // true my ass! this doesn't work |
Final comment, courtesy of James Gosling himself:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
/* *************************************************************** ************** * BEWARE!! * ************** All ye who enter here: Most of the code in this module is twisted beyond belief! Tread carefully. If you think you understand it, You Don't, So Look Again. *************************************************************** */ |
Do share with us if you encounter any hilarious comments in your code base.
Thanks for reading.
To share your code in the comments, please use our online compiler that supports C, C++, Java, Python, JavaScript, C#, PHP, and many more popular programming languages.
Like us? Refer us to your friends and support our growth. Happy coding :)