Stack OverflowHumor in code
[+96] [112] pfranza
[2008-09-26 15:34:41]
[ language-agnostic fun pop-culture ]

When you are writing code or naming products, which sources of cultural references are you most likely to draw from? Which reference sources do you think are more likely to be universally understood?

For example when findbugs sees that you've implemented equals() without overriding hashCode() it suggest that you implement it by returning 42 (a reference from HHGTTG)

Or why we have big endian vs little endian encoding, referencing Gulliver's Travels

Not that we should act unprofessionally with our code, but if you going to tell a person that they could only (watch/read/...) one (book/movie/show/...) which one would allow them to 'get' the most jokes?

I thought your question was "What source will help you understand in-jokes?", not "What joke would you like to tell?". I'd recommend Monty Python (the TV series). That's where "SPAM!" came from. - joel.neely
void ballmer(Developers developers) throws chair - Rice Flour Cookies
I think Which reference sources do you think are more likely to be universally understood? is not the right approach. Jokes are much more fun if not everyone understands them. It rewards those users that do and allows you to better jokes. That said, that can only be done in jokes that aren't too obtrusive. - Jasper
[+98] [2008-09-26 16:54:22] FlySwat

Microsoft Code has lots of good comments (Taken from Windows 2000)

// The specific idiot in this case is Office95, which likes
// to free a random pointer when you start Word95 from a desktop
// shortcut.


// we are such morons. Wiz97 underwent a redesign between IE4 and IE5

// We have to do this only because Exchange is a moron.

// We are morons. We changed the IDeskTray interface between IE4

// should be fixed in the apps themselves. Morons!


/* CallProc32W is insane. It's a variadic function that uses
* the pascal calling convention. (It probably makes more sense
* when you're stoned.) */

Finally, this makes you wonder about the build process over at MS:

