How salty is your code?

Do you curse in your computer code?

I was searching Borland’s newsgroups for a solution to a particularly annoying problem and I found this short bit of sample code:

JBuilder newsgroup posting

The first thing I noticed was not whether or not it would work – I noticed the F word placed quite conspicuously (and appropriately) in the comments.

The code reminded me of a few (relatively tame) cursing developers I knew…

One fellow was writing in a horribly primitive scripting language provided by a company called, say, “Bozo Company”. The language was incapable of allowing passing an expression as a parameter as such:

x = sqrt(a + b)

His response was to use the following workaround:

bozoCompanySucks = a + b
x = sqrt(bozoCompanySucks )

He did this in hundreds of places.

Another fellow used to sprinkle the application with pungent error message dialog boxes. If you accidently clicked the wrong thing and found a bug, a message box would pop up with some serious sailor language. I was always curious if any of those debug messages made it into our shipping product.

I know that these are kind of lame, and my own code is unfortunately squeaky clean. Team development and code reviews make salty code somewhat risky these days.

How about your code?

Wow, how unprofessional can you get.

I’ve certainly written some terse and less-than-kind comments when working around system bugs (e.g. “the stupid ms muldiv always rounds down, so we’re wrapping the function here to fix it. Don’t call muldiv, call this”.), but I’ve never used profanity that I can recall.

Not to mention, the loser who wrote the code you saw should have just done what I did above: written a wrapper function or macro that fixed the problem, rather than copying and pasting his (rude) fix all over the place.

Think about it. The problem that the “loser” was working around was due to a fundamental flaw in the syntax of the language. Trying to work around it with a wrapper function (I’d be shocked if a “horribly primitive scripting language” had macros of any sort) makes absolutely no sense.

Metacom has got it. The fellow was a particularly sharp individual who was annoyed at such a limited language. He was kind enough to clean up all of his odd variable names prior to his departure.

Though I totally agree that such language in code is unprofessional, I still get a kick out of seeing a few curse words sprinkled in the comments from time to time. Particularly when used to point out a carefully designed booby trap that I am about to fall into.

I started a new job a year back and picked up a lot of legacy code from my predecessor. His code was pretty good, but had lots (dozens) of comments that said only:

/* This is turd */

Asking around, I found that he did indeed say “This is turd” out loud a lot (at the appropriate times) as well.

All such things are rare, and outright profanity really rare, within my FileMaker scripts, field defs, and so forth, I’m pretty clean, but occasionally, since I do have it to myself…let’s see…

a) The computer-illiterate co-CEO in the New Jersey office forced me to split the database in half over my strenuous objections for unrelated irrelevant reasons (networking problems making remote Terminal Services access slow and sludgy) and then of course I had to write routines allowing data in the NJ half copy over to the NY half. Name of one of the major subscripts: “Make JT for Surgically Separated NJ (sigh)”.

b) It’s not in there any more so I’m drawing upon memory, but once upon a time they had me restrict all but senior financial people from creating new “vendors”, and wanted all others to be forced to select only from dropdown list of valid vendors. Then, subsequently, they demanded that I allow them to enter “temporary vendors” on-the-fly, in the same field but not drawn from the valuelist and not being added to the permanent list of vendors. (So I create an override field and a calculated display field that can display contents of legitimate or silly-ass override field). Then they want them to have the ability to “save their temporary vendors to the permanent list” upon being verbally okayed to do so by the lazy-ass financial folks who originally demanded that input be restricted. At some point I ripped out all this mess and started over with a simple routine requiring that vendors be on the list but letting anyone add them, but during a short get-by “patch” period there was some seriously godawful-ugly scripting and a morass of cobbled-together impromptu relationships and routines that were intercommented with apologies to any subsequent programmer, e.g, “Yes I know, believe me it wasn’t my idea”.

c) I’ve hidden an occasional silly easter egg. I had a script attached to a portal field that would go off to the related record and call a script in that other file, and I had a couple users persist on trying to click on it while in Find mode, which yielded a slew of error messages. Rather than simply suppress them and pop up a message reminding them they couldn’t do that in Find mode, I had the window zoom in and out 400% / 25% back and forth a couple times, beeping, and then speak out loud “Bad, very bad. System error. Crashes. Flames and screaming and babies crying for their mama.” before popping up the message “No, you can’t do that in Find Mode! Shall I put you in Browse mode and take you to the Purchase Order, or just leave you here in Find Mode?”

The only one that’s ever gotten me into (momentary) trouble was innocent and unintended: in a standard routine in a shrink-wrapped resellable solution, I had a “plug-in” routine that could call a file or set of files that would be customized per client, and the placeholder file during development was “Dummy”. You can probably see where this is going. Once I forgot to change the reference in the main file after the client’s custom files had been developed before sending them an advance copy to play with, and some computer-semiliterate salesperson was on the phone the next day screaming that the computer was calling him a dummy (“The file “Dummy” cannot be located. Please locate the file “Dummy” and click “OK” to continue.”)

I might have used “darn” or “damn” or maybe even “freaking” or “friggin”, but that’s probably it.

The only thing I can remember is once when I was having a particularly hard time getting my code to communicate to a piece of machinery, I put something in the comments like: // Ack that sumbitch

Beyond that, I can’t remember ever swearing in code.

Well, no outright cuss words in the code, but some acronyms where everyone knows what they mean, e.g. fubar. And definitely some acerbic comments about the code or the reasons that a particularly grotty piece of code exists.

Some of the verbal utterances that take place while I'm coding, on the other hand, are not fit for prime time viewers.

