I don't personally care about language choices in code, but I'll play devil's advocate and speculate as to why a business might be concerned.
1. Reputational harm in the event that code needs to be shared. Say, the code gets read in court, or an outside consultant is brought in who is given access to the code. The company likely wants to maintain the same standard of professionalism that they expect when their employees write or utter spoken language in the workplace for the same reasons.
2. Similar to #1 but nuanced enough to deserve its own mention: code is a business asset. It can be sold or licensed out. The company may fear that language that it deems unprofessional could depreciate the value of that code in the context of selling or licensing it to 3rd parties.
Personally I think that the fuss over "bad words" is deeply irrational to a religious degree. The idea that arbitrary sequences of phones or characters will cause anyone within ear or eye-shot to become offended is rather absurd. But you can't choose what planet you do business on and, on Earth, there are a lot of silly people.
Yeah I had a coworker who put salty MessageBox.Show debug messages in the code, and one day while demoing the software a pop up appeared that said “BITCH!!!”
Needless to say the customer was not amused. So the simple solution is just ban the bad words from the source code.
> the same standard of professionalism that they expect when their employees write or utter spoken language in the workplace for the same reasons.
Depends a lot on the culture. In the countries I've worked in, anyone trying to forbid profanity in the workplace would be laughed out of the room. The laughter would likely turn to anger if it turned out to be Americans trying to impose puritanism on another country's project
3. Some of your coworkers may be among that group who finds it offensive or jarring. Maybe this is irrational, but we all are. I bet there's a sequence of ASCII bytes (say, art of certain infamous images from the early internet) that you wouldn't like to stumble across either.
I can swear a lot while talking. I have never written a curse word in my code, especially professionally. Just seems odd and not useful? I wouldn't be offended if I came across one, but it seems weird to use in a professional setting? A lot of the times I have seen inappropriate words used were not in any context and were used as a "joke" when logging/debugging. So "dicks 01" or "fuck me 01" instead of a bland "check 01" or whatever. For some reason, that seems much more unprofessional than a comment like "this code is shitty but works, need to clean up."
The contextless swearing seems so unnecessary and adds nothing to the code, whereas a comment with a curse word in it reads way more human.
> The idea that arbitrary sequences of phones or characters will cause anyone within ear or eye-shot to become offended is rather absurd.
I find your assertion to be absurd. Do you really believe that no one should ever be upset by something someone else has said? If so, you have a huge misunderstanding of nearly-universal human behavior.
Also 3, fear of reputational harm if the code leaks. Microsoft got a lot of PR for curse words in code that leaked, and then they locked it down.
3) in case the code is open sourced or leaks, the company might get cancelled, especially if it's the n or r word.
>The idea that arbitrary sequences of phones or characters will cause anyone within ear or eye-shot to become offended is rather absurd.
No more absurd than the notion that a mere sequence of sounds could convey any other meaning or elicit any other response.