/*       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 *       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 *       !!!!!!!!!!!!!!DOING SO F**KS THE BUILD PROCESS!!!!!!!!!!!!!!!!
 *       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 *       !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Isn't that a little bit dangerous to post that here, I mean could this be a copyright problem or so, even so it's funny? - André
I think these have been posted elsewhere, publicly, so there is little danger. Of course IANAL... - Keithius
These are from the leaked copy of Windows 2000 source that hit the scene years ago, I don't work for MS. - FlySwat
(5) I wonder if all of the 'moron' quotes were posted by the same obsessive programmer! lol - Tony R
I know that those where posted elsewhere already, but it's still a possible prob, just b/c others did it, it's not automatically legal, but maybe I'm just über concerned - André
(6) I take comfort in knowing our dev group isnt alone in needing anger management - MikeJ
Doesn't changing tabs to spaces break make? and if you do it on my make files, I might kill you. - dlamblin
There are lots more of these over here... - Jason
Using spaces instead of tabs breaks make as well - including GNU Make I believe... - Graham
fair use, guys, this is most definitely fair usage.. - Jasper
@Fly Swat-See… Also @Janson 's link is cool! - giddy
[+88] [2008-09-26 17:38:04] Dylan Beattie

Ok, not actually real production code, more compilable doggerel...

public class MohammedAli {
  float like_a_butterfly;
  string like_a_bee;

and the somewhat more elaborate:

public class LunchOrder {
    double cheeseburger;
    char grilled;
    long drink;
    short cake;

Slightly upset that this made me laugh! Feel so.. cheap! - DavidWhitney
(92) class Employee { short hours; double pay; long lunches; }; - Adam Rosenfield
(12) I always declare the first double "d" - cciotti
Maybe short coffee? - tunnuz
(20) More like class Employee { long hours; short pay; short lunches; } - Joe
(4) class Divide { private function youreNotInvited() { return "from whence you came!"; } } - oops
(10) class CEO { short hours; long perks; BigInteger pay;} - fastcodejava
(2) or the infamous int eger; - slacker
[+83] [2008-10-08 21:57:08] Dashogun

Once, a couple of years ago, I was working with some custom XML for an installer. In my late night frustration I just couldn't figure out why this one "feature" wouldn't work. That is, until I got this error message:

The Product element contains an unexpected child element 'Bastard'.

This was totally unintended and has kept me laughing to this day...

[+71] [2008-10-08 21:31:35] John Chuckran

Taken from the xkcd comic Random Number [1]

int getRandomNumber()
    return 4; //chosen by fair dice roll.
              //guaranteed to be random.

(3) That is possibly one of the funniest things I've ever seen. - localshred
(55) I'm getting tired of xkcd though. - The Wicked Flea
The book version has an extra ';' between the () and the line break. But, hey! it's the RFC 1149.5! It's the only logical random number to return, right? - luiscubal
(11) -1 Every time you push a good xkcd joke one step closer to becoming just another overused internet meme, god kills a kitten. Please, think of the kittens. - Evan Plaice
[+69] [2008-10-08 21:16:37] Jason Baker

I just found this Stored Procedure in our database.


print ' {o,o}'
print ' |)__)'
print ' -"-"-'
print 'O RLY?'
print ' '
print '{o.o}'
print '|)_(|'
print '-"-"-'
print 'YA RLY'
print ' '
print ' {o,o}'
print ' (__(|'
print ' -"-"-'
print 'NO WAI!'

(6) i'm added this to every DB i ever create. haha - Jon Erickson
[+57] [2008-11-07 14:50:04] RichieACC

When I was using VB6, I often had my error handling look like:

On Error GoTo Hell

I used it again when writing code in VBA for access. My then very Christian manager nearly had a heart attack when he saw it, and made me change it :(

(37) FAIL @ religious lack of humour - Jens Roland
(1) I am going to use this! goto hell; - Chris Peterson
That was in Futurama, in the robotoly church: 10 sin 20 go to hell but they forgot 30 ... 40 profit! - streetpc
(6) I would upvote this, but you have 42! - Wayne Werner
haha!! Thanks Wayne! - RichieACC
[+50] [2008-09-27 05:13:04] seanb
// every time you call this a kitten dies somewhere

O(n3) method follows...

[+50] [2009-02-05 15:57:06] vengafoo

I was writing a class to crawl the web so naturally the class definition was like this:

public class WebCrawler //: public SpiderMan, private PeterParker

Might be more appropriate for a Facebook scaper, pretty funny nonetheless. - Peter Turner
[+48] [2008-09-27 10:48:43] keparo

I usually write very straight-edge code, and try to name things as clearly as possible. But sometimes a good, logical name turns out to be funny.

I was building a "safe search" filter for a popular online video site. You may have used it. It just keeps the sexier videos out of your sight unless you explicitly toggle your settings to include them.

So I needed to name a method for bringing the sexy videos back into the user's video queries.

I couldn't help myself:


It's in production. Millions of people bringSexyBack() every day.

It says for a popular online video site, that could be any number of ... No wait ... your probably right. - Brad Gilbert
That's gold! I bet it plants an earworm whenever you look at that code though :-) - Dan F
(7) Hrm, now what video site could that be. Could it be... Veoh, Mr. Kelly Patrick Robinson? - Artem Russakovskii
[+45] [2008-09-26 16:09:27] Matt

I giggle every time I shorten "Assembly" to "ass" in .net:

var myAss = this.GetType().Assembly;

I was once asked to go back and rename my variable names for this exact reason.... because someone had to read it aloud in a meeting. - hometoast
(3) How does one adequately read code aloud? Do you have to specify where the semicolons are? - John Rudy
(4) I'm thinking more along the lines of something like: "When I call function X on 'myAss', it throws a NullPointerException. We need to make sure to double check that 'myAss' is not null!" - Outlaw Programmer
LOL LOL LOL! :) ... I just remembered i had that in my own code somewhere, but it didn't even feel weird to name the variable containing an Assembly "ass". It occured to me only days later when i came back to this code, and henceforth every Assembly var is named "ass" now. - steffenj
(3) But "myAss" is so much better, i guess i have to refactor! :) - steffenj
I had the legitimate opportunity to use name a variable "perfectPair" the other day. So I did :-) - endian
(6) Once I saw an application called MIARS, short for M*** Integrated Analytical Reporting System. The conversation was supposed to go: Where did the numbers come from ? ... - ConcernedOfTunbridgeWells
Did you every pull anything out of or put anything into ... er nevermind. ;) - Edward Kmett
(12) I shortened "Performance analyst" to "perf_anal" once. The perf_anal himself wasn't too impressed. - Graeme Perrow
I just happen to have started working on a project where Assessments are filled in and processed. And every programmer coding before used for (Assessment ass : assessments) { if (ass.isOpen()){...}...} it's fun to work with this code :) - Peter Perháč
(1) As long as you don't start making ASSembly MANagers... - Artem Russakovskii
(1) Very often when I'm typing "add" I miss by one button so it ends up as "ass" so i try to call strange methods like assItem() etc... - Stein G. Strindhaug
[+43] [2008-09-26 15:36:27] yalestar

Not really a cultural reference, but I'm fond of using the HTML blink tag in my Javadoc.

(4) That's just mean. :P - musicfreak
(1) Ha! I had a prof who said any blink tags in assignments (websites) would result in an automatic 0. Shame no one ever tested him... - Adam Neal
[+42] [2008-10-08 21:22:13] Ates Goral

I've always waited for the occasion to write the following comment inside a C++ class declaration with private members and friend classes:

// Only friends are allowed to see each other's private members.

[+42] [2008-09-26 20:17:02] alex

SEX (SignEXtend) mnemonics was removed from the Assembly language for Intel microprocessors but ANL and ORL (Logical-And and Logical-Or) were allowed.

Source here: - analytik
[+41] [2008-11-30 15:23:01] unexist

Here's another one:

while ("my guitar gently weeps") {

Might be funnier if you spelled 'weeps' correctly :) - Tim
(5) I am going to adopt this one. - Konrad Rudolph
[+39] [2009-02-21 18:27:24] Patrik Hägne

I once worked on an app that had an interface for auto handling persistence of "dirty" objects. The interface was named...


... and still makes me laugh, the guy who wrote it hadn't even realized that it was funny when I asked him about it.

(1) Wish I could upvote more than once, LOL. - Leslie
[+36] [2008-11-07 14:53:54] dwelch

My favorite, and one I now sometimes borrow was seeing this in a Makefile:

love :  
     echo "not war"

(2) On FreeBSD system is built into the make. - Wergan
[+33] [2008-09-26 15:44:38] unexist

There are so many funny comments in the OS-world. I like this one:

return(0); // Another brick in the -Wall

(It is one of those returns that never could be reached.)

[+32] [2008-09-26 15:43:37] ddaa

Monty Python references. But then, I'm a Python programmer.

(2) Makes perfect sense! :) import spanish-inquisition; - steffenj
(1) I did a project at uni once involving Knights and tournaments. Bonus marks were awarded for applicable Holy Grail quotes. - Zooba
(2) This is specifically encouraged in the official language reference. - Colonel Sponsz
(9) Them: "I would redesign the architecture." Me: "It's only a model..." - Joseph Gordon
@steffenj: nobody imports spanish-inquisition :) - Muhammad Alkarouri
As i've told to my colleague: "-This project is dead! -No,no, it's testing, look!" - Alexander Il'in
[+31] [2008-09-26 17:53:31] Michael Easter

I once saw an especially clever comment used Morse code as an implicit message....

// .... . .-.. .-.. ---  .-- --- .-. .-.. -..
// begin section
// .... . .-.. .-.. ---  .-- --- .-. .-.. -..

Love it... +1 with sentiment that shenanigans should be in comments and not variable names.

Spoiler - helloworld - Guy
i dont get it, someone care explaining? - Click Upvote
(12) ".... . .-.. .-.. --- .-- --- .-. .-.. -.." is Morse code for "HELLOWORLD". - Chris Peterson
i first thought my browser had a render-error - Marenz
Brilliant!!! I am gonna put lot of Morse legacy n my code!!! ;) - Microkernel
[+24] [2008-09-26 15:42:17] Galwegian

One wingnut I had the pleasure of working with used to work in the names of his ex-girlfriends to variable names.

Dim Jessica as String


thats a strange until you go to clean up your pointers ExGf lisa = new ExGf(); .... delete(lisa); but event that doesn't seem very thereputic. - pfranza
(6) Even worse, it looks like he's using VB so he can't even terminate his ex-girlfriend string. - polara
(13) Does he refactor all his code when he gets dumped? :) - steffenj
@steffenJ: those are his ex-gfs; he is already dumped by them. new exgfs will have to wait for new code to be written I guess ;) - user20358
(4) If you name your functions/methods after girls, you can "call" them. - tsilb
and if your classes are named after girls, you can inherit them? - Click Upvote
and if your HTML SELECTs are named after girls, you can 'check' them - Jens Roland
(17) and if your processes are named after girls, you can kill them - Jens Roland
(7) I think someone took that joke past the end of the index. - uzbones
+1 for wingnut! - Harry Lime
+1 for past the index. I almost sprayed coffee. - Pekka
throw new IndexOutOfRangeException(); - Tom Savage
I think he just liked imagining Jessica in a string. - ssg
Wonder how many calls ended up as NullReferenceExceptions - sMaN
[+22] [2008-09-26 16:31:30] Cruachan

In the days when Pascal was a popular teaching language and a common exercise was to write a program to output graphics using a pen printer (one of those that moves a pen across a page, raising and lowering the pen to draw) we had a lecturer who used to delight in the pointing out the pitfalls of the convention of naming pascal variables by joining words and in fixing capitals, i.e. the common boolean variable name :-


I did worse than that. I stored the state of the pen in the variable PenIs--and did not notice what it spelled until I was done. - Loren Pechtel
you mean a plotter - Brad Gilbert
Aye, that would be it. They were endlessly fascinating to watch, especially the ones that moved the pen in two dimensions (some moved the paper and the pen instead). - Cruachan
[+22] [2009-03-24 13:27:59] Brian R. Bondy

In C++:

 #define true false // happy debugging losers

Actually, not in C. Only C++ defines the boolean type. - Billy ONeal
@BillyONeal: Yup fixed. - Brian R. Bondy
First time ever -- the internet actually made me laugh out loud. - ajax81
[+21] [2008-11-07 14:24:54] T.E.D.

I've twice had to create a Log class for message logging. Both times I put this comment in the class header:

// What rolls down stairs
// alone and in pairs
// and flattens the neighbor's dog?
// What's great for a snack
// and fits on your back?
// It's log, Log, LOG!

(9) Lets not forget that its "Big its heavy its wood. Its better than bad its good" - Jon P
How 'bout LOG for girls? - borisCallens
dang.. i was 5 when ren & stimpy came out - community_owned
Its fun for boys and girls - Brad Gilbert
I am so putting this in all my headers from now on. - musicfreak
[+20] [2009-02-05 15:20:28] Chris
double pi = 3; //M:find correct value 

This "inaccuracy" was hidden in the code for about 3 years before I discovered it.

(18) Shouldn't the compiler have found it first? ;-) - Adam Liss
Whats wrong with Math.PI() :-) (assuming .NET or Java) - Anders Rask
+1 Indiana Pi Bill, for those who don't get the reference. (Also Biblical, I believe) - new123456
[+19] [2008-09-26 15:52:45] Pyroglass
for(int c = 0; c < 10;)
   c++; // < get it?  c++ ?  it's so... literal

(1) Perhaps it's a speedup loop? - HoboBen
C++, get it? C plus plus - mattlant
No, we lost you ... - OscarRyz
Then the whole world is lost. God help us all :P - mattlant
People just pretend they don't understand puns. That or i have a horrible sense of humor. - WolfmanDragon
I wouldn't beat yourself up about it. Took me a while to get it. And once I did I didn't find it funny because... well... I found it funny for about 10 minutes when I learned it my freshman year of college... :-\ - Wes P
I thought it was pretty funny. - Pim Jager
I got it, but wish I didn't. - Dour High Arch
(16) The code says "c++", and C++ is a programming language (whose name comes precisely from the fact that ++ is the increment operator in its predecessor language C). Is that it? Is that the joke? Is that a joke? - ShreevatsaR
(3) I would normally write ++c; - Daniel Daranas
@ShreevatsaR: lol I get it now tnx bro - Daniel
(9) C++ -> make C larger but use the old version :) - martinwguy
(5) why don't you just go c = 10... - Tor Valamo
[+17] [2008-09-26 18:46:55] Gulzar

Once I was going through some old application code for maintenance and I came across these comments within an empty function block:

"Alex will be coming tomorrow to write code here." It was commented with a very old date. Obviously, something happened to Alex or else it would not have remained empty.

I was curious and made some enquiries about Alex with some old timers. One of the guys mentioned that it might have been the guy who admitted he could not code from Day 1 and needed some training. He was fired the same day.

Not sure what happened to the guy who put the comments in the first place.

oh my god. hahahahaah - Click Upvote
(1) I hit a similar comment after a few hours debugging, a lovely note to myself saying 'TODO: Fill this in. I didn't know whether to laugh or cry at the time. I laugh about it now though :-) - Dan F
[+16] [2009-05-26 22:06:59] codymanix
char coal;
short cut;
long way;
float assets;
string tanga;
double penetration;
object slide;

UserPermissionException up = new UserPermissionException();
throw up;  // lol

return off;// the Jedi;

I can`t stop laughing :))))))) - Siblja
(3) int eastwood and char guevara – we had those at uni ^^ - poke
I prefer double entendre - not as explicit :) - gnud
public double entendre - codymanix
Fantastic, my next variable shall be named double penetration - Jeffrey Greenham
[+14] [2008-09-26 15:46:07] John Rudy

In unit tests, I'll do HHGTTG, Office Space, Idiocracy and occasionally (only occasionally) Star Wars references.

In my production code, no. No way. I try to keep that as professional as possible, down to the comments -- at least what gets checked in. Not only does it make my life easier when I'm maintaining it six months down the road, but it makes the lives of anyone else who has to maintain it easier. Humor has a place; in my mind production code isn't it.

(That said, I'm not above a little easter egg in an about box with some humor -- as long as it's zero-impact on the application's functionality.)

(10) Why is it that 'professional' has to = 'so serious we avoid any attempt at humour'. There's some arguments for easter eggs, be it in the code, or in the UI. We're human. Why can't our code be human? - DA
@DA: Because the next guy who needs to read/maintain it may not get the humor. It doesn't add value to his experience. Additionally, clients who are being billed hourly and may expect to audit the code often don't appreciate it -- they see it as time wasted on their dime. - John Rudy
(1) Another reason not to write funny code is that if it happens to break there, it could look really bad. If it's a serious bug you could end up looking like a clown. - dangph
(1) You're against jokes in comments hidden in the source code, but not in about boxes every user can see? - Michael Mrozek
(3) I agree not to write funny code, with exception of about box easter eggs, however what's wrong with funny comments. I'm usually so depressed when I check out code at work, I would love to find occasional humor (even poor attempts). - jamone
[+11] [2008-09-26 15:38:23] shelfoo

I think one of the funnier ones I've seen is a perl function that had a hash named ofTheJedi (instead of some generic "this holds data" name).

Then only reason it was named that way was so the return statement was 'return %ofTheJedi'.

I've seen lots of HHGTTG references, lots of star wars references, and the odd Dr Who/Battlestar reference.

i'm incorporating this into my code pronto - Jon Erickson
[+10] [2008-09-26 16:22:47] David Heggie

This is from the app we're currently working on. For all fans of dodgy 80's pop:

if($res) {
    $karma = $res['Karma']['karma']; // karma karma karma chameleon

This is a song ? - Agusti-N
Oh my, I laughed so hard, and I really don't know why! - Allan Kimmer Jensen
[+10] [2008-09-26 17:19:21] Jacob

There is an xkcd forum thread with quite a nice collection of Funniest/Most Annoying Code Comments [1]


[+10] [2008-10-22 18:18:00] Maglob

Magic number in Java class files: 0xCAFEBABE

[localhost ~]$ hexdump -C Foo.class  | head
00000000  ca fe ba be 00 00 00 31  00 46 0a 00 14 00 1f 09  |Êþº¾...1.F......|

(1) I like this place. It's right up the street from the 0xDEADBEEFCAFE. - Don Branson
[+9] [2008-09-26 17:01:21] JW

If you're going to put jokes in your code, PLEASE for God's sake do it in the comments. There's nothing more annoying than variables or methods with "hilarious" names. It really does make the code more difficult to understand.

But I'm all for funny comments. (And there's more to humor than referencing obscure TV shows.)

[+9] [2009-11-18 12:02:51] Hilton Perantunes
<?php $_GET['rich'] or die('trying'); ?>

[+8] [2008-09-26 15:44:39] Brian Knoblauch

I try to avoid doing that. Can make it more difficult for others with different backgrounds to maintain the code.

Yeah I've been tempted many times to make a snarky comment, but then I remember the folks for whom English is a second language. It's hard enough for them without having to figure out a sitcom reference. - JosephStyons
(1) Ditto that. Often times humor is quite relative, even without a language barrier. What you think is funny somebody else might consider idiotic. - Nik Reiman
(34) You guys must be a lot of fun at work. - korona
lol, brian knoblauch is that dude - community_owned
@josephstyons, I think you should do that for precisely that reason, would be funny if they couldn't understand a sitcom ref and went to a supervisor and said 'do you know what x means..?' LOL - Click Upvote
(2) And then you realize, that sitcoms are not, perhaps, the most funny thing in the world :) - shylent
[+7] [2008-11-24 19:11:34] Kawa

Looking through some code from earlier this year, I found some silly comments.

In a C file that converted to/from Roman numerals, the "last update" timestamp had the year written in Roman numerals. That was the only file in the project that had it. Later on, in another number crunching file, it included some things regarding the above-mentioned Roman numerals:

#include "roman.h" //He has a wife, you know... Know what's she called?"

There's also a function I first encountered in Nethack and lovingly adopted: strkitten(char*,char);

So what does strkitten do then? - Alan
(4) Well, if strCAT appends (concatenates) an entire string, strKITTEN appends only one character, obviously. - Kawa
(1) +1 for the kitten. Everyone loves kittens! - Wayne Werner
[+7] [2010-02-21 05:06:17] fastcodejava
abstract class Sex {


class SexWoMen  extends Sex {
   long duration;

class SexMen  extends Sex {
   byte duration;

[+6] [2009-07-13 17:07:54] Victor

acceptable usage of breaks and contunues in java:

    //something in loop
        break dance;


        continue the_assault;

or something to that effect.

[+6] [2008-09-27 11:14:50] Joeri Sebrechts

One of my favorites was a file with in the header something like
// Author: Mike
and a bit later, in a function, something like
// Mike: whoever wrote this code should be put against the wall and shot

Anyway, be very careful about being too clever. Blowing off steam in comments is fun, but maintainability should always trump funny. Never, ever, try to be clever with variable naming.

Lol, i really wanted to upvote this but have run out of votes - Click Upvote
[+6] [2008-09-26 16:55:11] Joe Strazzere

It's all fun and games, until a bug makes your attempt at humor visible to the customers...

As seen in "We Burned the Poop". - FlySwat
Very, very, very true. Not that I have any first hand experience with this............... - Max Schmeling
(2) Psh. The customer is the audience. (Just kidding. [Sort of.]) - eyelidlessness
Yes, as we once had "Please stand by is grunting a sculpture" noticed by our content editors. - Chris Ballance
'back in the day' we used to remote into client PCs and do fixes on site for emergency situations. Nothing like cracking open the code and reading a comment: "Way to go Bob, taking a simple problem and making it fucking more difficult". Especially fun when the customer is reading the screen. - SomeMiscGuy
[+5] [2008-09-26 17:54:39] loudej

My favorite is a comment a co-worker added to a safe-delete function we had in c++. It was very hackish, but it protected from some null problems in a code-base that wasn't checking nulls often enough.

    class WidgetBase

      void SafeDelete()
        if (this)
          delete this;
Whether 'tis nobler in the mind to suffer
The slings and arrows of outrageous fortune,
Or to take arms against a sea of troubles,
And by opposing, end them. 

delete is supposed to include a null test like this anyway (as in, it won't attempt to free a null-pointer). Nice comment though. - Zooba
haha. tell him calling something on a null pointer is undefined behavior :D - Johannes Schaub - litb
@Zooba: My C++ compiler from 1998 didn't check null. - Joshua
@Joshua: but it did figure out what null.SafeDelete() was? - MrKishi
[+5] [2008-10-22 18:03:50] Adam N

To answer your question, I suspect Hitchikers Guide to the Galaxy is the single book from which the most programmer humor comes from, but that may just be personal experience. I have seen very many comments and variable names that came from there.

But other than that, we're all over the board on our references... I remember seeing one comment in a chunk of perl code that had given the developer a lot of trouble:

# Touch this code and die like Biggie and Tupac
# /Touch

+1 great! . - scraimer
[+5] [2009-06-10 15:26:13] serialseb

from OpenRasta

public interface IHas : INoIzObject {}

[+5] [2009-06-18 14:13:06] George Profenza

A friend of mine uses this status message when he's asleep :)

while(awake) sheep++;

I think I'd prefer do { sheep++; } while(awake) - pfranza
[+4] [2009-02-05 15:27:11] Rulas
   //Just to be sure =)


[+4] [2009-11-18 12:09:21] Will

Scott Meyers in comp.lang.c++.moderated [1]:

using namespace std; // so sue me

[+4] [2009-02-05 14:17:52] Chris Ballance

To combat out project being offshored to Cambodia we try to include the occasional reference that other cultures might not understand.


To find the parent site in MOSS:


[+4] [2008-09-26 16:47:45] Treb

My favourite: 42, second place: Towel. And just to show that I have read other books too (3 or 6, depending on the way you count): Precioussssss...

[+4] [2008-09-26 15:36:13] Mike Mazur

I used quotes from Office Space as strings in unit tests.

Some example of this? - OscarRyz
(2) string multiline = ""Good evening Sir, my name is Steve. I come from a rough area. I used to be addicted to crack but now I am off it and trying to stay clean. That is why I am selling magazine subscriptions.""; // - Mike Mazur
It's not that I'm lazy; it's that I just don't care! - tsilb
[+4] [2008-09-26 15:48:43] yalestar

Another one I used to enjoy when I did COM programming was to place the following above a QueryInterface call:

// QueryInterface for the Straighty Interface

or, alternately:

// QI for the Straight Guy

[+3] [2008-09-26 16:38:18] Kevin Fairchild

I prefer unintentional humor...

Legacy code is perfect for that.

Dim intOrderID AS Long

Or sometimes when the comments have long ago become out of sync with the code they were referring to.

Reality truly is stranger than fiction....

[+3] [2009-02-05 14:46:59] Joseph Gordon

In a class to manage several threads:

public Collection getRuns()
    return new ArrayList( runs ); //return chinese food

[+3] [2008-10-01 16:08:43] BlaM

Got some nice comments with no reference at all :)

'2002 07 22 [Jon] Temporary fudge for AMEX
'2005-02-23 [Dominik] Temporary is relative ;)

(It's still in there ;) )

[+3] [2008-09-27 01:48:33] Ben

We named an internal application LIGERS. Needless to say, we were thrilled to be able to fit in a reference to Napoleon Dynamite.

[+3] [2010-01-23 16:45:18] Rob

In a debugging session with colleagues I said "set the break to 0xC0FFEE", meaning: "Let's go for a coffee break."

[+3] [2010-06-03 17:29:38] Jakub Lédl

A collection of my favorites (I hope someone actually reads this):

 * @file: getport.cpp
 * @author:
// No wonder he didn't write his name above this crap. I wouldn't.

// If we can't divide by zero, we have to use something very similar:
m = v / 0.0000000000000000000000000000000000000000000000000000001;

// window destructor
Window::~Window() {
    // wait for the window to close, it's cold outside
    pthread_join(thread1, NULL);

// This is for pure effect, the algorithm is so fast
// that no one would actually believe it

def AVeryCleverFunctionThatCalculatesIfTheNumberGivenByEntryWidgetIsReallyAPrimeNumberOrItIsDividableByAnotherNumberOtherThanFirstPlusNumberWhoseDistanceFromZeroIsEqualToOneOrByItself:

def parseRESData:
    return FALSE;

Not even one of these is actually mine, but I consider them so freaking hilarious I have to share with you :-)

I like the divide by nearly zero one... - Wayne Werner
How the hell did "def" get into C++? How the hell did Thread.Sleep get into C++? - Billy ONeal
It didn't. These are codeblocks from different languages (C++, Python, C#, the second can be anything), but this web text generator that Stack Overflow uses joined them all into single <pre class="prettyprint"></pre>. - Jakub Lédl
I've actually done the Thread.Sleep one. There can be something a bit...disconcerting about clicking a button to do some complex thing and having it finish instantly, especially if there's not even any time to show feedback. Sometimes the user just needs to feel like yeah, there's some heavy duty processing going on...and an annoyingly easy way to accomplish that is to make them wait a couple of seconds. - cHao
[+3] [2009-04-02 15:08:26] Simon

For the rare occasion I need to raise exceptions, I have reserved a special identifier:

var up:Error = new Error();
throw up;

What language is this? - missingfaktor
[+2] [2009-04-02 15:07:24] fbinder

There are some comments that are fun but really useful. I remember one program made with C++ (Visual Studio 4 or 5) where I found the following comment (I translated it for the sake of clarity).

double x = 0.0; // DON´T TAKE THIS OFF!!!

Note that the variable x was not used anywhere. The funny part is that if you deleted the line the program did not compile anymore. The error? If I remember correct it was something about struct alignment.

[+2] [2009-02-05 17:37:55] community_owned

My default new JSP text in eclipse used to read: "This is my JSP."

It now reads: "This is my JSP. There are many like it, but this one is mine."

[+2] [2009-02-21 19:29:00] Matt Olenik

This isn't really humor, but I find it funny. This is the fast inverse square root function from the Quake III source code. It uses some crazy hacks to get results that (at least, at the time) are up to four times faster than (float)(1.0/sqrt(x), even though sqrt is usually implemented in assembly.

Line 10 makes me laugh. Maybe it's just how ridiculous the whole thing is, and I can see John Carmack laughing while writing something so strange.

float Q_rsqrt( float number )
    long i;
    float x2, y;
    const float threehalfs = 1.5F;

    x2 = number * 0.5F;
    y  = number;
    i  = * ( long * ) &y;  // evil floating point bit level hacking
    i  = 0x5f3759df - ( i >> 1 ); // what the fuck?
    y  = * ( float * ) &i;
    y  = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
    // y  = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed

    #ifndef Q3_VM
    #ifdef __linux__
    	assert( !isnan(y) ); // bk010122 - FPE?
    return y;

(3) Carmack actually didn't write it. - Hawker
awesome article Hawker thanks! - m_oLogin
[+2] [2011-01-23 11:01:36] George Profenza

Q: What do you call 8 hobbits ?
A: A hobbyte

via reddit [1]


[+2] [2011-02-03 13:51:32] Paska

Dear Computer
Please print "Hello World!" string
Then wait until user pressed a key
Best Regards

...and this is magic.h

#include<stdio .h>
#include<conio .h>

#define a )
#define Best ;
#define Computer (void){
#define Dear void main
#define key ;
#define pressed (
#define Please printf
#define Programmer
#define print (
#define Regards }
#define string );
#define Then int
#define until =
#define user getch
#define wait x

do you like it? :)

[+2] [2008-09-26 18:54:53] SeanDowney

I'll throw in random stuff when I'm working on a very difficult problem, due to my inability to think of appropriate variable names. I tend to try and tell a story to keep my excitement

$self = new User();
while($self->hungry()) {
    $bacon = $pig.Substr(...);
    $breakfast = getValue() + $bacon;

[+2] [2008-09-26 20:43:16] community_owned

I sometimes use a pattern where a temp table has a boolean column named Kevorkian, initialized to true for all records. The process does some fancy dancing wherein records may be added, and Kevorkian may be set to false for certain existing records. Finally, a delete query removes all records where Kevorkian is still true.

I tried to think of a more serious name for a flag that means "after careful and mature consideration, this record still wishes to commit suicide" but Kevorkian was the best I could do.


[+2] [2008-09-26 17:26:11] DaveJustDave

I don't know about anything funny.. but it's always a hoot to lie in your comments. Not little white lies, but huge blatant ones.

'//do not remove following code or app will stop running
Dim n as string
For n = 1 to 10000000
   n = n & rnd()

(1) Looks like a loop to introduce a delay. That was often used to work around bugs (i.e. the Borland Pascal runtime error on newer PCs) or when there is an external component that takes a moment to initialize. In any case, that code will break at some point in the future when run on a faster machine... - Michael Stum
shouldn't n be an integer? Why a string? - Wallacoloo
Because if the snippet truly is a time delay, string concatenation would slow it down even more. - Cory Larson
[+2] [2009-02-05 14:52:29] Geo

I really liked this one :

int OF_THE_JEDI = some value;
// code does something here with var
return OF_THE_JEDI;

ok you are like the 4th person to post this, please come back when you get something original - community_owned
[+2] [2008-09-26 18:03:20] community_owned

I would say, stay away from humor in code unless your program is written in lolcode.

+1 for the awesomeness of lolcode - Wes P
[+2] [2008-09-26 17:11:05] kae

Personally, I keep the comments straight forward and to the point... The svn check-in logs however... recently full of references to Dr. Horrible's Sing Along Blog.

[+2] [2008-09-26 17:13:58] Dan Coates

This didn't directly relate to the code in the script, but I wrote a VBScript called psexecWizard. It basically called psexec en-mass based on some database criteria and did some other random/cool stuff. In between the functions, I made comparisons between psexecWizard and "Pinball Wizard". Other wizard references eventually cropped up (allusions to the Washington Wizards, Wizards of the Coast, and Harry Potter, boy wizard).


' Pinball Wizard was written by Pete Townshend of "The Who".  Dan Coates* wrote PsExec_wizard.  According
' to both authors, each item was "the most clumsy piece of writing [he'd] ever done."

' * Not the more famous Dan Coates that wrote "Lean on Me", but the less famous one who was in a
' a cappella group YouTube video performing Nintendo songs.

[+2] [2008-09-26 15:52:33] VirtuosiMedia

This wasn't used in any program, I just thought it was funny.

$iShower = $_GET['clean'];
if ($iShower) {
     echo getdate();

I think the implication is the wrong way round. Surely if (!$iShower) { !getdate(); } If showering is a sufficient condition then please let me know where you live - Leigh Caldwell
I think you need an area where the size of the intersection of dating women and desperate women is larger than the size of the set of showering men. No, I don't know where that is. - Tetha
index.php?clean=0 - eyelidlessness
(1) I'll admit it: I had to read the comments to get the joke D: I think it would have been clearer without the echo. - Wallacoloo
[+2] [2008-09-26 15:55:05] davetron5000

My test data for Gliffy's [1] API is all based on Simpsons and Futurama. For example, the account named "BurnsODyne" has diagrams like "Reactor Control UI", "Mayoral LAN", "SNPP Domain Mode", and "Booze Database Design". A personal account owned by "" has a flowchart called "Circuitous Plan to Get Hands Back". Test data just has to be kept interesting. I actually made them realistic, too:

![SNPP Domain Model] (


I guess inline images are no allowed? Weird that the help told me how to do it and previewed it and then didn't render it.... - davetron5000
I think it may be sanitised out. Jeff had a blog post recently about this. Obviously you're welcome to force yourself to execute arbitrary code (hence the preview working), but it would be better if it didn't. Uservoice, anyone? - Zooba
[+2] [2008-09-26 15:57:18] user13276

So this isn't directly answering the question - but definitely is good not to take yourself to seriously when you're programming - have a good time and don't worry - that proverbial next programmer will be smart enough to figrure out what's going on regardless your oddball sense of humor.

Had a senior project I was working on for my under-grad degree - we had a "project manager" who also participated in some of the coding. I was almost in tears when he took personallly a comment I made about "the stupid database" or something like that - he thought I needed counseling or something (not that I don't)... but again, let's not take ourselves to seriously, cause no one else does.. :)

[+1] [2008-09-26 15:40:15] AlexCuse

There's a database connection manager class in one particularly horrid third party app I work on. Every instance is called "connman".

While I'm sure it wasn't intentional humor, it seems appropriate. Sometimes, especially late at night, we break out laughing when we come across one of these.

Why are you working late at nights with an employer? Jeez...... - Click Upvote
[+1] [2008-09-26 15:44:45] Thorsten79

23, 42, 69

For extra obscurity, I sometimes convert them to hex before.

I've seen 666 used as well. - Aardvark
23 is a Discordian / Illuminati reference. - wnoise
I'm partial to 1701 myself - Wes P
I usually go with 1702, myself. A great book, that was. - Lawrence Johnston
Do you mean 2702? I think @Wes P was referring to the Enterprise, not Cryptonomicon. - Adam Lassek
[+1] [2008-09-26 15:46:46] MegaHAL

It might be funny in the code that you write, but it's maddening to debug someone else's code that's littered with this kind of trite.

Perhaps you meant tripe, as trite is not a thing nor is it relevant to bad comments... sorry haha. - slude
vocab nazi slude++ - Max Cantor
I actually liked the idea of "trite" used as a noun and came here to say so. - eyelidlessness
[+1] [2008-09-26 16:44:36] EricSchaefer

A friend of mine wrote a program that would communicate with another via two pipes. One for each communication direction (send/receive). The variable that held the descriptor/handle for the pipe for receiving data was named "bagpipe".

i think d-bag would of been a better name for your friend - community_owned
[+1] [2008-09-26 16:15:42] Rontologist

One of my favourites that I have come across:

my $ofTheJedi = x;
return $ofTheJedi;

I beat you to it.. or is that bet you to it? - shelfoo
I got beaten as well :( - Geo
lol so many of this joke here - wrongusername
[+1] [2008-12-25 21:58:40] Piskvor

A certain project I worked on had a LOT of complicated, big-ball-of-mud [1] code. One of the older functions is prefixed by a quote from Through the Looking Glass:

/* "It seems very pretty," Alice said when she had finished it,
    "but it's rather hard to understand! Somehow it seems 
    to fill my head with ideas--only I don't exactly know what they are! 

IMHO funny comments are OK, but funny-names or funny-values for variables are horrible:
-Why do we have a String login_is_ok and why does it contain "Listen, I'm not crazy ... yet"?!? +Well, one of the original developers thought it was funny, ROTFL-funny even.


[+1] [2008-11-07 14:01:10] community_owned

The funniest thing I ever saw was in a c# application to replay captured drawings on the screen. In between the individual drawing of the samples of pen positions was a call to a function waitABit();, which was defined as follows:

void waitABit()
  for(int i = 0 ; i < 1000000 ; i++);

(1) One like this caused us a lot of grief. If was compiled code designed to run on a 286. We had to keep a 286 PC in working condition until the whole line was retired around 2002. Worse yet the DOS version installed on it was German. Every emulator or slow down we tried cause the program to fail. - Jim C
[+1] [2008-11-07 14:14:59] Michael Dubakov

In java code of huge old application I saw quite funny comment

// Fellow, modify this method if you understand EVERY SINGLE LINE in it

[+1] [2008-11-07 14:28:19] Edward Kmett

In my younger days When writing one-off perl programs I admit I had a penchant for just emitting code with colloquial meanings like:

open(FOO,"...") or die horribly;


foo() until $hell_freezes_over;

Though, that said, I try to make very few cultural references in my code.

[+1] [2008-10-01 17:44:49] osp70

I had written some code that needed to know if the person reported last month had passed on during the month. I created the method ISeeDeadPeople(...) as bool

[+1] [2011-02-03 13:40:29] grysik44

I can't resist adding a comment to this one

 reader.Flush(); // after use

Lol, very nice. - Alix Axel
[+1] [2010-08-09 22:10:39] Jesse J

Just for fun, I named one of my methods as such:


[+1] [2010-09-23 07:41:49] Anders Rask

In a menu control i found the following comment

if (_isPage) // If you are a page, you are steril and can't have childrens
    HasChildren = false;

[+1] [2010-11-05 16:32:31] MathieuF

Found on the web :

The human body in HTML & PHP

<hair /><br />
<ear align="left" />
<sight><eye align="left">
<eye align="right"></sight>
<ear align "right" /><br />
<nose /><br />
<form action="aliment.php"><mouth /></form><br />
<nect height="8cm" />
<tshirt style="background-color: #000000;" />
<arm align="left"><hand /></arm>
<chestarea><?php if ($sex=='female')
{echo '<tit align="left" /><tit align="right" />;}
else {echo '<nipple align="left" />
<nipple align="right" />;} ?></chestarea>
<arm align="right"><hand /></arm>
<br /><tummy><bellybutton /></tummy></tshirt>
<pants size="short"><underwear>
<?php include 'private.php'; ?></underwear></pants>
<leg align="left" />
<leg align="right" style="tattoo-image: url(img/alvago.gif);" />
<sneaker align="left" class="nike"><foot /></sneaker>
<sneaker align="right" class="nike"><foot /></sneaker>

[+1] [2010-02-22 12:35:23] PieterG

Some code for sending emails

//Let's take care of the email body
StringBuilder bodyBuilder = new StringBuilder();

[+1] [2009-12-28 18:49:07] Caro Cogitatus

I tend to name temporary classes, scripts, and variables as "mattayu". As in:

public class Mattayu
   ... some temporary coding to be used and thrown away

I actually had someone ask once, "What's a 'mattayu'?"

To which the answer is, naturally, "What'sa matter me? What'sa matter YOU???"

[+1] [2009-05-24 01:41:45] German

I don't remember the exact original code and it no longer exists because it was a horrible hack but here's the story:

It was shipping date and we still had some "cleanup" to do, the final tests were running and only one, tiny bug was found by the tester: randomnly, when the user reloaded the application with the command "[app_name] reload" he couldn't get back the prompt and had to press Ctrl+C (the reloading worked fine, just the prompt didn't return sometimes).

The application was run by a bash script that managed more than one child process in the background, and to identify the current in scope process we named it as "me".

So we came up with the brilliant idea to kill the child process that do the reload after it was done:

sleep(5) # Aproximately time taken to reload the application
kill $me # , please

It was a rather stressful day...

[+1] [2009-05-24 03:14:15] Thanatos

From the C++ standard headers included with Mingw (and perhaps others...)

*  @return  A bit pattern (well, isn't everything?)

*  Documentation?  What's that?

[0] [2009-06-18 14:27:44] Chris Doggett

I wrote baNdit [1], a Firefox extension that adds a lot of useful features to One of the features is marking posts that have scores above a certain threshold with an image, or if you've told it to pay attention to a particular user, it'll mark the post with a different image. The name of the function that handles this is:

PublicDefenderChristineSullivan : function() {

Google it if you don't get the reference.


[0] [2009-02-21 19:36:42] lmsasu

In FoxPro:

set bug on


set bug off

[0] [2009-02-21 18:48:26] Clayton
die (Strings::get('Obituary') . $e->getMessage());


$validArchType = array ('A-Frame', ..., 'McMansion', ...);




<string key="VICE_PRESIDENT">Just making sure Kathy is paying attention.</string>

[0] [2009-02-21 18:04:36] monkeypushbutton

I write for a lot of school districts. I tend to keep humor out of my code but my test database has the teachers as the actors that played the Doctor and the students as the various companions over the years.

[0] [2010-01-23 03:42:00] CLR

At my employer, we've named our databases and some of the machines in your development environment after The Big Lebowski characters and common themes.

For instance...

"TheRug", "TheBriefcase", "Donny" and "Walter"

I won't elaborate on what is exactly named after the infamous rug, but I will say that it LITERALLY ties the room together...or in this context, our production environment.

There's actually a question for server names at serverfault. You could put this answer there too. - Matthew Crumley
[0] [2010-01-23 10:00:28] Kronikarz

I was writing a bejeweled clone, and I had functions for destroying (killing) and restoring (ressurecting) jewels from a pool. So I once wrote something like this:

Jewel* jesus = RessurectJew();

[0] [2010-01-23 16:37:15] Ted Dziuba

It's just a comment but I couldn't help myself.

def this_is_recrawl(config):

    if config.has_option("global", "recrawl"):
        return config.getboolean("global", "recrawl"):

    return False

[0] [2011-02-22 04:39:57] sMaN

An embedded programming assignment at Uni was broken into 2 segments, Control and Logging. I subsequently had the roll of logging, and in turn labeled all my files prefixed with AssLogging.c

Why is this funny? I don't get it... - Alix Axel
Just a bit of potty humor - sMaN
[0] [2008-10-01 16:18:32] Unsliced

We had a project whose title abbreviated to AU, so quite a few (private) functions were

gold_this() { ...}


gold_that() { ...}

after the chemical symbol ...

It was humour, although not particularly funny.

[0] [2008-09-27 01:44:49] Wes P

Geeky pop culture things. Like Johnathan Coulton songs, or an XKCD comic. Maybe an obscure video game reference (like Leroy Jenkins or something). Generally my source code humor comes from whatever tickles my fancy at the moment.

[0] [2008-09-26 19:30:53] Ben

When ever I test a system that needs information about people I always use The Simpsons characters. There are lots of them and when I see "Ned Flanders 132 Evergreen Terrace. Springfield MA I know it's one i created.
(yes, I know it's the wrong state but I'm from MA and it's a debatable issue) It's also fun to see which of my co-workes notices it first.

k.. well hate to break it to you, but the simpsons are so 1990's. family guy for the new millenia1!! - community_owned
Awesome - small heads-up though, the Simpsons are at 742 Evergreen - which would make Ned either 740 or 744. :-) - Fritz H
[0] [2008-09-27 02:51:55] smaclell

Wow. Just wow. This thread is awesome. I personally like a bit of humour in code, it keeps me awake on those extra early mornings when the 9:30 scrum is a bit too early.

On my last job we had a particularly colourful couple of coders who liked to get subtle jabs in through the comments. My favourite was one that had an excellent swear density, about every 4th word, and a blatant statement that he a) did not want to write this code and b) we would be better off using another product.

I thought the swearing might be a bit much but hey that little chunk of code could get me through even the most boring meetings.

[0] [2008-09-27 10:05:40] community_owned

I came across a quite funny method, used seriously in the code, it made me laugh. :D. It did something, but it was hard to decipher what it did.

void Foo() {

// Some spaghetti code here 


Apparently there was no method 'Bar', I was disappointed.

[0] [2008-10-08 21:37:23] Slapout

There's some code at work along the lines of:

date midnight midnight = date("8:00")

[0] [2008-10-08 21:45:57] Jeff Cuscutis

I worked with someone who put a variable named NotSoFastMonkeyBoy in the application. This popped up in an error message where some customers could see it. Management was not amused.

At the same place was a library for making multi-step wizards and named everything according to a wizard theme. Each page of the wizard was a spell, all the spells were in a grimoire, and the current page was pointed to by a wand.

[0] [2009-02-05 14:17:49] Don Branson

I inject a number of things in code that only I think are funny. :)

For example, instead of naming an interface IPacketViewer, I might name it ISeePackets.

Theoretically, I could mention my children's names in method parameters, assuming I was using the Dependency Injection pattern.

[0] [2008-11-26 14:16:41] J.T. Hurley

I have a habit of making testing values the names of fictional countries. Leading to several co-workers playing "guess the movie" once.

[0] [2008-09-26 17:00:41] Antonio Louro

Well, when just testing stuff out I used to name my command objects Arnold:) That and a lot of swearing in test strings:P

[0] [2008-09-26 15:58:33] Jeremy Brown

This is definitely not mine, but the Sun hme driver provides lots of fun!

[0] [2008-09-26 16:05:34] The Brawny Man

We have a series of scripts that manage our automated promotion process named Travis and Franz (for no particular reason aside from the whims of the programmer who named them), and a cleanup script named Alice (from the maid in the Brady Bunch).

[0] [2008-09-26 16:10:16] Adam Neal

I've never done it in code for work, but when I was in school I always enjoyed overly long acronyms for my app names. Also, recursive ones are fun. I named one MOOVIE - Movie Object Oriented Visual Information Exchange.

That's not a recursive acronym ("Movie" is a word) - advs89
[-2] [2008-09-26 17:21:32] David Hill

I like belittling my programmer-colleagues in my code comments. It makes me feel better, and also tells me whether anyone reads my comments.

Bad idea. You never know when your comment will come back and bite you. - SLaks
I think its a great idea. I'd write a comment about you that says "Has no sense of humor, and dresses like a bag lady." - David Hill