Table of Contents
584 words
3 minutes
Code Comments We've Written Over the Years: A Hilarious Collection

The original intent of code comments is simple: to explain what a piece of code is doing. But in reality, comments often become programmers’ emotional outlets, disclaimers, or even performance art. Open any project that has existed for more than two years, and chances are you’ll find content in the comments that’s more entertaining than the code itself.

1. The Blame-Shifting Type: “This Is Not My Problem”#

The core demand of this type of comment is—if something goes wrong, don’t come looking for me.

// I wrote this code at 3 AM, and I don't know why I wrote it this way,
// but it works now, so I don't dare touch it.
// If you change it and it causes any problems, please don't find me in git blame.
const magicNumber = 42;
// The logic here comes from the product manager's "Small requirement"
// If you have any questions, please contact the PM (no longer with the company)
apply_discount_logic()

A more refined version: “If you remove this line, the program will crash. Don’t ask me why.”

2. The Self-Deprecating Type: “I Know I Suck”#

Self-deprecation is a traditional virtue among programmers. This type of comment often carries three parts resignation and seven parts sincerity.

// The following code uses "brute-force enumeration"
// Time complexity O(n³), but n is currently at most 3, so it should be fine in theory
// — of course, that's just my excuse
for (int i = 0; i < list.size(); i++) {
for (int j = 0; j < list.size(); j++) {
for (int k = 0; k < list.size(); k++) {
// ...
}
}
}

Another classic:

// TODO: refactor this code
// but I've been staring at it for three hours,
// and now I just want to go home and lie down.
// — March 15, 2024

And the date corresponding to this TODO is often earlier than the project’s first commit.

3. The Honest Type: “You Might Not Believe It If I Told You”#

Sometimes, the truth is just that plain and unadorned.

/*
* The reason this z-index value is 99999
* is because the modal was covered by the navbar (z-index: 1000),
* the navbar was covered by the dropdown (z-index: 5000),
* the dropdown was covered by the tooltip (z-index: 10000),
* I don't want to refactor the entire z-index system, so...
*/
.modal { z-index: 99999; }

And this kind too:

// I admit this section was copied from Stack Overflow
// Link: https://stackoverflow.com/questions/xxxxx
// I don't understand it now, but as long as it works

So honest it’s hard to blame them.

4. The Overly Defensive Type: “I’ve Predicted Your Prediction”#

// ======================================================
// WARNING: DO NOT MODIFY THE CODE BELOW
// If you think you can optimize it, trust me, you can't.
// We tried. Three times. Every time ended in a rollback.
// Please respect the blood and tears of those who came before.
// ======================================================

Some defensive comments are even longer than the code they’re protecting.

Conclusion#

Code comments are like a programmer’s business card—some use them for self-deprecation, some for blame-shifting, and some quietly leave a “pitfall here” warning. Whichever style, they all add a bit of warmth to cold code. Of course, the best comment is actually code that doesn’t need comments. But until then, at least let’s write them in a more interesting way.

What interesting comments are hidden in your project? Feel free to share.


References

Code Comments We've Written Over the Years: A Hilarious Collection
https://www.hehonglei.com/posts/funny-code-comments/
Author
HHLBlog
Published at
2026-08-10
License
CC BY-NC-SA 4.0