Why no caps for comments?

I made a few feeble attempts. starting a sentence without a capital letter - no way! Muscle memory and the habit of decades. But I don't get it. Is the sacrifice of correct punctuation really worth the gain? What, an extra tap on the Shift key? Which is how I suppose the practice started for real programmers, coding in volume? What about the untidiness of the rest of the comment? Are commas, semi-colons etc abandoned too? And the occasional multi-sentence comment?

P.S. I straighten askew picture frames too.

Eh?

What do you mean no caps for comments? Where are you typing comments and what is preventing you from using capitals? I don't understand.

I get more annoyed about comments that don't match the code that they refer to than about how terse or badly laid out the comments are

Is this really a Programming Question or does it belong on Bar Sport ?

3 Likes

I also don't understand you questions. There a few best practice rules for a good name convention but all of this is not defined by law. So basically you can write your code as you want, but it's probably not good to read for third persons which want to review your code.

It's a individual decision. There are programmers who using comments thrifty indeed. But in better organized project the documentation is generated by tools like doxygen which can increase the readablility instead of inserting tons of comments within the code.

You also have to consider that it can create a lot of effort if you want to documentate each function in detail. A lot of programmers want to create functional code and don't want to write big documentation "books". At the end it's a individual problem and in companies a question of the requirements of the management

You can see an example of the common style @Terrypin is referring to here:

Note that the "p" in "put" is not capitalized.

I think the style makes sense in the case of short comments that are not complete sentences. But with a complete sentence I would use proper capitalization and punctuation, and even more so for a multi-sentence comment.

1 Like

Surely it is not a decision at all as to whether the comment should match the code

I've vaguely noticed that some comments are not capitalised, I've never thought much about it beyond it being the style of the person who wrote the code. My comments are capitalised, and I notice those of many other people are too. Do what works best for you.

4 Likes

Some? I have a thousand or more sketches accumulated for learning and reference, from scores of sources, online and paper. (Must get around to some house-keeping) . I’d estimate the proportion with uncapitalised inline comments as about 99%.

Just had a look through sketches in Latest and have yet to find one that capitalises as I do.

I learned the hard way how important comments in my own code are. Several sketches I wrote a few years ago, now puzzle me completely why I did certain things the way I did them. Or making me to search in the datasheet what a particular register does.

For short comments only to clarify the function of a statement or register I don't capitalize. I save the capitals for names.

example:

ISR(USI_OVF_vect) { //interrupt service routine when USI timer overflows
  USICR |= _BV(USITC);// toggle the SCL port by writing one to this bit
  USISR |= _BV(USIOIF);// clear the USI counter Overflow Interrupt Flag
}

For longer text explaining what the sketch is for or why I do something I tend to write normal sentences, but put them in a comments block.

example:

/*************************************************************************
   Attiny85 two tone beeper on SCL pin PB2 (mis)using only ADC and USI
   Uses none of the 8-bit timers or watchdog timer)
   Connect a passive beeper to SCL pin PB2
   Connect a (10K) potmeter between GND<>RESET<>VCC
 *************************************************************************/

And it makes it easier to share my code with others.

1 Like

OK, so that shows you've paid it more attention than I have. I'm sure you will have noticed that I have written a few tutorials. If you read a bit further at the end of the tutorials you will see credits and thanks to the people who have helped me. When I write a tutorial I usually ask for help and feedback, because getting someone else's opinion is really, really helpful. One bit of feedback I am sure I have not had is 'don't capitalise your comments'.

If you read lots of topics on here you will find replies suggesting adding comments to code, you will find replies pointing out that the comments do not accurately indicate what the code does. I have yet to see a comment that says 'comments should not be capitalised', I challenge you to find such a comment.

Your code must comply with the rules of the language, C++, otherwise the compiler will tell you there's a problem with it, or worse, the compiler won't complain but you will get some weird problem when you run it. Comments are your own business, as I said before:

And don't worry about what other people will think. If the comments are clear and explain the code well people will think how nice it is to read well commented, understandable code, they won't fret over some capital letters, but if they worry only about the capital letters, then really, pay attention to someone else who doesn't.

1 Like

Not when you are working on a codebase collaboratively. In this case you should be consistent with the established code style, including comments.

1 Like

I'm a rebel...

I think in the context that @Terrypin is, I think, concerned with, I feel confident in saying that comments are his own business.

1 Like

An eye for detail can be a curse. The important thing to remember is that not all details are important.

2 Likes

Thought it was interesting to see just now that ChatGPT shares my style!

Although I note it doesn't go so far as a full stop at the sentence end.
:slightly_smiling_face:

1 Like

Yes. When you type with two fingers, capital letters are a PITA. Since most comments are fragments, it does not make sense to hold them to rules meant for regular writing.

Worst: variables names using underscore characters. Especially if you use a few different tablets and each hides that character in a slightly different way.

a7

those two comments

are what drove me to replace the bareMinium sketch...

I got soooo tired of getting rid of those :slight_smile:
so long time since I noticed the absence of capitalisation (if I ever noticed).

2 Likes

Yea, Bar Sport. So, I’ll throw in. Seeing poor language practices in comments doesn’t bother me nearly as much as (allegedly) native English speakers posting nearly unintelligible questions and requests for (free) help in places like this forum.

My god, take some time to organize your thoughts. Express them in proper English paragraphs. Use complete sentences with proper capitalization and punctuation. While you’re at it, run the text through a spell checker before posting it.

You’re not texting your friends here; you should be communicating like a technical professional to other technical professionals.

4 Likes

Yes. I almost always use the simple hyphen/minus sign. Apart from the underscores's visibility issue, it too needs the Shift key.

I like spelling out the datasheet's acronym from the datasheet to help search for it :

USICR |= _BV(USITC); // Toggle Clock Port Pin