Sweary source code comments a sign of competence

It’s cheaper for my current employer to let everyone continue to work from home, but if they do that, they’ll end up stuck with $4T in office space they won’t be able to sell profitably. So they are forcing everyone back into the office and hoping the rest of wall street will follow along, propping up the commercial real estate market for now.

2 Likes

I feel you… and at points likely caused someone else to make sweary comments about my code.

1 Like

I like to think that stock photo represents the woman smiling after having just added some truly shocking obscenities in the comments of the code she’s working on.

First there was the study that supposedly showed that people who swear a lot have larger vocabularies, now this. Call me cynical, but I think there are some expletive-flinging researchers out there looking for indirect validation.

3 Likes

Ah, so you’ve worked with industrial automation code… :thinking:

I’m aware of a legendary government codebase written in PL/1. Purportedly it is so dark and impenetrable that the sole developer continues to be employed in perpetuity as juniors fail, one after the other in two or three year cycles, to port it to a newer language.

I consider comments to be notes to my future self. These are often edited later with sweary comments at myself for having completely missed what it was that I was most likely to forget about in that chunk of code.

4 Likes

Where that “someone else” could very well be you from months or years ago. On more than one occasion I’ve looked at a piece of code, said “Why the <puzzled or profane word, depending on how bad it is> did they write it that way?” only to look back in source control to realize they was me ten years ago.

If I’m being charitable I’ll say I’ve learned a lot since then. :grin:

12 Likes

10 years ago? Try 10 days ago. 10 days ago me was an IDIOT

8 Likes

…but not to excess.

These are pretty sweary:

5 Likes

always write tests first, then port. this is the way

i always wonder, was i drinking again? my former self often makes the stupidest of mistakes. i don’t understand him at all. seriously.

3 Likes

In every complex problem there are points where it’s frustrating and you can’t figure out why it doesn’t work and most of us start swearing (my Mormon colleague would never swear in code or speach).

If my code comments get sweary or just odd its mostly a sign I didn’t give up and fought through to figure it out (someone recently pointed out that a model I published in 2018 has a comment “this is a madhouse, but its a madhouse of my own making. I can change it”).

Swearing in code comments might just indicate the coder didn’t give up when pushed to the point of screaming obscenities at the computer

4 Likes

Just out of idle curiosity, has your boss ordered you to show him screenshots of your code so he can evaluate it?

8 Likes

Beautiful example of the advice I was given early in my career: “Write your comments as though your code was going to be maintained by a violent psychopath who knows where you live.”

5 Likes

5 Likes

Back in my coding days: I had occasions where, a year or so after creating some new code, I went back to it to add new functionality. Invariably these two thoughts would arise while reviewing:

  1. wow, was I drunk when I wrote this?
  2. how the hell does this even work properly (and yet, it did…)

:man_shrugging:

5 Likes

I, too, wrote Perl. :smirk:

aka, “either this is a brilliant regex, or the cat jumped on the keyboard”

6 Likes

I have had so many arguments with no-comment purists who are apparently convinced that their code is so special that it needs no comments for context, business cases, “we did this because something else has a bug”, etc.

“But the comments always get out of sync!” Then you are neglecting to make the necessary changes in your code when it needs to be fixed, aren’t you?

6 Likes

This was actually video processing code in C++. There were definitely a few sections where I’d clearly used a lot of trial and error to get the desired result, and returning to the code later I had a much better picture of how the process worked - and could usually optimise and simplify at that point.

2 Likes

I can’t even fathom this argument. Me: “the code is right there. If you can’t fix the comment when you fixed the code, stay out of src/

5 Likes

So, when you write your comments on the punchcards, do you use a pencil or a biro?

3 Likes

I mean, OK, but daily I read comments that aren’t true about the code that follows them, usually because they were once true but changed.

I think it’s possible to be wrong about comments in both directions. I have coworkers who comment almost every line and it’ll be like

initialize x to 1

x = 1

And I know people who almost never comment. I am not a prolific commentor. Instead, we do PRs with each other, and we try to do a good job, Before I submit a PR of my own, I review my own code. I start writing comments on the PR that indicate what things are - usually it’s stuff like “the reason this is being removed here is I moved it to file X” or “this is no longer used” etc. But if I start writing stuff that explains why something is implemented the way it is, I usually delete that PR comment and put it in the code.

I usually also take this personal-PR-review-time to look at functions I added and see if they’re completely described by their name and arguments, like “add_post_to_user(user_id, post_id)” or if there is something subtle or unexpected or not completely described from the name. I usually end up adding at least a docstring comment that says what the function is (and is NOT) for.

I don’t think there are good hard and fast rules. It’s an art and a moving target and I accept that I am often wrong about how much I comment. If anyone asks for more detail I will always go back and add it. It can be very difficult because I am experienced and good at reading code - I am way more likely to look at the code for a library than it’s documentation.

2 Likes

It’s just the laziest possible argument for “comments are bad”.

Comments are bad? Cool. Make sure the source tells me why you’ve made the choices you did here. And I will bounce it in code review until it does.

2 Likes