17

As a programmer, I often use the term "Remove commented out code" as a commit message when checking in code. I wonder whether this is correct English.

To use an example outside the realm of programming, consider these two phrases for contrast:

"Help the poor people"

"Help the left behind people"

The first seems reasonable, while the second sounds clunky. Is it grammatically correct? I assume it could be said better.

What about my initial example? Is there a better way to phrase it or is it ok?

  • Comments are not for extended discussion; this conversation has been moved to chat. – Andrew Leach Apr 5 at 14:15
  • In a commit message, you are defining the actions you took in that commit. Defining an action that has been completed, is done using the past tense. So "Remove" should be "Removed". – Dylan Apr 5 at 14:44
  • A simple hyphen would make "commented-out" a compound adjective - and then it's fine. – TrevorD Apr 5 at 22:39
43

There is a better way to phrase it, but it's also OK. That is to say, in contexts other than a commit message, you would probably want to rewrite the sentence, but for an internal note, it's fine.

The main issue with the sentence is that you're using commented out as a compound adjective and so you should probably hyphenate the phrase: "Remove the commented-out code." Hyphenation would also improve your last example sentence: "Help the left-behind people" is better, but "Help the people who were left behind" is better still.

If I were trying to express the idea of your commit message in a more formal context, a context where prose style is important, or really any context without a strict and low character limit, I would write, "Remove the code which was commented out."

  • 90
    Your answer is grammatically correct, but it misses an important fact: "commented-out code" is idiomatic in the relevant domain of expertise. The phrase is widely used and well understood by programmers. I would not have a problem using it even in a formal context. Because "commented-out code" is idiomatic, "code which was commented out" is unnecessarily wordy and may intone smugness. – jpmc26 Apr 3 at 18:40
  • 14
    @Juhasz "User login" is a synonym for "account," not a user in the logged in state. The idiomatic short phrase for "users who are logged in" would be "authenticated users." "Logged-in users" would be recognizable but not idiomatic. More relevant to this question, "users who are authenticated" would certainly sound strange in most contexts. I'm not sure what the rest has to do with reformulating the phrase into "the code which was commented out." – jpmc26 Apr 3 at 19:30
  • 14
    Maybe it's just me, but for programming specifically, I'll agree and say "Remove the commented-out code" is better for a commit message. If the commit message was "Remove the code which was commented out" it leads me to sit and think, did mean that you removed code (for all practical purposes) by commenting it out? Or was there code, commented out, and was removed? – BruceWayne Apr 3 at 20:50
  • 8
    @jpmc26 Ack, be careful about universalizing your own dialect. Your criticisms are all correct, but "user login" is an event (a "user account" is just that), "logged-in users" is perfectly idiomatic (authentication can be performed in other ways, such as with OAuth), and using an adjective like "authenticated" in an adjective clause has more to do with the train of thought of the speaker than style. – chrylis Apr 3 at 21:25
  • 6
    Commit messages and idiomatic jargon are pretty far away from formal writing, there's no conflict here. Use "commented-out code" in your commits, tweets, and emails, use more formal language in your presentation to the Queen of Sweden. – barbecue Apr 3 at 21:43
28

Commit summaries (the single first line of a commit, and often the entire message) are a defined genre of technical speech because they have a specific role of identifying changes in a big list of changes and are limited to a certain number of characters. In particular, they are usually written in imperative ("Remove" vs. "Removed") and in headlinese for the same goal of fitting information into a limited space. Thus these are all considered helpful commit summaries:

  • Remove commented-out code
  • Refactor foo service
  • Add new SMS implementation for Bar Mobile

As noted elsewhere, "commented-out" should be hyphenated as it's a phrasal adjective; otherwise, the way you're phrasing it is stylistically preferred for this specific context.

  • 4
    @CJDennis It's not really harmful to do that, but it's more important to keep to 72 characters than to add lubricant. – chrylis Apr 3 at 23:53
  • 2
    Who says that in the 21st century it's important to not go above 72 characters? My commit messages sometimes have single lines longer than 72 characters, and a total count of thousands of characters without issues. – CJ Dennis Apr 4 at 0:06
  • 7
    @CJDennis It's fine on commit messages; I sometimes write multiple paragraphs. The commit summary, on the other hand, is processed by tons of tooling, and GitHub, for example, will truncate it. – chrylis Apr 4 at 0:35
  • 1
    From what I've seen, GitHub doesn't truncate it (i.e. only store the first 72 characters), but in certain limited views it will show the first 72 characters as a preview. The full text is visible in a different view. My advice is that if you need more than 72 characters, use them! A 100 character commit summary (without irrelevancies) is unlikely to go under 72 characters by changing it to "headlinese". – CJ Dennis Apr 4 at 0:49
  • 6
    @CJDennis you can use as many characters as you want in a message but 72 is the standard for headings which is the first line. I don't want to go back and forth between views to know what the summary of the message is - FEAT1234: Making changes to the authentication procedure to allow for Single Sign-On users is too long and it will cut of at allow for S. OK, I made this a bit too word-y but the idea is that a descriptive doesn't really fit. A message of "Change authentication for SSO users" is enough as a heading - write an essay as the message, if you want. – VLAZ Apr 4 at 6:44
-8

Just to add the pedantic view, 'out' is essentially redundant.

'Remove commented code' works, or to more accurately explain the commit 'Remove obsolete code' is probably better.

Having said that, 'commented out' is pretty much an industry term. If you wish to keep the 'out' (to differentiate from regular language comments that assist future readers, as opposed to comments that hide code from the compiler, I suppose), I see no need to hyphenate the term. It is common enough (especially among your target audience: commit log readers) to be immediately recognised and doesn't create ambiguity when left un-hyphenated.

  • 15
    'commented out' is pretty much an industry term — Right. And unfortunately for your first paragraph, so is 'commented code'! Commented code (especially well commented code) is a pro, not a con. "Gallant's code is commented. Goofus's code is commented out." (So "Remove commented code" would be less technically correct, but of course a human reader would supply the missing "out" from context.) – Quuxplusone Apr 4 at 5:59
  • 27
    Most people I know would consider "commented code" to refer to code that has comments in it, and "commented-out code" to refer to code that is put between comment markings in order to make the compiler/interpreter ignore it. They are not synonyms in the common usage that I know, so the "out" is not redundant. In fact, "comment out" is a phrasal verb modelled on "cross out", "scratch out", and "rub out", all of which have quite distinct meanings if "out" is omitted. – Robert Furber Apr 4 at 9:28
  • 16
    I agree with the other commenters. To me "commented-out code" has a very different meaning from "commented code". The latter meaning code that includes comments, the former being code that has become a comment and is now obsolete. They are not synonymous. – user2705196 Apr 4 at 11:59
  • 3
    I agree, so this answer is wrong: "commented code" and "commented-out code" are different things. What is more, "obsolete code" is different yet again: it usually won't have been commented out. – reinierpost Apr 4 at 17:30
  • 2
    @mcalex "After going through identifiers, key words, strings etc, I said all the dark green stuff was simply commented code ..." this is actually, technically, just wrong, and maybe the source of your confusion re: the responses here. The "green stuff" itself is not "commented code". It is code comments, commonly referred to within domain as simply "comments". It may CONTAIN code that has been "commented out" (meaning: rendered into being a comment). Code that has comments ON IT (usually to the right, or above/below) is "commented code"... to be actually pedantic. – taswyn Apr 4 at 21:40

protected by Andrew Leach Apr 3 at 21:45

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.