Live data from Hacker News

Open source code with profanity in comments is statistically better

blog.desdelinux.net

121–130 of 221 posts

Re: Open source code with profanity in comments is statistically better

#121

Earlier quoted context omitted.

That’s a pretty big leap IMO. What gives you that impression?

Not that commenter, but with 20 years of experience in open source I share their hypothesis. Language policing slows down technical progress, very significantly I would wager.

I guess I should put it another way. Sure it’s a valid theory, but I think asserting it as borderline self evident/a big enough deal that it primarily explains the profanity in repos is another matter entirely. I could also assert 5 other valid theories I’m sure. Doesn’t mean they’re all accurate or worth weighing.

So yeah, I’m just curious how those of you who responded to me are quantifying this.

Re: Open source code with profanity in comments is statistically better

#122

From the research paper: > we calculate the swear factor as the number of swearwords divided by the lines of code That's what I suspected. Assuming that most swear words will be contained in comments, what this is actually measuring is the ratio of comments to code. In other words, code that is more heavily commented is better. I think we already knew this. That said I would like to see a more critical analysis. Firs…

Isn’t commented code no longer considered a good idea in most companies? I used to work for a bank and the policy is no comments unless absolutely necessary, because comments become out of date. Doxygen is the only real comments allowed.

Pasting again my 4 reasons to leave a code comment:

1. An odd business requirement (share the origin story)

2. It took research (summarize with links)

3. Multiple options were considered (justify decision)

4. Question in a code review (answer in a comment)

And the article on how/what/why in code: https://max.engineer/maintainable-code

Re: Open source code with profanity in comments is statistically better

#123

My pet theory is that this is because honest, emotional comments are much more useful than the usual “professional” style that try to hide it when you have no clue what you’re doing. When it’s clear someone was stuck, frustrated, banging their head against the wall etc while writing a particular bit of code, you can refactor a lot less defensively because you know the crappy parts weren’t secretly there for a reason.…

I think so too. Profanity, in small amounts, is an indicator of honesty.

Everyone swears sometimes. If you never do it in front of others, it signals that you're always filtering yourself.

Re: Open source code with profanity in comments is statistically better

#124

Earlier quoted context omitted.

That’s a pretty big leap IMO. What gives you that impression?

Not that commenter, but with 20 years of experience in open source I share their hypothesis. Language policing slows down technical progress, very significantly I would wager.

If I find someone with 20 years experience that disagrees with your take, what then? I’m just wondering how y’all are quantifying this, as I explained in another comment.

Re: Open source code with profanity in comments is statistically better

#125

One rule I live by is I never ever swear in comments or commits, just not worth it. Even in personal projects. But one of my favorite projects to ctrl-f for "fuck" is in the jedi outcast source code. Since it is proprietary and was a good game: https://github.com/search?q=repo%3Agrayj%2FJedi-Outcast+fuck...

> Sign in to search code on GitHub

lolwat

Re: Open source code with profanity in comments is statistically better

#126

Earlier quoted context omitted.

Isn’t commented code no longer considered a good idea in most companies? I used to work for a bank and the policy is no comments unless absolutely necessary, because comments become out of date. Doxygen is the only real comments allowed.

Pasting again my 4 reasons to leave a code comment: 1. An odd business requirement (share the origin story) 2. It took research (summarize with links) 3. Multiple options were considered (justify decision) 4. Question in a code review (answer in a comment) And the article on how/what/why in code: https://max.engineer/maintainable-code

If the code doesn't speak for itself...

Re: Open source code with profanity in comments is statistically better

#127

Earlier quoted context omitted.

Pasting again my 4 reasons to leave a code comment: 1. An odd business requirement (share the origin story) 2. It took research (summarize with links) 3. Multiple options were considered (justify decision) 4. Question in a code review (answer in a comment) And the article on how/what/why in code: https://max.engineer/maintainable-code

If the code doesn't speak for itself...

…then I would suggest altering the code to speak for itself. If you can't do that any further, refer to the 4 reasons to leave a comment.

Re: Open source code with profanity in comments is statistically better

#128

Earlier quoted context omitted.

Isn’t commented code no longer considered a good idea in most companies? I used to work for a bank and the policy is no comments unless absolutely necessary, because comments become out of date. Doxygen is the only real comments allowed.

Pasting again my 4 reasons to leave a code comment: 1. An odd business requirement (share the origin story) 2. It took research (summarize with links) 3. Multiple options were considered (justify decision) 4. Question in a code review (answer in a comment) And the article on how/what/why in code: https://max.engineer/maintainable-code

I’d also add:

- The code is not self describing for some reason (eg duffs device, complex math, non obvious cases, etc)

- The code is correct but it looks intuitively wrong. This comes up every few thousand lines for me, where some conditional looks redundant or twisted up for some reason - like maybe there’s weird choices to keep the borrow checker happy. I leave a note to myself because next time I read that code I’ll want to “fix” it.

- Internal function preconditions / invariants. Eg, “this method must only be called while the XXX mutex is held” / “this code can only be reached when YYY is true because ”. Sometimes these checks can be cheaply expressed in assertions, but not always. And sometimes you need comments as well to describe the nuances of what’s going on.

Rereading my comment, maybe these are all examples of comments used to support code that’s not self describing. I’ve been programming for about 30 years now. I don’t think self describing code is always possible or desirable. I prefer fewer, longer functions with comments than digging through dozens of tiny functions spread everywhere. Large functions are usually easier to write and to read.

Re: Open source code with profanity in comments is statistically better

#129

Earlier quoted context omitted.

in procedurally written scripts, i write "what" comments as an outline or roadmap. i also use # vs // differently where the // style designates these what so i can find next to jump to next section. if i ever get away from being a solo dev and work as part of a team, there'll be a lot of unlearning personal habits

What you describe as sections seem like natural breaking points for function. Split of those section in their own named function. The names help to document, make it easier to test and the calling of the functions will give a high-level overview of the processes Ie: def drive turn_ignition() shift_gear() press_accelerator() end def turn_ignition … code end def shift_gear …

[deleted]

Re: Open source code with profanity in comments is statistically better

#130
post #62

Earlier quoted context omitted.

Isn’t commented code no longer considered a good idea in most companies? I used to work for a bank and the policy is no comments unless absolutely necessary, because comments become out of date. Doxygen is the only real comments allowed.

That's an idiotic policy and definitely not something that is industry standard. Code gets out of date as well, so let's just stop writing it altogether..

If code is wrong or out of date, the program will fail or stop doing that it's supposed to do. If comments are wrong or out of date, it will mislead the developer or at least confuse them if the comment says something else than the code. A wrong comment is worse than no comment - and usually developers don't care about comments as much as for the code. Why comment some code anyway if the code is easy to read? The only reason is to explain -why- something has been developed, not -how-.
Post reply on HN