OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 7:54 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 51 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: Funny comments in your OS's Source code?
PostPosted: Wed Jul 24, 2013 5:16 am 
Offline
User avatar

Joined: Mon Sep 19, 2011 9:24 pm
Posts: 8
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:
//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:
//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


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Wed Jul 24, 2013 6:42 am 
Offline
Member
Member
User avatar

Joined: Wed Dec 01, 2010 3:41 am
Posts: 1761
Location: Hong Kong
I got comment not on my kernel but some production code looks like this due to policy:
Code:
//! 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.


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Wed Jul 24, 2013 6:53 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2646
Location: Devon, UK
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


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Wed Jul 24, 2013 7:33 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
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)


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Wed Jul 24, 2013 9:46 am 
Offline
Member
Member

Joined: Thu Jul 05, 2012 5:12 am
Posts: 923
Location: Finland
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.

_________________
Undefined behavior since 2012


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Wed Jul 24, 2013 10:19 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2646
Location: Devon, UK
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


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Wed Jul 24, 2013 10:24 am 
Offline
Member
Member
User avatar

Joined: Thu Jul 26, 2007 1:53 am
Posts: 395
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/


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Wed Jul 24, 2013 11:16 am 
Offline
Member
Member
User avatar

Joined: Wed Dec 01, 2010 3:41 am
Posts: 1761
Location: Hong Kong
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.


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Wed Jul 24, 2013 1:26 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
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:
// 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 ]


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Wed Jul 24, 2013 2:48 pm 
Offline
Member
Member
User avatar

Joined: Sat Jul 30, 2011 10:07 am
Posts: 374
Location: Wrocław/Racibórz, Poland
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:
/**
* 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


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Wed Jul 24, 2013 3:02 pm 
Offline
Member
Member
User avatar

Joined: Wed Jul 13, 2011 7:38 pm
Posts: 558
At the beginning of a function in a driver for some VirtualBox specific crap:
Code:
// Dragons aren't scary enough. Here be snakes.


And when that function starts getting weird:
Code:
// Programmer Indiana Jones is screaming like a little girl.
// I warned you, didn't I?


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Thu Jul 25, 2013 12:59 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 03, 2008 4:13 am
Posts: 153
Location: Ogre, Latvia, EU
Being a Futurama fan, i couldn't resist.
Code:
/* We're Owl Exterminators! */
avl_tree::~avl_tree()
{
    clear();
}

_________________
If something looks overcomplicated, most likely it is.


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Thu Jul 25, 2013 6:01 am 
Offline

Joined: Sun Oct 02, 2011 2:50 pm
Posts: 8
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:
// 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!
}


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Thu Jul 25, 2013 9:03 pm 
Offline
Member
Member
User avatar

Joined: Wed Dec 01, 2010 3:41 am
Posts: 1761
Location: Hong Kong
Just found a funny comment (and behavior) on my boot loader code, it happens when it failed to parse the kernel executable.
Code:
.phdr_fail:
    mov     edi, 0xB8000
    mov     rax, 0x1F211F211F211F21                 ; Holy, Full screen of !!!!!
    mov     ecx, 80*25/4
    rep     stosq
    hlt


Top
 Profile  
 
 Post subject: Re: Funny comments in your OS's Source code?
PostPosted: Wed Jul 31, 2013 5:54 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 26, 2009 2:48 am
Posts: 792
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 51 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 57 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group