How do people deal with profanity in source code and VCS comments. Keep or delete?
What about soft-expletives like WTF or Arrgggh?
Is unprofessional, offensive or something to be shrugged off?
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.
Sign up to join this communityIt should be gently discouraged
..you cannot possibly know who will get to see the source code over its' lifetime.
While it is all part of the job to get frustrated with a particularly complex or old piece of code and want to sound off about it, putting expletives/rants/ASCII art/bad jokes/offensive remarks into the source code is both unprofessional and a bad idea in my experience. Sometimes, the engineer writing the comments is oblivious to the eventual effects his comments could have - here are just some of the issues I've see:
While we all need to have some outlets for frustration/fun/japing about, the source code is not the place to do this, IMO. You wouldn't put expletives/jokes/offensive comments in a Contract, Help Pages, Blueprints, or other professional document, even though those documents may be read even less often than the source code.
If team leaders get all heavy-handed about it, there's going to be upset, so I say 'gently discouraged' by means of a quiet word with problem engineers and provided suitable venting mechanisms to let off steam, whether that be Facebook, instant messaging, air hockey or a punch-bag.
It's no defense to say that comments are compiled out either - what about JavaScript, or any other dynamic client-side code?
Here are some of the real-world experiences I've had that have shaped my opinion:
While working at Microsoft, I spotted that one software engineer didn't know the correct spelling of "couldn't" - he missed the o,l and d - and had peppered much of his code with long explanations of how he couldn't get X to work because Y person was causing problem Z. His code was great; his spelling was not so good. Suffice to say, any subsequent reviewer of this code (e.g. me) was alarmed to see a large number of random swears in the code. Some of this code went on to be shown to partners (driver writers). Imagine their horror at seeing the swears. The rants ideally should have been to the project manager in verbal form (in which case person Y may be pulled in to the discussion) or perhaps commit messages, but not in the source.
At one company, a foreign-language-speaking individual joined a predominantly english-speaking team. He wrote comments in his language, thinking that nobody else could read them. This was fine, until Babelfish/Google Translate released a 'to English' option for his language, at which point the rest of the team translated a few comments and were appalled at the filthy and often derogatory comments the guy had been making about the company, his team and a female coworker. Awkward.
At another company, one guy was really taken with ASCII art and put all sorts of art into his source code, unspotted (or perhaps blessed) by code reviewers. After a while, he dwelled on dragons, for some reason, usually with some kind of tag line. Later on, a Welsh person joined the team. The national emblem of Wales is a red dragon, so the new guy was initially cheery about the pictures, but then offended when some of the silly tag lines could be construed as offensive. Yes, some team leader mediation required, but this shouldn't have happened.
Names/specifics removed to protect the innocent.
If you're selling your source code (i.e. you're a component writer), it probably ought not be in there.
If it's a matter of prudishness, then well whatever, it's up to you.
If you see someone writing a lot of WTF's then maybe it's a sign that you should talk to them about the problems that they're having.
If someone is directing their aggression towards another persons code, then they might be harassing that person and you've got a completely different situation to deal with. Perhaps they have a legit complaint and don't know how to properly voice it. Perhaps they're just a jerk.
It wouldn't be wise to just have some sort of content filter, whatever a developer writes is important and it tells you a lot about how things are going.
I work for a Fortune 500 company that designs, manufactures, and sells consumer products that have µControllers running code developed in-house. Litigation is always a possibility, either from consumers hoping to get rich quickly, or by competitors claiming infringement. Because of this, we write our code and ALL comments with the knowledge that it may (probably will) come under the scrutiny of hostile jurors at some time. That means that variable and function names should not include inciteful terms, like KILL_CHILD(int process_id)
. While the purpose of this example function could very well be to terminate child processes, how would a hostile jury view that function name if the plaintiff's child was killed while using the product?
In-code comments can be even worse. While a decent defense team could probably handle explaining what a child-process is (from previous example) and why it might need to be terminated, it would be nearly impossible to defend against a comment like:
// The following section of code is REALLY BAD!!! I hope
// it doesn't burn anybody's house down.
Off-hand comments like that have been deciding factors in real court cases.
On a related topic, names for projects can also be damning when under the microscope of intense litigation. Do you remember the uproar from the conservative groups in the mid '90s when technology news sources reported "SATAN Unleashed On The Internet" ?
< rant_mode_off >
With all that said, for personal projects you are free to do what you like in your code.
If it bothers you and you are the head honcho, I don't see why you couldn't implement a rule about this. You are after all the leader in this hypothetical situation.
However, if it only bothers you and nobody else seems to mind maybe you should just suck it up.
I might not be the right person to ask since I often use light profanity.
I think it mostly depends on how PC (Politically Correct) your environment is.
If I code for a suit-and-tie company I'd try to not use profanity at all but if it's for a hobby project or something I tend to speak my mind more freely.
It seems to me that in the USA and some other countries people are a lot more PC (or stuck-up) than in the Netherlands where I live and work.
As an added bonus, here are some statistics on profanity in code: http://andrewvos.com/2011/02/21/amount-of-profanity-in-git-commit-messages-per-programming-language/
I'm inclined to agree that it can be quite unprofessional, but everyone cusses from time to time so I try not to hold it against others. That said, the codebase tends to reflect the overall professionalism of the group so an explicative laden codebase could reflect an unprofessional group and a meeting might need to be in order to "apply some polish" to the group. Likewise, if certain trends appear in the code, it could be an indicator of general problems within the group that need to be resolved (i.e. the API you are working with is has problems that are frustrating developers).
In terms of the codebase, I'll usually just edit the relevant comment to be safe for work and leave it at that. Depending upon the language you are working with, this is always a good idea as you never know what might appear in front of a client or customer.
Is this unprofessional, offensive or something to be shrugged off?
Possibly all three ... depending on your point of view.
It is human nature for people to express themselves using "colorful language" in certain situations. More so in some cultures than in others, and some people more than others. But the tendency is universal.
If I were you, I'd shrug it off unless you are willing to make yourself unpopular with your workmates.
However, if the source code / VCS comments get published outside of your organization, your management might want to take a stronger line, on the basis that it is bad for business to offend your customers.
One of the problems with profanity is that it's different from culture to culture. In the US innocent stuff tends to get "bleeped out", while in other countries often you can hear the same language exchanged in parliament discussions.
Profanity in code and commit comments is quite common, likely because of the "nobody is going to see it" view. I think that it's actually more common now that most organizations outlaw easter eggs.
I personally think that non-customer facing stuff (such as internal commit materials) is not that big of a problem.
However, most large multinationals are run by legal departments and "safe workplace" and all that stuff, which means that anything that could be offensive to at least one person is a problem and potential cause for dismissal. I hate to admit it, but I tend to bow to the regulations of those who pay my salary.
A quick solution to this problem is to install a profanity filter on your source control system (as a presubmit script or a regular check).
I think it's ok as long as it's not out of control like dropping f bombs over there. I have seen a guy I work with write a script between two characters discussing the various objects they each represent. There was a multiline comment that ran for like 30 lines of these two characters talking back and forth to each other.
/* * igor: shall I make myself public masster? * Frankenstein: ah igor, I shall inherit from your best traits... */
It went on like this for a long time. He created two objects called, you guessed it: Frankenstein and Igor as part of some sanity check. It was actually very creative but a total waste of time. I would have rather have seen a few WTF's or expletives than a screenplay between two C# objects...
Depends on the culture of the company/client. For example, if you are developing Bible software, expletives in any form are definitely unwelcome. On the other hand, a game developer might not care so much (or go to the other extreme).
I'm always of the mind that any comments (in code or commits) should be helpful. Certain words catch our attention more than others--expletives, even the soft variety, definitely are noticed. It can be be useful to call attention to something that is just plain wrong but you have no way around it just yet.
That said, I don't use expletives but I will occasionally use things like "Doh!" or "Huh?" which is not too different in spirit. If it bothers you, talk about it with the offender--s/he may not be thinking about it. If they tell you to take a hike and you feel strongly about it, go a rung up to the manager. If you get no support from the manager, then you'll have to learn to live with it or go elsewhere.
Well, I'm not exactly sure what else you're supposed to say about code like this:
tocommit = (n + (COMMITSIZE/PAGESIZE) - 1) & ~(COMMITSIZE/PAGESIZE - 1);
This code was pulled from a real, extremely crufty codebase I've been trying to optimize lately. (The code is open source, so I'm not revealing any employer's secrets here or anything.)
As others have said, it depend on the workplace and who will see the source code.
If I was selling the source code I would have a second repository of only released versions and not allow any checkin comment in there outside of a description of what each new version provides. What I do on the day to day and all my missteps are between me and my team, not my clients.
Currently my build server reports on OMG, WTF, kludge, mess and TODO comments as a metric of remaining cleanup to do so right now they are part of the process.
If you see profanity in open source software and want to get rid of it, prepare for the possibility of push-back. Don't just write a three line bug report, and expect it to get accepted. Write a mini-essay explaining why profanity and discriminatory language is bad, and pre-empt the rebuttals.
I think it's a matter of personal preference. That stuff doesn't really bother me, so I would probably leave it. Might even give me a hint into where the problem areas are in the code.
Do they bother you? From the fact that you're asking this question I'm guessing that they do. In which case, remove them or clean them up into more appropriate comments about what is wrong.
grep f.ck
on the source code of a Linux kernel. If it's good enough for them, it's good enough for me. But never ever put anything offensive in places where there's the slightest chance customers can spot it. I did it once and luckily we managed to pull the update in the last minute, but it wasn't fun. (Well, actually it was afterwards.)