News for hackers. Stuff that matters.

Ask HN: Do you swear in your code?

At my company, there tends to be some bad language in our code base. It's pretty common place to find F bombs in they comments. Is this normal practice?
( 80 comments | 15 points | on HN )
Re:Ask HN: Do you swear in your code? by sah on Monday June 16, 2008 @02:21PM (#218911)
Some of my favorites that I've written or come across...

From the BitTorrent client source, an apt comparison:

  This function is like a boat made of shit, floating on a river of shit.
From my .emacs file:

  ;; Fucking RMSmacs (by version 21.3, but after 21.1) doesn't
  ;; fucking make these fucking variables local where it fucking
  ;; should, so the c-set-style we're about to do below breaks
  ;; fucking fill-paragraph for fucking all non-c-like modes by
  ;; fucking default.  Someone desperately needs to die, and I'm
  ;; pretty sure it's not just me.
This one doesn't include swearing, but is in the same spirit. From the Audiogalaxy server, above a huge chunk of regular-expression-based string munging code:

  /*

    sah's take on all this:

    "Cursed the ground where dead thoughts live new and oddly bodied,
    and evil the mind that is held by no head. [...] For it is of old
    rumour that the soul of the devil-bought hastes not from his
    charnal clay, but fats and instructs the very worm that gnaws;
    till out of corruption horrid life springs, and the dull
    scavengers of earth wax crafty to vex it and swell monstrous to
    plague it. Great holes secretly are digged where earth's pores
    ought to suffice, and things have learnt to walk that ought to
    crawl."

    -The Necronomicon
Re:Ask HN: Do you swear in your code? by Hates_ on Monday June 16, 2008 @11:10AM (#218673)
Swearing in comments is unacceptable IMO. You wouldn't write swear words in internal documents, so why do it in code. It's unprofessional and shows a level of dis-respect for your own code and for the people who might end up maintaining it. Plus, heaven forbid a client happened to see it as well.
Re:Ask HN: Do you swear in your code? by ken on Monday June 16, 2008 @12:28PM (#218755)
I've heard more than one hacker speak about either ignoring or redefining "professionalism" (whatever that means):

JWZ: "I wear my unprofessionalism as a badge of honor." <http://www.jwz.org/doc/easter-eggs.html>;

PG: "Maybe some aspects of professionalism are actually a net lose" <http://www.paulgraham.com/opensource.html>;

PG*: "the way that he thought about professionalism did not differ from the thinking of a Mary Kay cosmetics saleswoman: wear nice clothes, drive a clean car, and don't say anything that might offend anyone" <http://philip.greenspun.com/ancient-history/professionalism-...;

We speak and write profanity in other contexts, so why not code? It shows respect for future maintainers that we're honest about what truly sucks, instead of watering it down. Plus, we don't care if clients or investors see that we don't wear suits (or even shoes); similarly, they care about what the code does, not what it looks like.

Re:Ask HN: Do you swear in your code? by notauser on Monday June 16, 2008 @12:44PM (#218774)
One interesting compiler bug later and your comment could end up in an error message.

Anyway I would only swear when I'm at home with a beer in my hand, so I only put swearwords in my code when I'm working at home with a beer in my hand ;)

Re:Ask HN: Do you swear in your code? by midnightmonster on Monday June 16, 2008 @12:27PM (#218752)
True story: During a summer internship years ago, I used Foo and Bar as placeholders throughout a web page comp. My boss sat me down for a serious chat about professionalism. Turns out he had never heard of Foo and Bar. Prior to that conversation, I had never heard of FUBAR.
Re:Ask HN: Do you swear in your code? by ajross on Monday June 16, 2008 @05:22PM (#219133)
Yes, that's the source of the symbols. Some people like them, some think they're unprofessional, yada yada. But I've never once had someone try to interpret "foo" as profanity...
Re:Ask HN: Do you swear in your code? by tjr on Monday June 16, 2008 @07:37PM (#219232)
Possibly, though it seems somewhat more complex than that.

http://www.catb.org/~esr/jargon/html/F/foo.html

Re:Ask HN: Do you swear in your code? by helveticaman on Monday June 16, 2008 @10:24PM (#219327)
I think that's where FOO and BAR come from.
Re:Ask HN: Do you swear in your code? by tx on Monday June 16, 2008 @12:26PM (#218749)
We aren't building tractors, we're "painting" software and do whatever makes us feel more creative. In fact some really great hackers I knew were very passionate about their code and coding process in general. Once we had a dedicated Yellow Pages book to throw in a brick wall (literally). That was awesome.

BTW, didn't you notice how often good programmers curse in public?

I suspect we work in different industries.

Re:Ask HN: Do you swear in your code? by BrandonM on Monday June 16, 2008 @01:09PM (#218801)
You think people who build tractors don't swear? After my work in steel manufacturing, I would bet that there is some informal manual next to a machine that has at least one swear word in it.
Re:Ask HN: Do you swear in your code? by axod on Monday June 16, 2008 @12:21PM (#218744)
You work in a corporate environment don't you. You had to fill out a "comment request form" in triplicate just to post the above comment ;)

I'd say it depends. If you're working for bigco, swearing is probably not going to go down well with your boss, or co-workers. If you're working in a startup/open source project/on your own, then swearing can be good and useful IMHO.

If I swear in the comments of some code (Rare), I can instantly see that I've had some issues with that code, or something I'm interfacing to is idiotic and needs fixing etc.

Re:Ask HN: Do you swear in your code? by edw519 on Monday June 16, 2008 @01:41PM (#218832)
You work in a corporate environment don't you. You had to fill out a "comment request form" in triplicate just to post the above comment

You don't work in a corporate environment, do you?

If you're working for bigco, swearing is probably not going to go down well with your boss, or co-workers

Since few bigcos I've ever worked at ever do code reviews, how would they even know?

After spending many years in corporate environments, it's easy to spot those who haven't when they post comments about corporate environments.

Re:Ask HN: Do you swear in your code? by axod on Monday June 16, 2008 @02:11PM (#218889)
My last job was in a corporate cubedom for 4 years. Not a massive company, but a few 100s of employees. We held weekly code reviews at one point. Also bosses do have a habit of suddenly believing that if they help code the project might run quicker, so they ask for svn access etc, then break everything :)
Re:Ask HN: Do you swear in your code? by edw519 on Monday June 16, 2008 @02:14PM (#218899)
So you have worked in a corporate environment. My mistake.

But tell me, when did you ever have to fill out a "comment request form" in triplicate?

Re:Ask HN: Do you swear in your code? by axod on Monday June 16, 2008 @02:59PM (#218966)
Now I can't work out if you're being sarcastic or not.
Re:Ask HN: Do you swear in your code? by edw519 on Monday June 16, 2008 @03:37PM (#219018)
Touche.

I've worked in many corporate environments, some where things were perfectly logical and others that aspired to be as good as Dilbert.

But I never had to fill out anything in triplicate. I guess I should have realized the sarcastic flag was up. Sorry.

Re:Ask HN: Do you swear in your code? by axod on Monday June 16, 2008 @04:22PM (#219077)
We had so much Sarbanes-Oxley bs anything seemed possible. "Oh you can't use an IM client that isn't approved by us, as it's against S-OX". (Approved by us meant that they paid some inferior crappy IM company to install their client on all company computers. Then they paid a fee per user) Nothing like corporate waste :)
Re:Ask HN: Do you swear in your code? by baltoo on Monday June 16, 2008 @03:03PM (#218972)
I'm located in the northern parts of Europe so perhaps that explains it but I routinely and deliberately use foul language in technically oriented internal documents. The rationale being that it should be harder to copy'n'paste and edit it in an ad hoc sales doc than to ask me for a more specific technical explanation.
Re:Ask HN: Do you swear in your code? by Hates_ on Monday June 16, 2008 @01:04PM (#218795)
I think people have mis-understood my comment. I never said swearing was bad. Practically every word that comes out my mouth is a swear word. I just don't think swear words in code makes for "beautiful" work. I even have a go at developers for not putting full stops at the end of comments ;)

In addition, it's got nothing to do with working for a large corporation as I work for a small advertising software company with less then twenty employees.

Re:Ask HN: Do you swear in your code? by ajbatac on Monday June 16, 2008 @11:22AM (#218687)
Apparently a lot of public codes does...

http://www.google.com/codesearch?hl=en&lr=&q=fuck...

Re:Ask HN: Do you swear in your code? by jayroh on Monday June 16, 2008 @01:15PM (#218809)
I used to ... until about 8 years ago when I response.write'd a large "FUCK YOU" in an asp app that I forgot to take out.

A big honkin' "FUCK YOU" that showed up during QA 5 minutes before client showed up for review.

Never again.

Re:Ask HN: Do you swear in your code? by ConradHex on Monday June 16, 2008 @04:26PM (#219080)
This is exactly why I don't put curse words in code, even in comments. This stuff really does happen, and the results can be awkward. It just isn't worth it.
Re:Ask HN: Do you swear in your code? by robinhoode on Monday June 16, 2008 @11:54AM (#218715)
Some people don't quite get the message unless you use swear words. Especially when the message is "this code is used to be compatible with X, and IMO, X is not very good". 'Not very good' doesn't really describe the emotion that it gives you. I'm sure there's probably better ways to criticize another software system, but when you're short on time, sometimes swearing does the trick. Most often I've deleted such comments or re-written it with a more eloquent vocabulary. But in general, I don't think it's forbidden territory. Call it being passionate about your craft :)
Re:Ask HN: Do you swear in your code? by gaius on Monday June 16, 2008 @11:21AM (#218683)
It's OK to do it in C++, if you must. It's very, very stupid to do it in HTML...
Re:Ask HN: Do you swear in your code? by angstrom on Tuesday June 17, 2008 @12:35AM (#219421)
Seen more than once where a site was blocked by a filter because someone cursed in the comments. Page looked perfectly clean otherwise.
Re:Ask HN: Do you swear in your code? by andrewf on Monday June 16, 2008 @12:46PM (#218777)
You know how some people swear casually, while others would cringe in shame if the apocalypse happened and a curse word passed their mouth?

Same for when they're writing code.

I don't quite get the shocked reactions.. I can understand thinking swearing is distasteful in certain contexts but would certainly never draw wider conclusions about a person because they swear. Then again, I'm Australian.

Re:Ask HN: Do you swear in your code? by kirubakaran on Monday June 16, 2008 @01:17PM (#218812)
When /fuck doesn't find anything, I know my code is ready for 1.0
Re:Ask HN: Do you swear in your code? by martythemaniak on Monday June 16, 2008 @11:48AM (#218708)
I'll occasionally swear in a TODO comment, but all those get done and the comment gets erased.
Re:Ask HN: Do you swear in your code? by markbao on Monday June 16, 2008 @01:36PM (#218829)
Re:Ask HN: Do you swear in your code? by icey on Monday June 16, 2008 @11:21AM (#218682)
It is a fairly common practice. That being said, it's a bad idea to allow that to stand in your code base. It never adds anything to the clarity of the code, other than the fact that you now know the developer writing it has a bad temper.

While you're in there cutting out F-bombs, you should probably do yourself a favor and review the surrounding code. Foul language in comments are almost always put in out of frustration, so you probably have some good targets for code refactoring.

Re:Ask HN: Do you swear in your code? by sah on Monday June 16, 2008 @12:16PM (#218734)
Fuck yes!

Just like the pros: http://www.jwz.org/doc/censorzilla.html

Re:Ask HN: Do you swear in your code? by pxlpshr on Monday June 16, 2008 @01:06PM (#218797)
I would say that's classless, engineering arrogance at best... there are better ways to flaunt intellect and respect, like by owning a night club.
Re:Ask HN: Do you swear in your code? by dgl on Monday June 16, 2008 @02:23PM (#218914)
There's swearing in comments, then there's:

  cmd/xfe/editordialogs.c:   fuck = fe_file_name_int_my_directory(context, buf, link_text);
  cmd/xfe/editordialogs.c:   if (fuck && fuck[0] != '\0') {
Re:Ask HN: Do you swear in your code? by dangph on Tuesday June 17, 2008 @07:50AM (#219664)
I wouldn't follow their example. Netscape Communicator was a big pile of shit.
Re:Ask HN: Do you swear in your code? by zbrock on Monday June 16, 2008 @01:43PM (#218835)
This is a line from our tag unit tests: @tag.name = "this is a really long tag name that exceeds the maximum length which is set at 65 characters, that should do it! no wait, we changed it to 128 so now it needs to be significantly longer so I guess I'll just throw some more text into here and maybe a gratuitous 'fuck' for the next time someone greps for the f-bomb"
Re:Ask HN: Do you swear in your code? by etal on Monday June 16, 2008 @03:51PM (#219036)
I'd enjoy seeing that in a long file of otherwise stale code. I like creative/surreal comments as well, if they fit the code.

That said, a sloppy file full of f-bombs can be annoying and repetitive, too.

Re:Ask HN: Do you swear in your code? by tjr on Monday June 16, 2008 @11:37AM (#218699)
http://philip.greenspun.com/ancient-history/professionalism-...

...may be of interest. But that said, no, I don't. Furthermore, colleagues who frequently use profanity in their everyday speech strike me as rather disrespectful.

Re:Ask HN: Do you swear in your code? by attack on Monday June 16, 2008 @07:20PM (#219223)
Disrespectful to?...
Re:Ask HN: Do you swear in your code? by PStamatiou on Monday June 16, 2008 @01:54PM (#218860)
I do the occasional "here be dragons" and that's about it
Re:Ask HN: Do you swear in your code? by nostrademons on Monday June 16, 2008 @01:56PM (#218865)
I generally don't (I like my code to be clean), but I frequently swear in commit messages, eg. "No longer fucks up selection in Firefox."
Re:Ask HN: Do you swear in your code? by huhtenberg on Monday June 16, 2008 @01:54PM (#218858)
Only in blocks that work around Vista's bugs. I do a lot of development for a variety of platforms, but Vista is really something special.

Seriously.

Vista bugs are new, so they are a royal pain in the ass to trace. Microsoft is typically unresponsive at best and in a denial at worst. The most frustrating part is that bugs affect parts that were present in the OS and worked just fine as early as Windows 2000.

Just to give an example - installing a driver or a adding a device instance from a service causes a deadlock in the Setup module that can only be resolved by forcefully terminating the calling process. A deadlock.

They broke basic stuff and these booby traps are sitting in the OS waiting for a dev to step on them. And you bet I am going to leave a comment regarding the IQ of whoever's responsible after I kill two weeks chasing the results of their sloppy coding around this piece of engineering.

Re:Ask HN: Do you swear in your code? by tptacek on Monday June 16, 2008 @11:26AM (#218692)
Fuck yes it is.
Re:Ask HN: Do you swear in your code? by tptacek on Monday June 16, 2008 @12:14PM (#218733)
Addenda: is this perhaps the dumbest fucking question to be asked on this board? Fuckin' A right it is. Can someone draw a line between this topic and something that actually matters to a startup?
Re:Ask HN: Do you swear in your code? by xlnt on Monday June 16, 2008 @12:54PM (#218788)
if it doesn't matter, why reply?
Re:Ask HN: Do you swear in your code? by tptacek on Monday June 16, 2008 @01:02PM (#218793)
You might ask yourself the same.
Re:Ask HN: Do you swear in your code? by xlnt on Monday June 16, 2008 @02:18PM (#218905)
I replied to you because I was curious what you'd say. I am interested in human psychology.
Re:Ask HN: Do you swear in your code? by tptacek on Monday June 16, 2008 @02:20PM (#218908)
And you have confirmed how easy it is to bait me into snarky responses. Congratulations!
Re:Ask HN: Do you swear in your code? by xlnt on Monday June 16, 2008 @02:22PM (#218913)
Why are you getting snarky? I was perfectly serious. I think it's best to ignore silly things. Most people seem to give them a lot of attention. That's important. I want to know why they do that.

Possibly related, many people I know find it easier to think of things to say in reply to stuff that's mistaken than in reply to stuff that's accurate. So they spend more time engaging with mistakes than thinking about the good ideas they encounter. That's important too.

Re:Ask HN: Do you swear in your code? by tptacek on Monday June 16, 2008 @02:38PM (#218934)
Oh. I replied because it was fun to do so, and because I'm in an epic bout of procrastination.
Re:Ask HN: Do you swear in your code? by jrockway on Monday June 16, 2008 @06:02PM (#219171)
I have nothing against it, but I don't do it. The source code is not my blog; if I want to rant about something, I write an article about it.

Comments are for quick explanations of things that aren't obvious. Documentation is for explanation of the obvious. Blogs are for ranting.

Re:Ask HN: Do you swear in your code? by noodle on Monday June 16, 2008 @11:01AM (#218667)
i did in college, and also frequently used "TAMO" in comments

but then i joined a company that supplies source to customers.

Re:Ask HN: Do you swear in your code? by midnightmonster on Monday June 16, 2008 @12:23PM (#218747)
Do I swear under my breath when code doesn't run how I meant? Often.

Do I sometimes put dire warnings or florid descriptions of suckage or even rhyming couplets in my code? Yes.

Do I swear in code? No. Swearing is easy and imprecise. If I can't find a more useful way to convey my point, I'm obviously not firing on all cylinders and should take a break.

To be fair, nearly everything I work on is one or both of at least moderately interesting or for a good client. If I were working on something obnoxious for a boss I disliked, maybe I would swear. But even then I'd be more inclined to sarcasm.

Re:Ask HN: Do you swear in your code? by jasonlbaptiste on Monday June 16, 2008 @12:37PM (#218766)
// No fucking clue why the below line is there
Re:Ask HN: Do you swear in your code? by gaius on Monday June 16, 2008 @02:39PM (#218937)
Yeah, comments in my code are "notes to self" as much as anything. When I come back, I want to know what I was thinking. If I've commented like that it means I've thought about it and drawn a conclusion, rather than just skipped it as unimportant.
Re:Ask HN: Do you swear in your code? by gruseom on Tuesday June 17, 2008 @01:07AM (#219453)
In my experience, it's not "normal practice" but it's common enough. I don't like it, not because it's unprofessional as such but because it conflicts with the principle of removing everything extraneous. I think the best code is code that has been distilled to its clearest essence.

Edit: incidentally, profanity in code is not limited to comments. "White Like [name deleted]s Balls" is a variable name I saw once and have not yet had the good fortune to forget. I'll let you guys guess whether this was code distilled to its clearest essence. :)

Re:Ask HN: Do you swear in your code? by llimllib on Monday June 16, 2008 @12:28PM (#218756)
This is as close as I come, a comment from a few days ago:

> <%# All acesss to the message bar should go through the message()

> function defined above or kittens will be harmed %>

Re:Ask HN: Do you swear in your code? by kaens on Monday June 16, 2008 @11:28AM (#218694)
Sometimes, but usually only in code I'm using to wrap my head around a new concept that I'm struggling with. I generally don't swear in code that's going live, or public at all.
Re:Ask HN: Do you swear in your code? by brlewis on Monday June 16, 2008 @12:18PM (#218738)
The only F word I ever see in my company's code base is FIXME.
Re:Ask HN: Do you swear in your code? by root on Monday June 16, 2008 @12:17PM (#218736)
It is ok as long as only friends read it, "Haha, look, Johnny used a swear-word, he's such a witty guy" they'll say. But there may come a day that someone who doesn't know you reads that comment, without knowing you and your colorful personality and reading it completely out of context her first impression of you will be that you're a cantankerous old fart and she'll hook up with that dumb html-"programmer" instead.
Re:Ask HN: Do you swear in your code? by sapphirecat on Monday June 16, 2008 @01:41PM (#218831)
It totally depends on the culture of the company. At my last job, my boss valued 'professionalism' to the point where even sarcasm wasn't tolerated (even though I was right). My current employer doesn't seem to care, but most of the swearing remains verbal instead of going into code.

I personally prefer not to swear outright, in code or otherwise, but it's only a preference.

Re:Ask HN: Do you swear in your code? by kurtosis on Monday June 16, 2008 @12:41PM (#218772)
the only profanities in my code are throw and raise
Re:Ask HN: Do you swear in your code? by pavelludiq on Monday June 16, 2008 @11:59AM (#218719)
I don't have a habit of commenting stuff, so i do it rarely. I don't write allot of unclear code(tanks to python) so i don't have a lot of places to express myself in any other form but good code. I comment only hairy stuff. But i use swear words as a variable names sometimes if im not going to show the code to others, but they are usually not in English.
Re:Ask HN: Do you swear in your code? by SteveC on Monday June 16, 2008 @02:51PM (#218956)
No, but I make up for it when speaking normally.
Re:Ask HN: Do you swear in your code? by jeroen on Monday June 16, 2008 @11:12AM (#218675)
Always assume that what you write is read by others than you intended. That goes for code, documents, emails, and test data.
Re:Ask HN: Do you swear in your code? by underscore on Monday June 16, 2008 @05:29PM (#219142)
I do swear in code occasionally. If the cheap laugh is enough to make me realize that I need to step away from the computer and think about what is making me want to swear at it (stopping me from writing desperation code that breaks stuff and will get deleted later), then it is worthwhile, I think.
Re:Ask HN: Do you swear in your code? by grimoire on Monday June 16, 2008 @03:31PM (#219007)
For those of you who swear in your code base, I ask you this: is it ok in your company to swear in a meeting? The code you write isn't just for you, it is for everyone on the team, including people you haven't met yet. Is that what you really want to communicate to others?
Re:Ask HN: Do you swear in your code? by sah on Monday June 16, 2008 @04:34PM (#219088)
Yes, and yes. The last time I worked at a company where people didn't feel comfortable swearing in meetings was probably 1997. Honest and casual communication is faster, friendlier, and more enjoyable.
Re:Ask HN: Do you swear in your code? by TrevorJ on Monday June 16, 2008 @01:21PM (#218815)
I work in post-production graphics, and when troubleshooting particularly nasty problems I've been know to name some of my project assets things like "WhattheHelliswrong.mov"

I would not recommend doing this, but it definitely made me feel better.

Re:Ask HN: Do you swear in your code? by TrevorJ on Monday June 16, 2008 @01:15PM (#218810)
I work in post-production graphics, and when troubleshooting particularly nasty problems I've been know to name some of my project assets things like "WhattheHelliswrong.mov"

I would not recommend doing this, but it definitely made me feel better.

Re:Ask HN: Do you swear in your code? by tlrobinson on Monday June 16, 2008 @04:56PM (#219104)
Back in the day when the source code to portions of Windows (2000?) was leaked, the first thing many people did was grep for swear words. It turns out there were quite a few.

Just Google "windows source swear words" or something.

Re:Ask HN: Do you swear in your code? by scooter53080 on Monday June 16, 2008 @12:08PM (#218728)
No. Aside from the fact it's unprofessional, it makes you look amateurish if the code ever ends up public. This happened with some YouTube code last year, if I remember correctly, and that is exactly what it made me think.
Re:Ask HN: Do you swear in your code? by attack on Monday June 16, 2008 @07:22PM (#219226)
Better code than you will ever write was written by people who swear a ton. Strange how that is.
Re:Ask HN: Do you swear in your code? by keefe on Monday June 16, 2008 @04:10PM (#219053)
I swear in code like I swear in life, only rarely and with great motivation. If I am going through code and see an "F bomb" I know I did something seriously wrong in that bit of code that I didn't have time to fix.
Re:Ask HN: Do you swear in your code? by watmough on Monday June 16, 2008 @09:12PM (#219282)
I have certainly disparaged the Oracle optimizer on occasion.

However, I don't believe it's appropriate to swear in code, and that any examples would be expected to come back and bite you on the bottom.

Re:Ask HN: Do you swear in your code? by MaysonL on Monday June 16, 2008 @06:47PM (#219207)
I once inherited the maintenance of a PL/I program whose acronym was CSALDE.

The first line of source read

/* CSALDE - Custodio Sum At Lois' Defecatio Est

Is it OK if your s bombs are in Latin?

Re:Ask HN: Do you swear in your code? by idigthought on Monday June 16, 2008 @05:50PM (#219161)
i generally don't swear in code that the rest of the company will use.

more than anything else, i swear at the code.

Re:Ask HN: Do you swear in your code? by st3fan on Monday June 16, 2008 @01:59PM (#218872)
No. Because it is unprofessional and immature. It adds nothing.
Re:Ask HN: Do you swear in your code? by jamongkad on Tuesday June 17, 2008 @03:30AM (#219545)
Nope I personally find it distasteful to do so.
Re:Ask HN: Do you swear in your code? by mkull on Monday June 16, 2008 @01:03PM (#218794)
abso-fucking-lutely
Re:Ask HN: Do you swear in your code? by magus_pwnsen on Monday June 16, 2008 @01:46PM (#218842)
Generally, I don't, and my last job was at a hedge fund. (Sailors, I hear, have a reputation for "cursing like a trader".) I get nervous enough about other people reading my code as it is; no need to make the process (imperceptibly) more volatile. In any case, swear words aren't descriptive enough to make for thoughtful comments... usually.