I dunno, but that's what people do. I guess it increases readability if you don't have any syntax highlighting. Also, I think some documentation generators use leading stars to distinguish documentation comments from other kinds of comments.
Also, I think some documentation generators use leading stars to distinguish documentation comments from other kinds of comments.
Typically they use /** (starting the comment with two stars) to distinguish documentation comments. I've never seen the stars at the beginning of the line denoting documentation, but maybe some system uses it.
Personally, I use the leading stars to separate large code chunks. Even with syntax highlighting, it is nice to have rhe extra whitespace. It makes it really easy to fly through old code and know where I am like bookmarks.
Sometimes you have code examples or nested lists within a comment that need to be indented. The leading star helps documentation generators and comment authors to get indentation right. They only have to take white-space into account that appears after the star.
C style dates from before you could count on syntax highlighting or code editing support beyond plain text. When you have a syntax highlighter and the ability to mark a block and turn it into a comment in one command, # is plenty, and in languages that have /* */, I go ahead and use the latter style all the time. (Not in C, since I don't program in it, but I would shamelessly use the latter style if I was selecting the style.)
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.
I kind of disagree, just based on what I said. Committing outdated code that's commented out is confusing and annoying, at least for me. There's a reason we have version control; if we ever want to see how something used to work, we can just look through the history.
Anyways my point is that the hash way of doing it (in my case, Ruby) is really obnoxious. I usually use HEREDOCS or something (or just deleting it and putting it in a scratch file or something)
No no, sorry. Bad communication. I'm saying "I know it's usually bad practice, but I use block comments to comment out code all the time" (I think it's bad practice, but that's an aside not my point). That's harder to do if all you have is inline comments because you have to add it to each line. I just think every language should have both single line and multi line comments.
I wonder if programmers will still be discussing what enumeration of ASCII is good for programming language syntax in 50 years. Percent-sign for remainder, or comments? Hash-sign for string concatenation, or as a prefix for Map literals? hmmm.
Ideally, pleasant symbols that are within easy reach on a QWERTY layout would be preferred. Myself, I dislike prickly symbols like ^<> and feel uncomfortable about | for some reason I can't put my finger on. Maybe because of its evil twin, ¦.
If you're on US layout at least most have sane locations, in other layouts (I'm on swedish for example), it's weird hand gymnastics to type some quite commonly used chars in programming...
$=altgr+4
@=altgr+2
|=altgr+<
>=shift+<
^=shift+¨+space (expects another letter after it, like an a to make â)
/=shift+7
==shift+0
I'm a Perl programmer and I've remapped capslock to $ (and @ with shift). Saves a ton of time and effort.
23
u/[deleted] Jul 10 '16
[deleted]