Matt Gemmell

TOLL is available now!

An action-thriller novel — book 2 in the KESTREL series.

★★★★★ — Amazon

C discourages commenting your code?

development 1 min read

Of all the code-commenting styles available to me, I definitely prefer C-style comments. That’s these ones, for those who aren’t familiar with them:

/* Do something particularly clever */

The problem is, they’re extremely difficult to type. The slash is fine; it’s just along from my M key. The asterisk, however, requires me to hold Shift and press 8. I usually do this by pressing the left Shift key with my left pinky, and pressing 8 with my right forefinger. The trouble is, it’s uncomfortable, and punches a hole in the flow of my typing.

I’m someone who very strongly believes in commenting code. I actually follow that principle; I comment my code fairly completely (without going to ridiculous extremes, of course), but C-style comments make it physically harder for me. I have this one-two movement between the slash key to the 8 key to orchestrate every time I want to begin or end a comment, and it forces a pause in my train of thought. I also need to make sure to synchronise the movement with my left hand pressing the Shift key, which adds further difficulty. Now, I don’t have any physical impairments - I have no trouble with typing. Indeed, I type very quickly - it’s easy to miss the Shift key when you have this forced hopping movement every time.

I’m aware that, for the most part, I can avoid this problem by using C++-style “to end of line” double-slash comments, but I don’t like the appearance of them, nor the fact that they can’t span linebreaks. I like the idea of multiline comments, and I use them constantly - I just wish that the delimiters were easier to type. If you want us to comment our code, make it a bit easier on our poor hands!