Funny comments in your OS's Source code?

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
User avatar
TudorOS1
Posts: 8
Joined: Mon Sep 19, 2011 9:24 pm

Funny comments in your OS's Source code?

Post by TudorOS1 »

I paused my OS development indefinatly while I worked on mods to Minecraft in Java.

When I resumed I was looking in the source files, and I found this in my scheduler:

Code: Select all

//Why did the chicken cross the road?
//He didn't, his thread got pre-empted
I have left odd "humerous" things in my source files quite a lot, mostly for fun (programming can get boring), for instance, also in my scheduler, I found this:

Code: Select all

//This code came from the time components but shhhhh
DOUBLE_DWORD temp = count;
So I do have one question, what funny comments have you put in your OS?
WARNING: Bad joke
Why did the chick run away?
He was a little chicken
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Funny comments in your OS's Source code?

Post by bluemoon »

I got comment not on my kernel but some production code looks like this due to policy:

Code: Select all

//! Hey, this function make fruit punch, what else you'd expect?
//! \param apple_juice amount of apple juice
//! \param apple_juice amount of orange juice
void make_fruit_punch(int apple_juice, int orange_juice) {
   ...
}
Seriously, it ain't funny, adding redundant comment to simple function is a waste of screen estate.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Funny comments in your OS's Source code?

Post by AJ »

Hi,

Looks to me like that has been done for parsing by a documentation generator such as Doxygen. In which case, I guess it makes sense to have the entire interface documented, even simple functions.

Cheers,
Adam
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Funny comments in your OS's Source code?

Post by Kevin »

And had you documented what happens when apple_juice or orange_juice (or even both) are negative, your comment might actually have ended up useful.
Developer of tyndur - community OS of Lowlevel (German)
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Funny comments in your OS's Source code?

Post by Antti »

TudorOS1 wrote:what funny comments have you put in your OS?
I do not have funny comments in any code I write (or even colloquial writing style there). Yes, I am boring and that is my style. I like to do it as professional as I can (whether it is a "hobby" or "professional" project). I like it when the code comments are written like the soulless computer itself would write them. I do not want to express my current mood of the day there. Of course, what I have done so far has not been very professional when it comes to the actual code. However, you do not find any funny comments that would make it even worse.

Of course, I am not against people making funny comments. That is their style.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Funny comments in your OS's Source code?

Post by AJ »

Hi,

I only tend to make any comments that may be considered funny when I've narrowed down a bug to a particular piece of code, but haven't yet worked out exactly why that bug is happening.

Other than that, it's pretty much all stuff that will be read by Doxygen or basic annotations explaining any "magic" (actual magic numbers or constants are properly declated as consts, but if I have "wait(200);", I may document that this piece of hardware requires a 200msec delay just because the datasheet says so).

Cheers,
Adam
User avatar
Jezze
Member
Member
Posts: 395
Joined: Thu Jul 26, 2007 1:53 am
Libera.chat IRC: jfu
Contact:

Re: Funny comments in your OS's Source code?

Post by Jezze »

Id say if your code needs comments you probably wrote bad code. That is unless the code has weird consequences that are hidden or not very obvious to the reader in which case a funny comment is a must to relieve tension.
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Funny comments in your OS's Source code?

Post by bluemoon »

Jezze wrote:Id say if your code needs comments you probably wrote bad code. That is unless the code has weird consequences that are hidden or not very obvious to the reader in which case a funny comment is a must to relieve tension.
While for simple code, the purpose of comments is to "compile with the whole theme", however, I think for serious project, most of the code require comment. The basic comment describe the interface (input/output parameters, any side effects), it's also good to document any assumption or fail cases, or why this piece of shi* is coded[e.g. due to customer request :)] etc.

Without proper comment it's difficult for anyone, including a future instant of yourself, to maintain code more complex than a hello world.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Funny comments in your OS's Source code?

Post by Combuster »

