Linus Torvalds In Sweary Rant About Punctuation In Kernel Comments (theregister.co.uk) 523
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
*/
Whether he's overall crazy or not... (Score:5, Insightful)
...I happen to agree with his stance on this particular issue.
Arguing over the subjective (Score:2)
And if you didn't agree, would you have changed your stance or argued that he's a crackpot?
Re:Arguing over the subjective (Score:5, Insightful)
I'd remind him from the real world that he should be glad there are comments at all.
Re:Arguing over the subjective (Score:5, Insightful)
I'd remind him from the real world that he should be glad there are comments at all.
Since for anything to get merged it must pass by Linus, he can insist that you put comments on it or it does not get merged.
The Kernel source actually has quite a few comments, and some very funny jokes running throughout it.
So when dealing with a BDL or core maintainers for a project, you just do what they say as if they were your employer paying you - as any professional would do; or you go do something else.
Re: (Score:3)
Re: (Score:3)
Re:Arguing over the subjective (Score:5, Informative)
I am so sick of that tired old pile of steaming crap. Just don't. It stopped being funny decades ago.
Real programmers know that other programmers will have to support their code.
Obey Wheaton's Law: Don't Be A Dick.
Re: (Score:3)
The easiest distinguishing characteristic between a programmer and a software engineer - empathy for the people who have to test, maintain, document, and extend your code :).
I've always been surprised that people don't consider them separate things (programmers and software engineers) - so maybe it's just me.
Re:Arguing over the subjective (Score:5, Funny)
I don't know about empathy but I try to live by -- "code/comment as if your code will be maintained by a psychopath who knows where you live."
Re: (Score:3, Interesting)
THIS is an ANUS:
*
THIS is an ANUS on SLASHDOT:
/.
*
Re: (Score:3)
Mature Voice of Experience speaking here:
There's a difference, there really is.
I'm in college
And don't say this in public if you want to be taken seriously. Though in the context you wrote it in tells me it will only help until you open your mouth.
Re: (Score:3)
No, that's wrong.
Good comments say in natural language what the code is intended to do, and what non-obvious reasons make it the way it is. The code in the programming language should be as readable as possible, but that does not negate the value of the comment. Both are needed for efficient bug hunting and validation.
Re:Arguing over the subjective (Score:5, Insightful)
Re:Arguing over the subjective (Score:5, Interesting)
I both heartily agree with him, and think he's a crackpot. If you're trying to attract unpaid people to work on a project, this isn't the way to do it.
Re:Arguing over the subjective (Score:4, Insightful)
My preference is
this type of comment
*/
Re: (Score:3)
Hate to start an editor war, but vim has no trouble dealing with leading delimiters either.
Get a real editor. Through out that IDE.
Re: (Score:3)
Can't decide if this a typo, bait fir the grammar nazis, or a clever reference to evil mode. Well played.
Re:Arguing over the subjective (Score:5, Funny)
"When I log into my Xenix system with my 110 baud teletype, both vi *and* Emacs are just too damn slow. They print useless messages like, 'C-h for help' and '"foo" File is read only'. So I use the editor that doesn't waste my VALUABLE time...Computer Scientists love ed, not just because it comes first alphabetically, but because it's the standard. Everyone else loves ed because it's ED!... When I use an editor, I don't want eight extra KILOBYTES of worthless help screens and cursor positioning code! I just want an EDitor!! Not a "viitor". Not a "emacsitor". Those aren't even WORDS!!!! ED! ED! ED IS THE STANDARD!!!"
-Ed is the standard text editor. [c2.com]
Re: (Score:3)
Real programmers write code with cat and make changes with sed.
If you have to use awk, you lose points.
Re: Arguing over the subjective (Score:5, Insightful)
Linus got an abundance of coders and by far most are paid, you can't compare it to other projects where you're lucky to get volunters at all. The kernel runs everything from cell phones to supercomputers and the markets it doesn't dominate is not the kernel's fault. He can well afford to only take high quality code that follows the style guides. Linux is simply not like most projects.
Re: (Score:2)
Linus got an abundance of coders and by far most are paid
If this was a paid employee, then this is basically a boss-to-employee performance review. Would you be comfortable with *your* boss giving *you* scathing bad performance reviews, live on the internet?
Re: (Score:3)
"Code quality high". Are you fracking kidding me! This is the Linux kernel we are talking about. The code is hacker crap!
It's better to stay silent and have people think you a fool than to open your mouth and remove all doubt.
Re: (Score:3)
// double-slash comments are the one and only improvement that c++ gave us
Why won't people accept the existence of C99 over 15 years later? (Microsoft has to be the worst offender about this, they refuse to support it in VS.)
If you want to talk about Luddites, the anti-C99 Luddites are worse than the anti-C++ ones.
Re: (Score:2)
Re:Arguing over the subjective (Score:5, Funny)
There is no problem that one can solve with object oriented design that cannot also be solved with structs and function pointers.
There is no problem that can be solved with structs and function pointers than cannot also be solved with raw assembly code, written directly to disk using a sector editor (or butterflies). But it's fucking stupid to choose such a non-productive way to code if you're doing it for a living (I recommend everyone does it once for fun, though).
The *only* advantage to object oriented design is more intuitive code organization, and that only within certain problem spaces.
Even if you never use inheritance or polymorphism (which certainly only makes sense for certain sorts of problems), putting your functions into the same namespace as the data they operate on is always going to make for cleaner code.
That right there is a significant win for C++.
For almost all kinds of problems, the fact that C++ destruction can automatically release resources, so you can safely return from anywhere in a function instead of having goto fail all over the place is a significant win for C++. Too many programmers are just hopeless at getting the "clean up everything before you exit the function" right 100% of the time.
For code organization, sometimes C++ "concepts" (static polymorphism, so no function pointers) are a nice win. Questionable whether the many lines of code you can save justifies the fact that you're writing template code, however.
The more you look, the more places you'll find clean little wins for C++, with no performance cost.
Re:Arguing over the subjective (Score:4, Insightful)
C++ lets you have classes that clean themselves up. The useful pattern is to do this for primitives, not complicated objects. E.g
FileHandle file = fopen(...)
You use file just like you would a FILE*, except you don't need to explicitly call fclose(). No clean-up block at the bottom, you just return, and fclose(file) is called as part of exiting scope. You can call fclose() if you want to for some reason, and that's safe too. It's as idiot-proof as code is going to get.
That means you can return from any point in the code, and each such object you created will be unwound safely in the reverse order.
It's really a huge win, and the pattern is easily adaptable to anything with reserve-release bookends.
Re:Arguing over the subjective (Score:5, Informative)
C++ absolutely solves the "goto fail" issue. The term that describes this is RAII [wikipedia.org]. C++ uses objects and smart pointers (which are just pointers wrapped in objects) to hold resources. When objects go out of scope, those resources are automatically destroyed. There's very little need to clean anything up manually with modern C++.
Re: (Score:3)
RAII is only useful for pointers. Dtors cannot throw any exceptions, that means that RAII is useless for anything else. See my post above.
Dafuq? Are you serious?
A GC is a more elegant solution for memory management.
There are entire classes of problems for which a GC is not acceptable, not just in the embedded realm, but in the application/system/large memory realms. There are reasons why the Java VM provides for direct byte buffers or why .NET allows you to jump from managed code to un-managed code.
Re:Arguing over the subjective (Score:4, Informative)
If you need to use < or > in your slashdot comments, you need to type < and > since slashdot interprets the < or > as marking HTML tags. If you have Notepad++, use TextFX Convert -> Encode HTML to automatically convert code samples, e.g.:
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}
Re: (Score:3)
And if you didn't agree, would you have changed your stance or argued that he's a crackpot?
last time I changed my stance, a Republican Senator smiled at me over the toilet stall partition.
Whom The Gods Destroy... (Score:2)
Re: (Score:2)
...they first cause comment syntax to twist their panties into a bunch.
Huh, I thought it was tabs vs spaces first, comment formatting second.
Re: (Score:2)
...they first cause comment syntax to twist their panties into a bunch.
Huh, I thought it was tabs vs spaces first, comment formatting second.
80 character lines.
Re:Whom The Gods Destroy... (Score:4, Interesting)
...they first cause comment syntax to twist their panties into a bunch.
Huh, I thought it was tabs vs spaces first, comment formatting second.
80 character lines.
I thought we all agreed to set our terminal windows to 120 characters?
Re: (Score:3)
...they first cause comment syntax to twist their panties into a bunch.
Huh, I thought it was tabs vs spaces first, comment formatting second.
80 character lines.
I thought we all agreed to set our terminal windows to 120 characters?
The only people who do that are the ones who do not run side-to-side diffs. Have mercy on the people who have to run diffs while fixing your bugs and stick to 80 character lines.
Re: (Score:2, Funny)
I code and write on Windows, would it kill you penguin lovers to include a CR with your LFs?
Re:Whether he's overall crazy or not... (Score:5, Insightful)
If nasty-looking comments were the worst offense in recent Linux releases, I'd be overjoyed.
Re:Whether he's overall crazy or not... (Score:5, Funny)
Re: (Score:2)
OK. I happen to disagree. But if a project has a coding standard, then you need to follow it anyway.
As it happens, my preferred comment style matches one of the ones he disapproves of. I like to conserve vertical space, so I prefer:
I don't plan on reading it there, though, I plan on using Doxygen to produce commented text, and not looking at the code again unless I need to modify it.
I quit writing comments (Score:3, Funny)
Because of shit like this. fuck you.
Re:I quit writing comments (Score:5, Funny)
Linus? Is that you?
I don't use comments (Score:5, Funny)
I like to make people work harder to figure out what I did.
Re: (Score:2)
I figured people are just going to rewrite everything the first chance they get. Learning some other guy's code base hasn't been fashionable for a few decades now.
Re: (Score:2, Interesting)
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.
Re: (Score:3)
especially if it lacks comments
Re: (Score:2)
Re:I don't use comments (Score:5, Insightful)
I like to make people work harder to figure out what I did.
I used to get a chuckle out of doing that... but then I figured out that the guy working hard to understand my code later is almost always me. I strive to write clean, clear code with useful comments to avoid making myself work harder to figure out what I did. Sometimes it even works.
Torvalds Must Die! (Score:5, Funny)
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
Re: (Score:2)
rot13: V frr jung lbh qvq gurer, jbbfu.
Re: Torvalds Must Die! (Score:4, Funny)
Re: (Score:3)
Re: (Score:3)
hectoring from the sidelines?
What? It's a verb. Hey, when you're using weapons-grade sarcasm and words like noösphere, a little word like hectoring has to fend for itself.
Re: (Score:3)
Ah no I didn't mean to imply that Linus is a steaming pile of dogshit masquerading as a wannabe politician.
please just go all the way to the C++ mode (Score:5, Insightful)
Seeing as 'C++ mode' // comments were added to the C99 spec; this would be my preference. I've always hated all forms of /* */
Re: (Score:2)
Re: (Score:2)
# Or *gasp* switch to a language where line breaks matter in the actual
# code too, so you can avoid typing and reading all that line noise.
Re: (Score:3, Informative)
I use // for comments, and /* for disabling block of code.
Re: (Score:2)
Re:please just go all the way to the C++ mode (Score:5, Informative)
C does this quite well.
Use
and
for textual comments.
Use
for code comments.
Bonus is many editors recognize the #If 0 idiom and automatically block-comment the code out!
And the preprocessor is self-balancing, so every #if must have a corresponding #endif making it ideal for commenting out blocks of code.
Re: (Score:3)
Use
for code comments.
Nah, don't comment out or ifdef out code. Just delete it. If you need to bring it back later, that's what version control is for.
Re: (Score:2)
Parkinson's law of triviality (Score:5, Funny)
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.
Re: (Score:2)
We're democratizing Linux! Tear down the ivory tower, and build up the code formatting style shanty towns in its place.
indentation too? (Score:2)
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...
Re:indentation too? (Score:4, Informative)
At least in all my professional software development, this kind of nitpicking is par for the course. The difference is that in a corporation you can strong-arm your team, either because they report to you or because you have political clout. In free software with something that has thousands or more of contributors, all you have is screaming loudly and offensively enough to get on slashdot. Then maybe people figure out that this is how they want it done.
Someone could scream back with valid arguments about why: /* This is a good idea,
* we should do this! */
I can't think of one. All I can think of is "who cares", the answer to which is "Linus" (and others), and if I don't care I should just do it their way.
Fuck quality; we need balanced comments. (Score:2)
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 (Score:5, Insightful)
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.
Style cop.... (new an better) (Score:3)
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.
From the nothing-really-wrong dept. (Score:2)
I agree with Linus. (Score:3)
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.
Re: (Score:2)
Speaking as somebody who's written code dating back to the 70s, be thankful I even comment the code. In some circles the code should be self evident and comments are like so much belly button lint; interesting but it doesn't serve a purpose.
Surprise, surprise (Score:2)
Torvie's got it all wrong (Score:3, Funny)
They are not comments, they are Perl.
Doxygen Style (Score:3)
/**
* If you adhere to Doxygen style comments
* it clears this up nicely.
*/
Re: (Score:2)
lol - missed a space before the closing comment ;-)
The asterisks should be aligned ;-)
It's got to be said. (Score:2, Insightful)
I wish he would worry more about systemd and less about comments.
Re:It's got to be said. (Score:5, Informative)
// Badly formatted comments on Slashdot (Score:2)
* 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.
*/
Things I Hate (Score:3)
Many things are worse than bad comment punctuation (Score:5, Interesting)
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.
Re:Many things are worse than bad comment punctuat (Score:4, Insightful)
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.
Most commercial projects have a code style (Score:3)
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.
This reminds me of top-posting in newsgroups. (Score:3)
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.
Why curse? Just codify your style... (Score:3)
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) [freebsd.org] manual for decades.
Maybe, he should leave children's to children and join a real OS-project...
Re: (Score:3)
I guess he doesn't like to be seen picking his nose :-)
Re:So, the kernel is done? (Score:4, Insightful)
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.
Hard-to-read comments make hard-to-read code. On a large project with multiple developers that matters.
Re: (Score:2)
Re: (Score:3)
"Hard-to-read comments make hard-to-read code"
This isn't about hard to read comments, it's about comment format that someone doesn't like. I can read the "crap" comments as easily as I can read the good ones, I'm not brain-dead. It's more about a visual style preference.
And I've worked on large proprietary projects, and finding code with random inconsistent styles is ugly and a massive PITA, and it does take up time when you're trying to figure out unfamiliar code and you're spending extra brainpower picking out comments.
It's not even that one commenting style is fundamentally more readable (but I think Linus's suggestions are slightly more readable, and on a big project that matters). But having a consistent style throughout the project is very important.
And we wonder why people don't like the open source community? They resort to petty insults and swearing to make points, and I am supposed to devote my free time to supporting the projects? Give me a break. If I wanted to be subjected to name calling I would go back to High School or jump into an FPS.
Agreed, Linus's "
Re:Who Cares? (Score:5, Funny)
Yeah! It's not like the guy fucking invented Linux or something!
Re: (Score:2)
Maybe anyone who wants to get their kernel patches upstream?
Re: (Score:3, Insightful)
What happened in his childhood to arrest his development? Any shrinks in the house?
It came in early adulthood when he confused good luck with genius. It happens all the time with the successful. They begin thinking they know more than their peers rather than they happened to be the lucky one at the right place at the right time.
Re:Linus the man-child (Score:4, Insightful)
Not to back up the "all success is luck" meme but I would put it like this.
There are any number of people who might have the skill to write a kernel.
His "luck" was being the one who put in the work at the right time, caught the attention of other like-minded individuals to make it a community effort, and very effectively filled the niche that needed to be filled at the time. Without him it is fairly likely that another project would have eventually emerged, or that BSD would have been what people rallied around. And we'd then know another personality or group of personalities or company as the face of the open source operating system.
That is not to say he doesn't have a crazy amount of skill.
But that skill and that "luck" don't necessarily make his opinions infallible especially on something as asinine as this.
That said, you don't like his management style don't work with him or with a company that requires you to work with him.
Re:Linus the man-child (Score:5, Interesting)
“Luck Is What Happens When Preparation Meets Opportunity" - Seneca
If you're not prepared for opportunity, and someone else is, you call them "lucky". Probably because you were too busy with Pokemon Go!
Re: (Score:2)
Re: (Score:2)
Hi Linus! I didn't know you read slashdot.
Re: (Score:2)
It is probably to help distinguishing comments from non-comments, especially when syntax highlighting isn't used, or in patch files.
Some text editors manage this style of comment quite well.
Re: (Score:3)
It's probably not even the biggest thing on his "Kernel Shit Must Change" list; more of a "this came up, so here's my opinion; now I'm gonna do something else". At least, that's how I interpret his email.
But why would you expect to see stuff about war, famine, or the Kardashians on the linux kernel mailing list?
Re: (Score:2)
Re: (Score:2)
Since not much new stuff outside of my own is written in Whitesmith's style
There's a reason for that, you know.
Re: (Score:2)
Reformatting code is a big no-no in shared version-controlled environments.
In many version-controlled environments, a hook is added to the check-in command to automatically run the reformatter, so there are never any diffs in the history caused by the formatting process.
I really don't like some of the settings that were made on the formatter my current project is using, but at least I never have to worry about things like typing lines too long. They're automatically fixed up on commit.