Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming Linux

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
*/

This discussion has been archived. No new comments can be posted.

Linus Torvalds In Sweary Rant About Punctuation In Kernel Comments

Comments Filter:
  • by Anonymous Coward on Tuesday July 12, 2016 @05:27PM (#52500099)

    ...I happen to agree with his stance on this particular issue.

    • And if you didn't agree, would you have changed your stance or argued that he's a crackpot?

      • by tripleevenfall ( 1990004 ) on Tuesday July 12, 2016 @05:32PM (#52500135)

        I'd remind him from the real world that he should be glad there are comments at all.

        • by TemporalBeing ( 803363 ) <bm_witness.yahoo@com> on Tuesday July 12, 2016 @06:15PM (#52500533) Homepage Journal

          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.

        • It's also moderately trivial to re-format comments in source using many available tools if one desires to do so. Some already-rolled ones, almost any language that supports regex, even, gawd, bash scripts with sed and awk etc can do this. If you don't like it that much, make a tool that fixes it. It ain't rocket surgery, it's a job for an otherwise boring afternoon. I don't recall any compiler whatever having an issue figuring out which of the input was comments. Go to town, how hard can it be?
        • My code has tons of comments. I use them to deactivate big chunks of code I don't want to run right now.
      • by alvinrod ( 889928 ) on Tuesday July 12, 2016 @05:40PM (#52500213)
        Not the OP, but I don't particularly care about it in this instance (though I've got my own pet peeves in plenty of other cases), but when you work for a company or contribute to a project, you should follow their style conventions.
      • by sunderland56 ( 621843 ) on Tuesday July 12, 2016 @05:45PM (#52500257)

        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.

        // and, for the record, who uses c-style comments any more?
        // haven't written one in years
        // double-slash comments are the one and only improvement that c++ gave us

        • by Jamu ( 852752 ) on Tuesday July 12, 2016 @05:56PM (#52500361)

          My preference is

          /*
                  this type of comment
          */

          // or this

        • by Kjella ( 173770 ) on Tuesday July 12, 2016 @06:05PM (#52500435) Homepage

          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.

          • 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?

        • by Megane ( 129182 )

          // 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.

      • 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.

    • ...they first cause comment syntax to twist their panties into a bunch.
      • ...they first cause comment syntax to twist their panties into a bunch.

        Huh, I thought it was tabs vs spaces first, comment formatting second.

        • ...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.

          • by perpenso ( 1613749 ) on Tuesday July 12, 2016 @06:09PM (#52500471)

            ...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?

            • ...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)

          by Anonymous Coward

          I code and write on Windows, would it kill you penguin lovers to include a CR with your LFs?

    • by RabidReindeer ( 2625839 ) on Tuesday July 12, 2016 @05:36PM (#52500175)

      If nasty-looking comments were the worst offense in recent Linux releases, I'd be overjoyed.

    • by HiThere ( 15173 )

      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:

      /** Title of the comment.
      * body of the comment.
      * body continued. */

      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.

  • by Anonymous Coward on Tuesday July 12, 2016 @05:29PM (#52500113)

    Because of shit like this. fuck you.

  • by Anonymous Coward on Tuesday July 12, 2016 @05:30PM (#52500121)

    I like to make people work harder to figure out what I did.

    • 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)

        by Anonymous Coward

        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.

      • Back in the real world people don't try rewriting extremely complex things like kernels everytime they want to do a fix or add some functionality.
    • by swillden ( 191260 ) <shawn-ds@willden.org> on Tuesday July 12, 2016 @10:12PM (#52501737) Journal

      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.

  • by Bruce Perens ( 3872 ) <bruce@perens.com> on Tuesday July 12, 2016 @05:31PM (#52500131) Homepage Journal

    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

  • by vux984 ( 928602 ) on Tuesday July 12, 2016 @05:34PM (#52500151)

    Seeing as 'C++ mode' // comments were added to the C99 spec; this would be my preference. I've always hated all forms of /* */

    • by etinin ( 1144011 )
      Is this even allowed in kernel code? I'm curious.
    • /* I wonder why the plainest possible comment format is not mentioned. After all, you only need the start and end markers because C does not care about line breaks. If you're going to pretend that line breaks have any significance in comments, with those cute asterisks in the beginnings of lines, then you might as well use the linebreak-sensitive C++ comment style. */

      # 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)

      by Anonymous Coward

      I use // for comments, and /* for disabling block of code.

      • Am I the only one who wishes languages had different semantics for disabling code versus actual comments? Sometimes it's nice to have, plus it helps avoid the issue of having a block of code with a /* */ comment in it, then putting another /* */ around that block of code to disable it, only to find out that the first */ closed the outer comment.
        • by tlhIngan ( 30335 ) <slashdot.worf@net> on Tuesday July 12, 2016 @06:41PM (#52500717)

          Am I the only one who wishes languages had different semantics for disabling code versus actual comments? Sometimes it's nice to have, plus it helps avoid the issue of having a block of code with a /* */ comment in it, then putting another /* */ around that block of code to disable it, only to find out that the first */ closed the outer comment.

          C does this quite well.

          Use

          //

          and

          /* */

          for textual comments.

          Use

          #if 0
          ....
          #endif

          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.

          • Use

            #if 0
            ....
            #endif

            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.

    • must say for a change I actually whole hearted agree with Torvalds, the style of commenting he is complaining about is a horrible method, much prefer the C++ mode myself.
  • by OpenSourced ( 323149 ) on Tuesday July 12, 2016 @05:34PM (#52500157) Journal

    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.

    • We're democratizing Linux! Tear down the ivory tower, and build up the code formatting style shanty towns in its place.

  • 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)

      by Austerity Empowers ( 669817 ) on Tuesday July 12, 2016 @05:58PM (#52500375)

      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.

  • 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)

    by jgotts ( 2785 ) <(jgotts) (at) (gmail.com)> on Tuesday July 12, 2016 @05:48PM (#52500295)

    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.

  • by Bomarc ( 306716 ) on Tuesday July 12, 2016 @05:50PM (#52500307) Homepage
    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.
  • The fact that this is what he decides to rant about is... probably a good thing.
  • by Mysticalfruit ( 533341 ) on Tuesday July 12, 2016 @05:57PM (#52500369) Homepage Journal
    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.
    • 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.

  • The Donald Trump of software developers.
  • by Tablizer ( 95088 ) on Tuesday July 12, 2016 @06:03PM (#52500417) Journal

    They are not comments, they are Perl.

  • by friedmud ( 512466 ) on Tuesday July 12, 2016 @06:05PM (#52500431)

    /**
      * If you adhere to Doxygen style comments
      * it clears this up nicely.
    */

  • I wish he would worry more about systemd and less about comments.

  • /*
    * 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.
    */
  • by avandesande ( 143899 ) on Tuesday July 12, 2016 @06:31PM (#52500659) Journal
    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?
  • by 140Mandak262Jamuna ( 970587 ) on Tuesday July 12, 2016 @06:39PM (#52500711) Journal
    Worst comments are obsolete comments. The comment described what that function was designed to do, some 8 years ago. It has morphed since, default arguments added, the list has been replaced by multimap which was replaced by hashmap completely changing the behavior, and still the comments have not been updated.

    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.

  • by iamacat ( 583406 ) on Tuesday July 12, 2016 @08:30PM (#52501327)

    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.

  • by PJ6 ( 1151747 ) on Tuesday July 12, 2016 @08:59PM (#52501433)
    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.
  • 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...

THEGODDESSOFTHENETHASTWISTINGFINGERSANDHERVOICEISLIKEAJAVELININTHENIGHTDUDE

Working...