The first rule of comments is that they are not the solution for poorly written code. Well written code doesn't need that much comments - just simple autocompletion and knowing the general theme does much more than having to look up (java)doc for everything you might use.

That said, funny comments don't typically end up in my code. The typical emotional comment typically takes the following format:

Code: Select all

// Do X because Y is stupid and does Z.
I'm also a personal fan of writing out the proofs for mathematical equations in comments directly above the implementation. Depending on the case in question, this not uncommonly results in code decorated with ascii art. Typically when it comes to that, half my colleagues wouldn't begin understanding it anyway - comments or not.


The closest thing to a funny remark is the occasional "Here be dragons" warning in my driver code.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Griwes
Member
Member
Posts: 374
Joined: Sat Jul 30, 2011 10:07 am
Libera.chat IRC: Griwes
Location: Wrocław/Racibórz, Poland
Contact:

Re: Funny comments in your OS's Source code?

Post by Griwes »

Not in the kernel, but in the same project's dumb imitation of Boost.Spirit from before splitting a single file with lots of template magic into smaller ones:

Code: Select all

/**
 * Watch out, crazy template code ahead. All hope abandon ye who enter here.
 *
 * Lexer is full of run-time, er, somethings, this one is full of compile time
 * ones. And run-time too. I *did* write `all hope abandon`, didn't I?
 */
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations
User avatar
Kazinsal
Member
Member
Posts: 559
Joined: Wed Jul 13, 2011 7:38 pm
Libera.chat IRC: Kazinsal
Location: Vancouver
Contact:

Re: Funny comments in your OS's Source code?

Post by Kazinsal »

At the beginning of a function in a driver for some VirtualBox specific crap:

Code: Select all

// Dragons aren't scary enough. Here be snakes.
And when that function starts getting weird:

Code: Select all

// Programmer Indiana Jones is screaming like a little girl.
// I warned you, didn't I?
User avatar
Velko
Member
Member
Posts: 153
Joined: Fri Oct 03, 2008 4:13 am
Location: Ogre, Latvia, EU

Re: Funny comments in your OS's Source code?

Post by Velko »

Being a Futurama fan, i couldn't resist.

Code: Select all

/* We're Owl Exterminators! */
avl_tree::~avl_tree()
{
    clear();
}
If something looks overcomplicated, most likely it is.
bemk
Posts: 8
Joined: Sun Oct 02, 2011 2:50 pm

Re: Funny comments in your OS's Source code?

Post by bemk »

This is the closest I got.

The statement about infinite loop, I think was from before I had the endProg call in there (which is just an assembly fuction halting the cpu). Cas van Raan is a classmate of mine, and he's a little foul mouthed at times. He asked me to put it in, so I did.

It only shows when you enable the "cas" flag before compiling, and you manage to panic the kernel (which I happen to do, from time to time).

Code: Select all

// Claim to have panicked, show the message and enter an infinite loop.
void panicDebug(char * msg, char* file, int line)
{
#ifdef CAS
	// Little easter egg, a request from Cas van Raan
	printf("****'s fucked up at line %i in file %s\n%s\nTry again!", line, file, msg);
#else
	printf("Andromeda panic in %s at line %i\n%s\n", file, line, msg);
#endif
	endProg(); // Halt and catch fire!
}
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Funny comments in your OS's Source code?

Post by bluemoon »

Just found a funny comment (and behavior) on my boot loader code, it happens when it failed to parse the kernel executable.

Code: Select all

.phdr_fail:
    mov     edi, 0xB8000
    mov     rax, 0x1F211F211F211F21                 ; Holy, Full screen of !!!!!
    mov     ecx, 80*25/4
    rep     stosq
    hlt
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: Funny comments in your OS's Source code?

Post by qw »

When I was programming in Basic I commented blocks that contained a lot of goto's, with "start of spaghetti code" and "end of spaghetti code". It also was my guarantee that no goto would jump into or out of that block.
Post Reply