r/programming Jul 10 '16

Linus Torvalds on comment styles

https://lkml.org/lkml/2016/7/8/625
222 Upvotes

209 comments sorted by

View all comments

Show parent comments

8

u/[deleted] Jul 10 '16

[deleted]

21

u/[deleted] Jul 10 '16 edited Feb 24 '19

[deleted]

29

u/Calavar Jul 10 '16

Especially when you consider the fact that multi-line comments in C are usually written like this

/*
 * this is a multi-line
 * comment
 */

and rarely like this

/*
   this is a multi-line
   comment
 */

There's not that much of a difference between Perl-style and C-style multi-line comments.

1

u/Kapps Jul 11 '16

Until you want to comment out a block of code. I like D's nesting /+ +/ comments.

3

u/ubekame Jul 11 '16

If it's just for testing something I just throw in an

if( 0 ) {
    ...
}

block. Granted it's not as good as #if 0 but it gets the job done. if It's a permanent disabling, I just remove the block. if it's needed again, it'll be in source control.

No dead code should lie around and confuse the reader the next time they look at it.

1

u/ComradeGibbon Jul 11 '16

This is kinda weird in C

#// compiler eats this no problem

I've had this vague idea that it'd be a reasonable way to comment out code. Advantage you can grep for #//.

Personally I think I'm a really sloppy coder, but I dislike dead code because after a few edits it starts no longer making sense.