As a rule, I don’t put profanity in code comments. It’s unprofessional, if occasionally tempting in the extreme — especially after spending eight hours trying to work around an API or operating system bug to get your widget working on that last 5% of machines, only to find that it still fails.
Apparently a lot of developers aren’t as professional about it as I am, though.
It turns out that C++ is the king of code-comment profanity. No real surprise there, as a complex low-level language it’s bound to provide developers with many opportunities to swear. What is surprising, to me, is that JavaScript and Ruby are nearly at the same level. I’ve never worked with either language, so I can only speculate why, but I have to point out that neither is a low-level language so they don’t have that excuse.
Python and PHP are the ones at the lowest end of the scale. I’ve only used PHP rarely and for the most rudimentary things, but I’ve gotten a lot of practice with Python, and I can tell you exactly why: it’s a dream to work with once you get used to it. When my nine-year-old nephew wanted to start learning to program a few months ago, I gave him an ancient laptop with Ubuntu Linux on it and started explaining Python — within a couple days, he was writing simple GUI applications via the wxPython toolkit, with little help from me. He’s a smart kid, but the language itself had a lot to do with how fast he could pick it up.
I was a little surprised that C rated only a little more than half the profanity of C++. I’ve done C programming, in the bad old pre-C++ days. It’s a less-complex language, but even more low-level, so I’d have expected more profanity in it. But then, few young or hobby coders work with C these days. The average C coder is generally older than the average C++ one, with a correspondingly higher level of experience and discipline, so while users of C might have more reason to curse, I suspect they keep it out of their code for the same reasons I do.
Anyway, it’s amusing to an old programmer to see the comparison.