16 Best Source Code Gems [Collection]
Tags: code, humor, humans
Published: 2017-09-15 18:17:13

---
title: 16 Best Source Code Gems [Collection]
published: true
description: Developer's personalities shine in odd ways. Here is a collection of examples of personality expressed with code.
tags: code, humor, humans
canonical_url: https://www.coderhood.com/16-best-source-code-gems-collection/
cover_image: https://thepracticaldev.s3.amazonaws.com/i/l5b0vpmov69xfvfvayfa.jpg
---

This post was first published on [CoderHood](https://coderhood.com) as [16 Best Source Code Gems [Collection]](https://www.coderhood.com/16-best-source-code-gems-collection/). CoderHood is a blog dedicated to the human dimension of software engineering.

[![](https://thepracticaldev.s3.amazonaws.com/i/3cylc5ko1raatz8v9rnf.jpg)](https://www.coderhood.com/16-best-source-code-gems-collection/)

Developer's personalities shine in odd ways. One them is in a (sometimes) subtle sense of humor, choice of words and attitude that you can find in code, code comments, and error messages. It often feels like a stream of consciousness that reflects the human reality of a moment in time.

I collect those gems and here I am sharing with you some of my favorites. Some I found myself in the code I worked with. Others, I collected from various sources. All have been stripped of anything that could be considered IP.

### 1 -- Wild Compiler.

~~~~~~~~~~~~~
Â Â /*
Â Â  * I don't know why the compiler hates me.
Â Â  * I changed this comment many times, and every
Â Â  * time it generated the same executable.
Â Â  * You should try. It's wild.
Â Â  */

~~~~~~~~~~~~~

### 2 -- If You Get Here.

~~~~~~~~~~~~~
Â Â /*
Â Â  * If you get here, I screwed up.
Â Â  * If I screwed up, I clearly don't know what I am doing.
Â Â  * If I don't know what I am doing, and you are looking at my code...
Â Â  *Â Â  ...we are both in trouble.
Â Â  */
~~~~~~~~~~~~~

### 3 -- Classic, Useless Documentation.

~~~~~~~~~~~~~
Â Â int  i  =  0;Â Â // Set i to zero.
~~~~~~~~~~~~~


### 4 -- Whatever You Do, I Can Do Better.

~~~~~~~~~~~~~
Â Â int  getRandomNumber()  {
Â Â Â Â Â Â return(rand()+1);Â Â // You have been one-upped
Â Â }
~~~~~~~~~~~~~

### 5 -- Don't Even Try.

~~~~~~~~~~~~~
Â Â /*
Â Â  * Don't even try to understand this.
Â Â  * I wrote it, and I have no idea why it works.
Â Â  * But it does. My subconscious is that good.
Â Â  */
~~~~~~~~~~~~~

### 6 -- Feeling Sick.

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

### 7 -- CUI (Coding Under the Influence).

~~~~~~~~~~~~~
 // drunk, fix later
~~~~~~~~~~~~~

### 8 -- No Comment

~~~~~~~~~~~~~ 
   /*
Â Â Â Â * Sorry, I have removed all comments from this code.
Â Â Â Â * If you can't understand it, you shoudn't touch it anyway.
Â Â Â Â */
~~~~~~~~~~~~~

### 9 -- Sincerely

~~~~~~~~~~~~~
 public  boolean  thisCodeSucks()  {
Â Â Â Â Â Â return  true;  // sincerely
 }
~~~~~~~~~~~~~

### 10 -- Random Number

~~~~~~~~~~~~~
    int  getRandomNumber()  {
      return  4;  // Guaranteed to be random. I used a dice.
    }
~~~~~~~~~~~~~

### 11 -- So Long

Not code, but still really funny.

![](https://thepracticaldev.s3.amazonaws.com/i/l5b0vpmov69xfvfvayfa.jpg)

### 12 -- Human Needs

This is taken from theÂ [Apple Chess Engine code](https://opensource.apple.com/source/Chess/Chess-311/Sources/MBCEngine.mm.auto.html).

~~~~~~~~~~~~~
Â Â //
Â Â // Paradoxically enough, moving as quickly as possible is
Â Â // not necessarily desirable. Users tend to get frustrated
Â Â // once they realize how little time their Mac really spends
Â Â // to crush them at low levels. In the interest of promoting
Â Â // harmonious Human - Machine relations, we enforce minimum
Â Â // response times.
Â Â //

Â Â const  NSTimeInterval kInteractiveDelayÂ Â Â Â =  2.0;
Â Â const  NSTimeInterval kAutomaticDelayÂ Â =  4.0;

~~~~~~~~~~~~~

### 13 -- Textbook Comment

~~~~~~~~~~~~~
Â Â /*
Â Â  * Explanation omitted as an exercise for the reader.
Â Â  */
~~~~~~~~~~~~~

### 14 -- Expiring Code

~~~~~~~~~~~~~
 // If you are reading this after 1/1/2010
 // there's something wrong.
 // This should have been ripped out by then.
 if  (DateTime.Now  >  new  DateTime(2010,  1,  1))  {
     throw  new  Exception("This code is now obsolete");
 }
~~~~~~~~~~~~~

### 15 -- "Temporary" Code

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

### 16 -- Family Issues
~~~~~~~~~~~~~

/*
Â * The game of life
Â */
 if  (status==SINGLE)  {
Â Â Â Â Â Â money  =  1;
 }  elsif  (status==DIVORCING)  {
Â Â Â Â Â Â money  =  money  /  2;
 }  elsif  (status==DIVORCED)  {
Â Â Â Â Â Â money  =  money *  2;
 }  else  {  // status==MARRIED
Â Â Â Â Â Â money  =  rand()  *  monthly_salary  +  0;  // Savings is represented by zero.
 }
~~~~~~~~~~~~~

---

### If you enjoyed this article, keep in touch!

- [Find all my posts on CoderHood.](http://www.coderhood.com)
- [Join my professional network on LinkedIn.](https://www.linkedin.com/in/lpasqualis/)
- [Follow me on Twitter.](https://twitter.com/lpasqualis)
- [Join my Facebook page.](https://www.facebook.com/coderhood/)
- And finally, follow me here on dev.to!