Linus Torvalds In Sweary Rant About Punctuation In Kernel Comments (theregister.co.uk)
An anonymous reader shares a report on The Register: Linus Torvalds has unleashed a sweary rant on the Linux Kernel Mailing List, labelling some members "brain-damaged" for their preferred method of punctuating comments. "Can we please get rid of the brain-damaged stupid networking comment syntax style, PLEASE?" the Linux Lord asked last Friday. "If the networking people cannot handle the pure awesomeness that is a balanced and symmetric traditional multi-line C style comments, then instead of the disgusting unbalanced crap that you guys use now, please just go all the way to the C++ mode."Torvalds despises the following two comment-punctuation styles (with his comments):/* This is disgusting drug-induced
* crap, and should die
*/ and:/* This is also very nasty
* and visually unbalanced */Torvalds prefers the following two styles:/* This is a comment */ and:/*
* This is also a comment, but it can now be cleanly
* split over multiple lines
*/
* crap, and should die
*/ and:/* This is also very nasty
* and visually unbalanced */Torvalds prefers the following two styles:/* This is a comment */ and:/*
* This is also a comment, but it can now be cleanly
* split over multiple lines
*/
...I happen to agree with his stance on this particular issue.
/* this is a
* bad first post */
Because of shit like this. fuck you.
I like to make people work harder to figure out what I did.
And if you didn't agree, would you have changed your stance or argued that he's a crackpot?
“Common sense is not so common.” — Voltaire
What happened in his childhood to arrest his development? Any shrinks in the house?
those first two examples are hideous. I guess before I comment more I should read the article?
Linus has been known as an acerbic and rude individual, but he's never dared to touch the sacred unbalanced comment before. He's gotten bolder as we've taken his stuff. We really should have held the line, called an end to it before now. This is what we get for pandering to him.
It's too late to simply eject him from kernel development. We can't have him hectoring us from the sidelines. I'm afraid that we must entirely erase Linus Torvalds from the noÃsphere.
Think of it as evolution in action!
rot13: whfg xvqqvat
Bruce Perens.
No bugs left other than comment style disagreements? Rejoice, the year of Linux on the desktop can't be far!
For what it's worth, my single contribution to the Linux kernel fucked up some white space. Torvalds didn't notice or I guess I would have woken up in the burn ward.
https://regmedia.co.uk/2015/07...
in case you have yet to see it. ElReg changed it after Linus roasted them alive!
...they first cause comment syntax to twist their panties into a bunch.
Seeing as 'C++ mode' // comments were added to the C99 spec; this would be my preference. I've always hated all forms of /* */
At last a Linux development post where everybody can have an opinion! Gone are the obscure race conditions and unstable semaphores, where prudent programmers preferred to watch in silence and seem ignorant, rather than open their mouths and dispel all doubts.
Rome taught me patience and assiduous application to detail. Virtues which temper the boldness of great, general views.
Who cares what the f*** Linus Torvalds thinks?
Totally agree!
That's formatting.
Not to sound too troll-like, and not to discredit all of the great work he's done in the past. However, the Linux kernel is pretty mature at this point; it's been that way for years. Why do we allow this guy to march like we're in a race to develop a fully working kernel as fast as possible? My first 'distro' was from TAMU back in '93. Development has been going on for nearly 30 years! It's time to put a fork in it, and time for Linus to move onto something else. An engineer should know when a project is done.
Linus Trump has unleashed a sweary rant on the Trump Kernel Mailing List, labelling some members "brain-damaged" for their preferred method of punctuating comments. "Can we please get rid of the brain-damaged stupid networking comment syntax style, PLEASE?" the Trump Lord asked last Friday. "If the networking people cannot handle the pure awesomeness that is a balanced and symmetric traditional multi-line C style comments, then instead of the disgusting unbalanced crap that you guys use now, please just go all the way to the C++ mode."
If only Tove had found this out sooner.
Does he have a passionate hatred for spacebar indents too?
it isnt always ideal to tab indent.
really, bitching over comment style? i cant wait to see the commit logs--"correct unapproved comment style, no changes in function."
what a brave new world...
This is news?
Go ahead, point out where in here
labelling some members “brain-damaged”
is.
"your commenting style/code/idea/product/argument/... is stupid" != "you are stupid".
If you can't tell the difference, seek professional help.
As we step back and look at the overall quality of code these days, set to unleash that shitstorm on the IoT hell that will ultimately control the world around us...
...it sure is good to know that our "Linux Lord" has his /* fucking priorities */ straight worrying about comments.
Linus is right. I've been using the Linux kernel coding style as much as possible in all of my programming, regardless of the language, since around 1994. I get nothing but compliments.
When it comes to the kernel, the most important thing is writing code that other people can read and modify. Anybody can write new code. It takes an artist to write code that other people can easily understand.
/* I too can't stand the look /*
*of this*/
* Whereas I always try to use this
*/
First: I've had to use style cop. It sucks. ... we each have our own variation of 'style'; which can be seen here.
But
So, why not have a 'stylecop' that acts locally; on white space & comments? If I like 3 spaces, and you like 4; we can just get along. The style is formatted on view, not on compile.
This would also fix his problem: When he views it... it will 're-format' to something he likes to see.
How hard would it be to simply write a script to reformat all comments in the preferred style? Not that hard I imagine...
This comment will not be saved until you click the Submit button below.
You must wait a little bit (2 minutes) before using this resource; please try again later.
/* What's wrong with a comment
like this? An extra star at the star of this line would be
pointless, if you use a "format and fill" type formatter--- the
ending star slash will just be another word */
Extra stars just fuck up the formatting. Or do you like /* blah blah * I guess this used to be on a second line */
The fact that this is what he decides to rant about is... probably a good thing.
My preferred coding style happens to be Whitesmiths. (Go ahead and laugh, but I'm used to it.)
Since not much new stuff outside of my own is written in Whitesmith's style, I use astyle to reformat the the other guy's code if I'm going to be studying it or adding to it or whatever. I actually have astyle fully integrated into both Geany and vim (the two code editors that I use) so I can reformat code instantly on demand.
I've never paid much attention to comment styles as such, but I'm sure that you can use astyle to reformat that if you want to; it has a million-and-one options available to put out all sorts of cats and make coffee.
So if Linus or anyone else doesn't like a C style, it takes almost no effort to reformat it to the style that you want. Then everyone gets to look at and use what he's comfortable with, and there's no friction at all.
If you're a zombie and you know it, bite your friend!
Poorly created comments are the work of the devil, plan and simple. Imagine working on a piece of software after it's been in active development for 10 years.
Some libraries just work and nobody's even looked at the code for 1/2 a decade. Shitty comments will kill you, or worse others...
Linus can be a needlessly pretentious ass about things, but I agree with him on this one.
Yes Francis, the world has gone crazy.
The Donald Trump of software developers.
They are not comments, they are Perl.
Table-ized A.I.
We're talking formatting here.
You young whippersnappers don’t know how good you have it. In my days, we didn't have time or space for comments! Sometimes we splurged on variable names and used more than one character!
Are you joking or did you program an Apple II in 40 column mode?
Historical note, comments often followed the code when programming in 6502 assembly on the Apple. Devoting an entire line to a comment was a rare luxury. Ex:
label: lda variable ; Comment
Whether I'm using Eclipse, PyCharm, or Visual Studio I don't need to worry so much about this bullshit. You can set an IDE setting and the IDE will help you auto-format comments and other pieces of code.
I know.. I know. Real men are inefficient and use vi or emacs....
/**
* If you adhere to Doxygen style comments
* it clears this up nicely.
*/
/*Is this really the biggest thing on your "Shit Must Change" list, Linus? Wars, famine, The Kardashians... No, poorly noted comments is your soap box!?! Teeing off like a teenager with Tourettes. Their used to be a reason people over 21 were labeled as "adults" It would be nice if we could all live up to that minor title, Linus. Be an example...*/
I wonder when y'all will stop using a product made/approved/committed by this lunatic. Sure, thousands of kernel devs out there, but at the end of it, nothing happens without Linus' blessing. Not only is he a lunatic, he openly rejects security aspects of his product, calling security-minded people "masturbating monkeys".
I'm sure as hell not gonna put that crapware on my production machines. Y'all should try some BSD. Much less vitriol, much less toxins and crap, much more engineering wisdom and security.
I wish he would worry more about systemd and less about comments.
I agree with his sentiment, although I'd be a bit less colorful about it (i.e. "This is acceptable because... This is not because.... Sincerely.")
I absolutely hate ugly comments (and code) and spend a decent amount of typing time lining things up. How I've done is has evolved over the years (mainly as I've had to conform to different architects).
But seriously, if he feels that strongly about it, why doesn't he just write a comment reformatter that gets run on merges? Actually, isn't there an IDE that will autoformat code to your preferred style on the fly?
This guy will be great when he gets dementia.
/* why would you deliberately /* in it and
* and unnecessarily lengthen
* a comment by not using the
* first line with the
* ending with a */?
The unfortunate standard resolution of 1920x1080 already means consoles are pitifully limited in their ability to show many rows. Sure, I have a 2.5K panel at home (2560x1600 vs 1920x1080 doesn't seem like much, but damn it is) and sometimes I get to plug my laptop into a phat-booty 4K display and see whole functions on one screen, but not often. Why on earth would anyone wish to have code take up more lines than necessary?
Looking at other code sections by glance rather than by switching tabs or scrolling is like running in ram vs hdd swap concentration-wise.
And that's one reason why Linus gets so vitriol, Jackasses don't read his messages or forget what he said so he has to keep repeating them throwing in a little profanity so perhaps they will stick.
Then there are the jackasses who regularly interact with him who he starts to trust; then they throw in some bug ridden atrocity when they should know better.
/*
* Guys, I already see a lot of badly formatted comments here.
* I thoroughly agree with Linus here, comments should be correctly formatted.
* Unbalanced comments should be removed and boxed comments are right out.
*/
As usual. Linus us right. Glad to see him sticking up for the right way to code.
It won't be a problem. Linus won't be among the first up against the wall, come the revolution, but he'll probably go in the third or forth purge.
Lets start a 'things I hate' thread... I can't stand pluralizing database table names. Its redundant. Who is going to store one record in a table?
love is just extroverted narcissism
Balanced Lines Matter! No line justification, no peace!
Next worst are ego comments. Every inline function preceded by three line comment naming the author as though he is Leo Tolstoy or she is Jane Austen.
Next worst are trivial comments. Next worst are no comments.
Then comes badly formatted comments.
sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
If I like 3 spaces, and you like 4; we can just get along.
If I like 4 spaces and you like 3 spaces, then we should both use tabs. Problem solved.
Well, I am neither brain-damaged nor a native speaker, and it is pretty clear to me that, while he does call the unbalanced comment style "brain-damaged", nowhere did he call *anyone*, not even those who like that style, brain-damaged.
It is even clear in the excerpt, so you don't even need to RTFA to see it.
I'm more a fan of
this style myself
*/
be intolerant of what you write.
... just doesn't have the same click bait appeal does it? ;)
I think it might be fun to put Linus in a kitchen with Gordon just to give him a taste of his own medicine and vice versa
Those who get to the top of their profession are driven perfectionists who expect everyone else around them to strive to achieve that same level of perfection.
I get why they lose it with others less driven and focused.
Do they need perspective or should we just leave them alone to continue to be brilliant? I think the latter.
How does he feel about tabs vs spaces?
I'm more pissed off by the unnecessary leading *, since any editor worth a damn has syntax highlighting. It's his project though, so he can set whatever standard he wants and if you don't like that you can fork it. Once again, pretty much any style problem can be solved in the editor, and most editors already fix this problem; but that's just my opinion and it's worth less than his because I'm not leading a kernel project that runs bazillions of servers.
For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
/* ââ©â®(ÎY_ÎY)ââ©â® */
No soup for you!
Putting the comment opener on the same line follows K&R indentation, where the opening curly goes on the same line as the if(), while(), for(), or do. The sole closing curly, except where used in a do-while or where it starts an else-block, goes on a line of its own.
What Torvalds suggests, i.e. putting the opening /* of a multiline comment on a line of its own, wastes vertical space just as Pascal-style indentation of curlies does -- and without adding readability.
If this is an issue with Emacs' indentation, or reflowing, or whatever, then the editor should be fixed. Vim certainly handles this style perfectly.
I'd quite like to hear what the actual fuck is behind the cursing, this time. "Don't hold back now, tell us how you _really_ feel."
3?!? wtf?
...chill, man! Chill! I used to work for an a$$hole who was incredibly worried about the APPEARANCE of code. No matter if the stuff actually worked, if it didn't LOOK the way he expected, it was WRONG. That was a steaming, stinking pile of guano, and I quit that place. I am SO glad I did. Don't drive the good folks away, Linus. Chill! Chill!
I hated using Windows for years because I thought that Bill Gates and friends were assholes for their business practices. Now I hate Linux, not because Linus has evil business practices, just because he's as much an asshole as they ever were.
I prefer // for single line comments /*
for multiple line
comments
*/
.427 picas
Linux programmer has nothing better to do than bitch like a 17 yro west hollywood female high school student about the code's comments. Priceless. He's an idiot that gets WAY too much credit for writing a simple OS kernel.
Fuck you Linus. It's a Microsoft world. Take your meds and have a beer. Or just the beer shoved up your ass.
I tend to format my comments in Linus' preferred style, but really, so long as the comments are clearly delineated as such and contain cogent, up to date information, does it really matter if they're ugly as sin? Save the rants for misleading, obsolete or missing-when-clearly-needed comments. It's like going into rant mode because someone chose to format a journal article in word rather than latex: sure word will misalign the in-line equations and generally make the whole thing look like high-school maths homework rather than a serious document, but if the content is good and readable then frankly who cares?
/* No Comment */
Yo Dawg, I heard you like comments so I put some brain-damaged stupid networking comments within your comments so you can bitch about the brain-damaged stupid networking comment syntax style while you bitch about the brain-damaged stupid networking comment syntax style.
// Today I learned that Linus Torvalds is a fucking moron
// who can't pretty print C into ANY AND EVERY style he wishes.
All hail the diva...
"sweary rant" ? Are you online and offended because he gets pissed when people fuck up his work? You mean if somebody fucks your work up.. something as awesome as the Linux kernel.. you would be like oh #sweetheart it's ok
Get the fuck out Microsoft/US Government. Treason goes to Hell.
deep down you know it's true
it's tabs vs spaces or vi vs emacs all over again.
screw you and your idiocy of comments and cases.
if you can't parse code to make it look the way you want, then WTF have you been trying to achieve for 30 fucking years? dumbass.
'nut said.
If Linux aims for the same level of polish and stability, it's not a bad idea to do the same. Someone else will likely have to fix bugs in your code at some point. Having a consistent style of comments and other things makes it faster to scan visually and spot problems for someone used to that style.
That's kind of what tabs are for, but that only works if you ONLY use tabs and never use spaces.
Emacs has some garbage defaults where tabstop = 8, and electrical engineers seem to be incapable of that, so I would run into code where the first indentation was 4 spaces. 2nd level was a tab. 3rd level was a tab and 4 spaces. Then when I load the code in an editor who sets tabstop to 4, nothing lines up and its unreadable. I eventually modified my groups coding standard to just disallow tabs because of Emacs users and rejecting any PRs with tabs in them.
There are just too many places where the code is more readable by using spaces to line things up into tabelized formats across multiple lines for an automated system to really ever get this right unless you limit (especially with case statements, it seems everyone uses something different there).
I love three-space indent!
Not really, but that's actually what I use because work mandates it. Apparently there was a big debate in the early days of the company between 2 and 4, so they compromised. Much of our coding standard is based on one particular engineer who had vision problems and needed to keep the number of columns restricted.
But you know what? It works. Millions of lines of code dating back two decades, and it's extremely consistent. Ninety percent of the code looks like it was written by the same engineer. That's what you want on a major project.
Though I will say that I've come to hate tabs in indentation. They're fine until they're not. At some point you end up using some tool where they don't look right.
My pet peeve, though, is trailing spaces. Any code management system should be designed to strip trailing spaces or block commits that contain them. I've seen far too many code merges break because of a disagreement on trailing spaces, and that's just dumb.
I would never have anything to do with a piece of trash like that.
It's common email convention now, at least in my experience - when you respond to someone, you put your response on top, so as the conversation chain grows, the order is the most recent (and therefore the most pertinent) to the oldest, descending. So you don't have to scroll through pages just to see the last reply.
Back in the day, on newsgroups, if you did that you'd get absolutely SCREAMED at for "TOP POSTING", because it was WRONG.
From the guardians of all that is right and wrong.
/*
* some
* people
* don't know
* how to speak
* in public
*/
Why wouldn't he simply codify his preferences? I hear, he still holds some sway among Linux developers — once a particular style is accepted by consensus, it becomes easier to convince folks to follow it...
Interestingly, the style Mr. Torvalds prefers has been part of BSD's style(9) manual for decades.
Maybe, he should leave children's to children and join a real OS-project...
In Soviet Washington the swamp drains you.
which is odd since it's pretty much the only thing C++ did right.
How about leaving out the crappy asterisks at the beginning of lines? They suck.
It is amazing how some people can take a small thing, and totally blow it out proportion. Especially if they are famous...
My answer to Linus: get the bugs fixed
First: I've had to use style cop. It sucks. But ... we each have our own variation of 'style'; which can be seen here.
So, why not have a 'stylecop' that acts locally; on white space & comments? If I like 3 spaces, and you like 4; we can just get along. The style is formatted on view, not on compile.
This would also fix his problem: When he views it... it will 're-format' to something he likes to see.
Check out clang-format. It's by far the best code formatting tool I've used, and using it allows you to stop thinking about formatting. However, your idea of everyone reformatting the code all the time to their preferred style is silly. Set a project style, "document" it in a .clang-format file and require everyone to use it. Everyone working on a project can learn the project's style; the tool just helps to make sure that it's applied consistently.
Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
It could have been a tabs vs spaces rant
We all know that didn't work out very well for Richard Hendricks
Next worst are no comments.
I disagree.
Uncommented code that needs comments is bad, but the best code doesn't need comments at all. If I write a piece of code that requires a comment to be understandable, that's a hint that I need to step back and rethink that code. Maybe name variables better. Maybe pull a chunk out into a separate function so I can name that (that's particularly useful with those one-line comments that explain the goal of a block of code). Maybe reorder or reorganize it so that it's clearer.
Sometimes, after all I can do, I still feel like I need a comment so I write one, trying to keep it as concise, accurate and readable (including formatting) as possible. But I always consider that a failure and know that if I were a better programmer I could have avoided it.
The reason it's a failure and that it's better to avoid writing comments if you can is because comments are much less well-maintained than the code they describe. That means that comments often become obsolete (what you called the "worst comments"). Comments that don't exist can't become obsolete.
Note that I'm talking here about internal comments, not interface documentation, and especially not Javadoc/Doxygen/etc. comments which are used to generate API documentation. Those are very valuable and should always be written. Even those should be kept concise, though, and redundancy should be avoided. There's no reason to restate the function signature. If the function and argument names are well-chosen, they can often stand on their own. Let them.
Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
What an idiot. A child in a woman's body who wants to be a dog.
"In any dispute the intensity of feeling is inversely proportional to the value of the issues at stake."
I don't care if it's 90,000 hectares. That lake was not my doing.
I actually initially read it as "sweaty rant", and imagined Linus furiously typing the rant, with sweat dripping onto his keyboard. Probably because "sweary" is not a real word, and my mind sort of auto-corrected it to the closet match.
Don't fornicate. Seriously, just don't do it.
this is really how homosexual apple users think.
I've never liked multiline comments, they look stupid. I will write my comments the way I want in which they visually please and provide a point. Most comments are removed from compiled code anyway, so f**koff.
c++/java // this is a comment // on multiple // lines
or
' this is also
' a comment for
' the vb/vba/script crowd
So what is it, tabs or spaces?
What a wanker.
Humans ..er .. I meant Hackers .
The whole point of using C++ style comments is that if you want to experimentally comment out a block of code you can use C style comments to do so and get have it get all fucky if there are any comments within that block. Yes, pre-processor directives can get the job done just as well but not every editor is good about delineating the contents of a pre-processor block.whereas even freeware editors typically colorize comment text.
/*
* This is a comment
* I hate comments
*/
As it is only once I do it in a software project I will indulge any style that is requested.......
Bring it on!
Can't we all just use our comments sense?
----------------------------------- My Other Sig Is Hilarious -----------------------------------
Oh look, a developer with his own preferred style of formatting who thinks any other styles are an affront to nature. What a surprise. Let's all take him VERY seriously and re-evaluate if our lives are worth living any more. Or, you know, he could get over it.
He said "crap".
That's "sweary"?
Fuck.
Watch this Heartland Institute video
Slashod - site about bullshit and drama for people who like to think about themselves as nerds, but actually are just interested in celebrity bullshit drama.
It really does not matter which comment form is "the right one" nor whether this is horrible way to communicate with people or just slightly sub-optimal. It is still bullshit drama for people who want to feel like "techies" while actually spending their time with pop-culture like celebrity drama. And nothing more.
Give a developer a degree of freedom and they will take it. Have a strong coding standard and stick with it. That way when another team member inherits your code they won't feel obliged to rewrite it. What could be simpler than having a one line and multi-line comment styles?
I don't agree with this viewpoint at all.
I have been working on some scientific simulator code and the comments have the math equations that a block of code is based on. It makes it so much easier to understand since it is often not obvious how an equation is mapped into implementation (things like discretization make things far more complex).
Comments should not say what code does it should be why. I don't need you to see that your code is adding up a bunch of numbers but knowing why it is doing it is very important.
Computer modeling for biotech drug manufacturing is HARD!
The most important comments are the ones that specify "why not". Often we will implement the interface using some methods, after release we find the inadequacies and change the implementation. Often the first implementation would be simple, intuitive and the first thing anyone would think of. Now that implementation is gone, and new less obvious and often tricky things are introduced. If the "why this and not that" comment is missing, a later code review might remove the complex second implementation and restore status quo ante.
It is important to document why it is not done that way, what we intend to do. Without it we will be forced to constantly reverse engineer to understand the code and might repeatedly re learn the same lessons over and over again.
sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
TECO will solve all your problems.
Fiat Lux.
I have been working on some scientific simulator code and the comments have the math equations that a block of code is based on.
That is absolutely a case where comments are essential. Ideally, they should not only contain the equations, but something of the derivation of the mathematical expressions and the rationale behind their use. In some cases it *may* be possible to write code in such a way that the expression itself is clearly expressed in the code, so a comment specifying the expression would add nothing... but even in that case an explanation of why that expression is appropriate is essential for any future understanding of the code. And in many cases the constraints of the programming language to not allow easy, direct statement of the expression, either, and then the comment that contains the mathematical representation is essential.
I'm not claiming that it's always possible to eliminate comments, but they should be eliminated whenever it is possible, and whenever you find yourself needing a comment you *should* take a step back and see whether it's possible to make the code clear without one.
Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
His points are completely valid, so I suppose the real story here is the audience's reaction and how divides us into
- those who understand and appreciate the value in comments and folkowing coding standards and the unwashed masses who don't
- those who agree with Linus's communication methods and those who find them objectionable and unprofessional.
... even the greats can go OCD on you.
I totally agree with him and I don't see why anyone would use the other comment style, which is very less practical
The most important comments are the ones that specify "why not".
Like complex mathematical derivations, that's another case where comments may be essential. My recommendation isn't to eschew all comments, it's to avoid duplicating in comments what can be just as clearly expressed in code... and to work hard to try to express the information in code rather than in comments. Doing so will make your code cleaner and much more maintainable.
My code isn't comment-free, but it is comment-light, and I think it has gotten much better since I adopted this policy (which, BTW, I should be clear that I didn't originate. I got the idea from one of Robert Martin's books on code craftsmanship.).
Some examples might help. Consider this case, where I had to write a comment to explain why not to do something. Or (to pick a section from the same file), look at this case which is interesting because the comment is very large -- as large as the code that it documents -- and because I think that without the comment it's really not clear why the code is doing what it's doing. I have toyed with various ways of refactoring that code to eliminate the need for the comment, but short of using something like a strategy pattern I can't find one that does the job. And even a strategy-based implementation would still require me to both ensure that the strategies are applied in the correct *order*, and to document what that order is.
Doh! I just noticed that that long comment has bit-rotted a little. It was originally written when the code only handled options 1, 3 and 6, so the concluding paragraph doesn't explain about options 2, 4 or 5, or why they're tested in the order they are. That example is an even better one than I thought, since it demonstrates both the need for and risks of explanatory comments.
That SoftKeymasterContext class, however, is an exception to the rule. It exists specifically to address a bunch of unusual corner cases and so it's not surprising that it requires much more explanation than 99% of code should. Here's a better example (chosen more or less at random from the same project) of what comment-free code should look like.
Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
I once got a few points knocked off my working code because of comments. I was told I didn't have enough General comments. My next program had nice blocks of comments about General Lee, General Custer, and many other famous generals. My instructor wasn't nearly as amused as I was. Imagine that.
I only look human.
My mother is a halfling and my dad is an ogre, so that makes me an Ogreling
It's not the style or format of the comments that offends, or great one.
It's the fact the most of the comments are unreadable or contain no useful information.
Fight the second battle first, then clean it up.
Which, of course, is exactly what you should be doing.
That interpretation requires that comments have brains. They don't. So this particular remark can reasonably be read to impugn the author of the comments. However, it's also extremely likely that this is a case of hyperbole; in which case smiles are called for, not outrage.
Yes, English is annoying. Linus can be, too. :)
I've fallen off your lawn, and I can't get up.
You do realize that you can write object oriented code in C with structs and function pointers, don't you?
Take a look at Berkeley Sockets, as you go up the networking stack structs extend other structs, which is OO design.
In the real world, "learning some other guy's code base" sometimes would indeed take more time than rewriting it the first chance you get.
If you haven't learned what something does and how it does it, then how the f*ck are you going to succeed at rewriting it?
By re-implementing the functional requirement that is supposed to be met by the God-awful complicated (and most likely buggy) code from scratch. Typically you have to delve into existing code to integrate or to fix something. Most often to fix something. So in those cases:
Think clean-room re-engineering from specs. This happens all the time, a system or function F that is supposed to do A, but that it uses too much memory, or it is too slow, or it leaks resources.
Whatever, but you know what F is supposed to do.
And the code behind A is just nasty and impenetrable, so hard to untangle to simply fix what is broken.
So you implement it from scratch so that it does A without all the other unwanted shit. That's how it is done all too often in the real world.
(every) Server routing stack is crap, unscaleable. No self respecting routing company in valley uses it unmodified. /*
If you every worked for cisco, jnpr you will realize we comment this way : (php crap will probably reformat this comment).
* fuck you linus
*/
He's gone full fruit loop. And he has full transformed himself into the punctuation police. This indeed is a sad time. While yes I agree that there are some comment styles that are visually more appealing than others I would say that I am more interested that I see any code documentation at all.
Dude, that's what gnu indent is for...
I've had this thought for a very long time. We are now at a point where presentation and content can and *should* be separated so as to benefit the end user. Devs do this all the time for the myriad formats that the plebs want for their own petty purposes. Why can't we do this for ourselves?
I think something like this will eventually show up on top of a layer like LLVM. The only difficulty will be selling it. Not sure, but it might take some kind of "killer app" for devs before adoption.
At best your code can explain what it's doing, but not why or how. I mean, it's great that I can see you frob and then swizzle. But why frob first and swizzle second? Why frob at all? Why not frobnicate instead?
dom
has gone to his head.
./*bad
/*
good
*/
*/
is not the worst programming problem I see
Star Trek transporters are just 3d printers.
If he's complaining about comments, Linux must be close to perfect. Otherwise, he'd be worried about that instead.
Hell, I'm happy if my guys leave ANY comments in their code.
In the past I have seen very unprofessional comments. One where they bitched back and forth, calling each other names.... and so on. Even the women could get very testy.
My team and I agreed to use tabs for everything, then we set our editors to the width we like best.
Also, I've made a couple mappings in vim that change 2 spaces to a tab, 4 spaces to a tab, tabs into 2 spaces, tabs into 4 spaces and every other possible combination that I want. If I want to reformat code to have the whitespace rules I want, I simply use gg=G and the file gets re-indented with the rules I set.
It's not ideal, but I do think a lot of the "tabs vs whitespace" issue can be solved with editor configuration. Even if I hated tabs with a passion and everyone in my team used them, I could: :w
1) Convert tabs to spaces: \ts2
2) Apply indent rules: gg=G
3) Make changes
4) Convert spaces to tabs: \st2
5) Apply original indent rules: gg=G
6)
7) Commit
At best your code can explain what it's doing, but not why or how. I mean, it's great that I can see you frob and then swizzle. But why frob first and swizzle second? Why frob at all? Why not frobnicate instead?
dom
Sometimes those sorts of things do require explanations which can't be made clear through naming. Most of the time, though, good naming and good code structure can explain everything except the road-not-taken questions... and it's relatively rare that the road-not-taken choice is actually important enough, or has sufficient non-obvious rationale, that it requires explanation. If it does, by all means put it in a comment, though -- and note that that sort of comment *doesn't* tend to become obsolete.
Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
I would love to see his kitchen.
I bet everything is in airtight containers labled with a professional label maker.
Racked and sorted into multiple different categories then sub sorted by alphabetical order.
I bet if someone puts something back in the wrong place, he has an absolute meltdown at them.
This is Nerd Rage, pure and simple. Never seen a clearer case of it! Complaining over comment style?!
Oh lordy, OCD+ASD to the max methinks. If this trivia is enough for him to work up a head of steam then all else must be full of rosy awesomeness in Linuxland.
The importance of good commenting can be seen in this winning example of C code
https://github.com/c00kiemon5t...
main(C,V)
char **V;
* understand it look it
*/ up.) (In the C Manual)
{
char _,__;
while (read(0,&__,1) & write((_=(_=C_C_(__),C)),
_C_,1)) _=C-V+subr(&V);
}
(GRR, how do you tell slashdot to NOT ALTER THE FORMATTING AT ALL!?!?)
Yes, there's more (see link). But you can clearly see the importance of comments there.
Coding style is a vehicle to convey your brilliance. You're a decent programmer so conform to whatever the style is on the project you work in. Don't waste your precious short life on arguing about style.
For instance: In order to be able to comply to any coding style, I always set up my modules so that reordering members will not affect the functioning. Want to order constructors, getters/setters and/or other methods differently? Want to order static members in a very specific way? All fine by me.
Let's get the real issue at hand be dealt with.
I hadn't the slightest objection to his spending his time planning massacres for the bourgeoisie... (P.G. Wodehouse)
Differences in our backgrounds explain the different emphasis we are placing on comments. But all three of us agree more than we disagree. Splitting hairs about the last 5% disagreement, while ignoring 95% agreement.
sed -e 's/Chuck Norris/Rajnikant/g' joke > fact
But all three of us agree more than we disagree. Splitting hairs about the last 5% disagreement, while ignoring 95% agreement.
We're programmers :-)
Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
You quote Linus as saying:
"Can we please get rid of the brain-damaged stupid networking comment syntax style, PLEASE?"
Then extrapolate the completely wrong conclusion:
Linus did not label members at all. He was referring to the comments themselves. Take an English class.
It's no less professional to arse-up punctuation everywhere possible than to go all sweary every time you feel pissed off in public.
Give it a fucking rest, Linus. And get over yourself, pal. Nobody is impressed.
is that C++ clears itself up.
Debugging an "Objects, Objects, everywhere, but never any think" C++ program is a huge pain because a bug can exist in any one of "implicit code" points of constructor or destructor, even if not a single written line of code appears in the source debugged.
That right there is a huge loss to C++
And frequently the problem is that the general case wants such easy constructs in code, but in many cases it's neither wanted nor warranted, but still run. Think on the Windows method of forking a new program compared to the UNIX method, and how that made multithreading on windows much quicker, whilst multithreading on UNIX is often not faster enough than forking, whilst encouraging sharing data and the bugs that arise when this is done without your knowledge.
It's way better to use Pascal-style comments:
{
This is a comment
}
(I started with Turbo Pascal, and the first time I saw C code I was so confused - It's all comments, how does this work at all?) :)
Agree (mostly). Though I'm not sure about putting obsolete comments first. Even though obsolete, it still tells you that someone once cared enough to comment that code. It also tells you something about the code history.
Anyhow this priority list just highlights how Torvalds has gone off and is ranting about one of the least important aspects of comments. I'm not sure this merited the expenditure of some of Torvalds' considerable credibility. It will be a minor blip if he limits this type of discussion going forward. Keep doing this and he risks becoming known as a trivia-obsessed oldster. Which won't do him or anyone much good.
You must be Republican. There is only one way which is reality, and trying to come up with your own world-view of that reality only leads to problems. Just stick to actual reality, which are the rules Linus came up with.
It's like if Monet wanted people to add to his paintings but some asshat showed up doing something other than pointillism. The code is a piece of art in itself, follow the style. If you want to be Picasso then write your own kernel...
When Torvalds has the time to rant about comment formatting, then there can't be big problems in the code currently.
btw: There are tools to fix formatting automatically.
related: They don't use doxygen (like syntax)?
Braindead indeed.
Mouth-foaming fool Torvalds is at it again, trying to talk down on some normal and inconsequential commenting habits.
I would not be surprised if his preferences are in line with his coding preferences' in relation to braces, where he started a Holy Fulmination (t/m) against that guy with the beard.
Arrogant airheaded asshole.
Also known as meta comments, they explain why you did something a certain way. It might be essential to use a certain method. Without these types of comments a new programmer to the project, or you yourself will forget the why and go in thinking they are clever and change the code. Voila! nothing works anymore because of some obscure piece of code or equipment or database needs it done that way. // specialized function to calculate XYZ // // META: // META: This has to be done using method X because the requires it. // META: System X is planned to be replaced by which will use the new database, and // META: the new XXXXX.YYYYY.ZZZZZ format, at which time the standard library function Y can be used instead.
I've done it with old files as well by renaming the directory to something descriptive. Helps with cleanup later, but you don't shoot yourself in the foot by deleting something and not realizing something out there still depends on it. e.g. upgrading PCs in a corporate setting. People are asked to get all the files they need off their old system. They always say they have everything. They don't, they always have an e.g. excel file tucked away is some weird directory only used once per year so they don't think about it. I would back up their entire old system, everything, every file, in a directory with a descriptive name /BACKUP PC03432 John C 20160722 can delete after 20171022/
e.g.
They will freak out a few months later thinking their file is gone, but you can magically save the day for them.