Doctoral Dissertation which utilized some of the crappiest legacy I have ever seen. Fixes involved subroutines named “damn_bitch” and variables such as cock_monkey. Man that sucks. In ended up removing it in the final version.

I think it’s just petty, juvenile, and unprofessional. I always assumed that videogame code was the worst in terms of professional environments, because it’s always a pretty casual atmosphere anyway.

But it annoys the hell out of me to see useless and/or cute comments like “THIS IS A HACK!” or “Slap the person who added this code!” It’s not helpful at all, and just somebody’s attempt to be clever, and it fails.

Cuss all you want, and make all the cutesy comments you want, out loud as you’re writing the code. But the code itself is a professional document that you’re getting paid to write. Show some professionalism.

I haven’t done hardcore coding since my high school AP classes, but in there, certainly, cause the teacher was jsut as profane and thought it was funny. He swore at us, we codeswear at him.

Not code, but I dropped a drawing from a vendor into a package I then sent to a customer. I should’ve looked at it closer because in the notes was an obscenity. I nearly lost my job when my customer’s project manager saw it but the vendor laughed it off, saying that they did that because nobody read the notes, anyway. You haven’t been told off until the personal representative of one of the richest people in the world tells you off and you know this is one of the people who can truly ruin you just because you pissed him off.

I always read the notes now and I dropped that vendor like a hot potato.

About 3-4 years ago, I was HTML programming, and was brought in to fix a project. When I opened up the pages, I saw lots of HTML comments berating the client. Things like:
“These fucking assholes are such a pain in the ass!”

HTML Comments are of course not that difficult to find, especially for a client. I’m not sure if they ever found those (perhaps that’s why I was brought in), but I got rid of them very quickly.

Yes, I definitely swear in my code too much for my own good.

I don’t think it’s terribly bad practice to cuss a little bit, if that’s the team mentality. I certainly wouldn’t put any profanity in my code if I were working for Microsoft or something, but I am making a game this year (a cool little platform-shooter type thing) and everyone on the team is pretty much on the same page maturity-wise, i.e. we don’t frown on swearing in the code. Especially in the parts we don’t think anyone’s going to read. :wink:

Doing a search through all the code just now, here’s what I found:

I don’t know who wrote this one:



    if(Game.In.JumpClick()&&m_OnGround)
    {
        //weird shooting slashing thing fix
        //^^WHAT THE FUCK IS THIS!?
        ...


The producer/A.I. programmer wrote this one:



Rabbit.h

Purpose:	A riled raging rabid fucking rabbit.  It is an enemy, derived from EquipableEnemy.


(That one was supposed to be temporary, but we got lazy.)

I wrote this one, in the OpenGL texture loading function. Molly, one of the team members, has a messed up video card on her laptop that inverts the red and blue channels for some reason.



#ifdef MOLLYSFUCKEDUPCOMPUTER
                    GL_RGBA,                // External format
#else
                    GL_BGRA_EXT,                // External format
#endif


I wrote this next one also.



/******************************************************************************\

WinMain
Komojo

Purpose: It's fucking WinMain
Parameters: A bunch of obsolete Microsoft stuff
Returns: I don't think it matters.
Modified: 11/5/2004

\******************************************************************************/


Ahh, good old WinMain.

I also just found this one, and I have no idea who wrote it:



    wcex.hIcon          = 0;    // Icon (don't give a crap)


The A.I. programmer also added a function to the Object class called “DieBitch().” I’m pretty sure we’re going to change that one before the final version of the code.

Yeah, this will probably come back to bite me in the ass someday, if an interviewer looks at my code and decides he doesn’t like it, but it’s good stress relief.

:slight_smile:

I’ll sometimes put profanities in when I’m trying to debug some particularly realcitrant piece of code, and I need to go through and check every step to see where the error is introduced. So the program will end up printing something like

ok
ok
ok
ok
Stupid piece of crap!

I will, of course, take such things out once they are no longer necessary.

Maybe I’m an immature programmer, but KJ, I found yours pretty darn funny.

My old supervisor at my last permanent job told me about something that she witnessed once during a demo of software written by the company she was working for at the time. I don’t remember the exact circumstances, but something happened that wasn’t supposed to, and the (customized) error message–displayed to the prospective clients and everybody–was:

WOOP WOOP OUT OF RAM

They were not amused. I, however, laughed my ass off when she told me. :smiley:

I don’t generally do that in my own code. But I’ve seen some things from my students. Not on their program submissions, usually (except for one with lots of profanity directed at me, which led to the TA handing it over to me when she spotted it, which led to me discovering that he copied somebody else’s code and changed the names, and he got a 0 on it for cheating…)

But, sometimes a student will come to me for help, and I’ll say, “Okay, log in to your account and let’s look at your code”.

They will log in, I’ll do a directory listing, and notice a file like “fuckit.cpp”. :wink:

All my code goes through peer reviews, so there’s no chance of sneaking in any funny business anywhere.

On the other hand, I have snuck in some mild gags in otherwise formal documents. I got a chuckle a few months ago seeing examples from a coding standards document I wrote several years ago pop up in another company’s coding standards – my samples for structures, variables, and #defines were all based on vintage video games… :smiley:

This morning I slipped a 3-second clip from the beginning guitar riff of Pink Floyd’s “Have a Cigar” into our app. Right click on the picture in the splash screen to hear it :cool:.

I changed the extension to “.jpg” and slipped it in with the rest of the resources. I wonder if my teammates will find it before the code makes it into production…