Top 45 Best Comments In Source Code I Ever Encountered

In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program.

They are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters.

The syntax of comments in various programming languages varies considerably.

Comments are sometimes processed in various ways to generate software documentation external to the source code itself by documentation generators.

They can also be used for integration with source code management systems and other kinds of external programming tools.

Related: Top 15 Best Coursera Courses & Specializations To Take in 2018

In my life as a developer, here are some of the 45 funniest source code comments I encountered.

Have fun and feel free to add yours in the comments section.

1.

/*
 * Dear Maintainer
 *
 * Once you are done trying to ‘optimize’ this routine,
 * and you have realized what a terrible mistake that was,
 * please increment the following counter as a warning
 * to the next guy.
 *
 * total_hours_wasted_here = 73
 *
 * undeclared variable, error on line 0
 *
 */

2.

// Autogenerated, do NOT edit. All changes will be undone.

3.

Exception up = new Exception("Something is really wrong.");
throw up;  //ha ha

4.

//When I wrote this, only God and I understood what I was doing
//Now, God only knows

5.

stop(); // Hammertime!

6.

// sometimes I believe compiler ignores all my comments

7.

// 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.

8.

// somedev1 -  6/7/02 Adding temporary tracking of Login screen
// somedev2 -  5/22/07 Temporary my ass

9.

// drunk, fix later

10.

// Magic. Do not touch.

11.

#define TRUE FALSE

12.

//Happy debugging suckers

13.

// I'm sorry.

14.

return 1; # returns 1

15.

Catch (Exception e) {
 //who cares?
}

16.

/*
 * 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.
 */

17.

try {

} finally { // should never happen 
}

18.

const int TEN=10; // As if the value of 10 will fluctuate...

19.

//This code sucks, you know it and I know it.

20.

//Move on and call me an idiot later.

21.

double penetration; // ouch

22.

/////////////////////////////////////// this is a well commented line

23.

// I don't know why I need this, but it stops the people being upside-down 
x = -x;

24.

// I am not sure if we need this, but too scared to delete.

25.

doRun.run();  // ... "a doo run run".

26.

# To understand recursion, see the bottom of this file 
At the bottom of the file:
# To understand recursion, see the top of this file

27.

// I am not responsible of this code.

28.

// They made me write it, against my will.

29.

/* I did this the other way */

30.

/* Please work */

31.

// no comments for you

32.

// it was hard to write
// so it should be hard to read

33.

options.BatchSize = 300; //Madness? THIS IS SPARTA!

34.

// I have to find a better job

35.

# code below replaces code above - any problems?
# yeah, it doesn't fucking work.

36.

class Act //That's me!!!
{
  ...
}

37.

public boolean isDirty() {
    //Why do you always go out and
    return dirty;
}

38.

Repeat
    ...
Until (JesusChristsReturn) ' Not sure

39.

// Catching exceptions is for communists

40.

// If this code works, it was written by Paul DiLascia. If not, I don't know
// who wrote it

41.

//Peter wrote this, nobody knows what it does, don't change it!

42.

// Comment this later

43.

/** Logger */
private Logger logger = Logger.getLogger();

44.

# This is becoz you messed with me the other day
if current_admin.name == "#{my_x_employer}"
  sleep(1000 * 3600)
end

45.

# Linux Sex
$ date ; unzip ; strip ; touch ; grep ; finger ; mount ; fsck ; more ; yes ; umount ; sleep

Did you like this list of source code comments?

Please share.

8 thoughts on “Top 45 Best Comments In Source Code I Ever Encountered”

  1. Number 2 – Autogenerated, do NOT edit. All changes will be undone. – appears in linux config files just, all of the time!

    Reply
  2. Number 2 – Autogenerated, do NOT edit. All changes will be undone. – appears in linux config files, just, all of the time!

    Reply
  3. #11 – “#define TRUE FALSE”

    You made a mistake here: this is not a ‘comment’ in the term that it is used in.

    This is a preprocessor statement, that tells the compiler to replace all instances of “TRUE” it encounters in that file with “FALSE” if that compiler has a preprocessor implementation (a lot of C compilers have one, IIRC).

    Reply
  4. Great article! These traits really makes programming language good and unique. I am glad to read your article as java beginner as its good to know about these characteristics. Thanks a lot for sharing!

    Reply

Leave a Comment