Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
Programming Linux

Linus Torvalds Says Rust Closer for Linux Kernel Development, Calls C++ 'A Crap Language' (itwire.com) 270

Google's Android team supports Rust for developing the Android operating system. Now they're also helping evaluate Rust for Linux kernel development. Their hopes, among other things, are that "New code written in Rust has a reduced risk of memory safety bugs, data races and logic bugs overall," that "abstractions that are easier to reason about," and "More people get involved overall in developing the kernel, thanks to the usage of a modern language."

Linus Torvalds responded in a new interview with IT Wire (shared by Slashdot reader juul_advocate): The first patches for Rust support in the Linux kernel have been posted and the man behind the kernel says the fact that these are being discussed is much more important than a long post by Google about the language. Linus Torvalds told iTWire in response to queries that Rust support was "not there yet", adding that things were "getting to the point where maybe it might be mergeable for 5.14 or something like that..." Torvalds said that it was still early days for Rust support, "but at least it's in a 'this kind of works, there's an example, we can build on it'."

Asked about a suggestion by a commenter on the Linux Weekly News website, who said, during a discussion on the Google post, "The solution here is simple: just use C++ instead of Rust", Torvalds could not restrain himself from chortling. "LOL," was his response. "C++ solves _none_ of the C issues, and only makes things worse. It really is a crap language.

"For people who don't like C, go to a language that actually offers you something worthwhile. Like languages with memory safety and [which] can avoid some of the dangers of C, or languages that have internal GC [garbage collection] support and make memory management easier. C++ solves all the wrong problems, and anybody who says 'rewrite the kernel in C++' is too ignorant to even know that."

He said that when one spoke of the dangers of C, one was also speaking about part of what made C so powerful, "and allows you to implement all those low-level things efficiently".

Torvalds added that, while garbage collection is "a very good thing in most other situations," it's "generally not necessarily something you can do in a low-level system programming."
This discussion has been archived. No new comments can be posted.

Linus Torvalds Says Rust Closer for Linux Kernel Development, Calls C++ 'A Crap Language'

Comments Filter:
  • Spot on... (Score:5, Insightful)

    by Camel Pilot ( 78781 ) on Saturday April 17, 2021 @01:38PM (#61284236) Homepage Journal

    "C++ solves _none_ of the C issues, and only makes things worse. It really is a crap language"

    Linus is truly a treasure for succinctly sum things up. I would have left of the "crap language" because that will trigger the faithful.

    • by ceoyoyo ( 59147 )

      Lol. This is going to be a fun comment section. You and Linus are both spot on though.

      • by ShanghaiBill ( 739463 ) on Saturday April 17, 2021 @02:10PM (#61284312)

        When the area around Boston was first settled in the 1600s, the cows wore paths between the barn and their pastures. Later, the paths were widened to accommodate horse-drawn carts. As the town expanded, houses were built alongside the paths, and they became roads. Later, buildings were erected in the spaces between the roads.

        So if you ever wonder why Boston's streets make no sense, it is because that is where cows walked 400 years ago.

        C++ was designed the same way.

        Rust has the advantage of a fresh start.

        • Sure but the problem with eschewing C++ for C is you're choosing 400 year old muddy cow paths over the paved roads in their place. Sure you could make a better layout in the future, but that doesn't make paved roads a lot better than mud tracks.

          • Re:Spot on... (Score:4, Insightful)

            by Bu11etmagnet ( 1071376 ) on Saturday April 17, 2021 @05:40PM (#61284812)

            Those who don't understand C++ are condemned to reinvent it (poorly)

            • Re:Spot on... (Score:5, Interesting)

              by Cassini2 ( 956052 ) on Saturday April 17, 2021 @07:16PM (#61285004)

              I don't think anyone could, should or would reinvent C++. It's a language that requires a special section in compiler courses. Good compiler courses have special sections entitled "this is what makes COBOL special" and "this is what makes C++ special". The section on COBOLs flaws is usually much shorter than C++'s flaws.

              The design by committee approach to C++ pretty much guarantees no one wants to duplicate it, and no one can. A new C++ compiler is the work of a fairly significant development team.

              These simple questions can be really tough to answer in C++:
              a) Does this const pointer to const point to an immutable object (possibly in ROM?) or must it be in RAM?
              b) Is function "x" re-entrant (can it be optimized to non re-entrant code)?
              c) Does function "x" execute?
              d) Will this line of code trigger a dynamic memory allocation?

              On some architectures, particularly in the embedded world, being able to answer the above questions results in significant optimizations. In particular, determining if a const variable is actually immutable results in speed-ups. Similarly, if a linker can omit all functions that do not execute, significant file size optimizations can occur. Many real-time systems require no new memory allocations in critical blocks of code.

              C++ is a very hard language, to understand, to use, to optimize, and to write compilers for.

              Those who don't understand C++ are condemned to reinvent it (poorly)

              If this is true, software engineering is doomed ...

              • Re:Spot on... (Score:4, Interesting)

                by The Evil Atheist ( 2484676 ) on Sunday April 18, 2021 @03:15AM (#61285614)
                But they did reinvent C++. It is Rust. Rust didn't invent RAII and ownership semantics. Rust didn't invent Arcs. Rust didn't invent compile-time generic code.

                The design by committee approach to C++

                C++ has never been designed by committee. The committee is there purely for the standardization process.

                a) Does this const pointer to const point to an immutable object (possibly in ROM?) or must it be in RAM?
                b) Is function "x" re-entrant (can it be optimized to non re-entrant code)?
                c) Does function "x" execute?
                d) Will this line of code trigger a dynamic memory allocation?

                Tell me one language that can answer that. For example, d). Let's say I have a line of code in C which is "do_this_thing()". Pray tell - what part of the C language can tell me whether do_this_thing() will trigger memory allocation?

                In C, if a function is not declared static and is not used, any LINKER (or static analyzer) that can tell you a function is used will also be able to do the same for C++. And that's just for checking if a function is used. Whether something executes is yet an extra thing on top. Tell me what holy grail of a language can tell me whether function 'x' executes? If, in Rust, you pass a function as a callback to some other thing, how can you prove that callback will or won't be called?

                • If you follow about 200 rules that nobody follows.

                  But when I am forced to use it, I would love to have a compiler warning that says "Set dangerous mode off". So when I write

                  output("The answer is " + x);

                  I do not get a weird memory error if x is an int, vs if x is a string.

                  Likewise taking the address of a local variable and other cute tricks.

                  References almost work well in C++, except that they don't. As a coding style they can be used for safe references, with pointers used for unsafe, but nobody does tha

              • Re:Spot on... (Score:5, Interesting)

                by serviscope_minor ( 664417 ) on Sunday April 18, 2021 @04:15AM (#61285690) Journal

                If this is true, software engineering is doomed ...

                Computer scientists love to hate C++, but there's one tiny problem, it's hugely successful for a variety of really good reasons. Failing to understand something which has proven successful and long lasting is almost certainly a recipe for failure.

                Sometimes it's funny, like when Rob Pike made Go as a C++ replacement and C++ programmers largely ignored it because it wasn't very good and then wrote a whiny rant about how C++ programmers hated it because it was too awesome and they're all poopy-heads.

                The only reason Rust is making any headway is because the designers actually new and understood C++ very well, and aimed to solve the actual problems C++ has, not the "lol teh C++ si teh sux000rZ" pseudo-problems from the peanut gallery.

            • by Kisai ( 213879 )

              This.

              While Rust looks nice, there are other languages that have reinvented C++ before, like Java.

              Basically the longer a language exists, the more C++'isms find their way into the core language before the language gets abandoned for something easier to maintain and understand. PHP, Python and Javascript are having this problem in spades.

            • by Z00L00K ( 682162 )

              It's not hard to re-invent a crappy language into a new crappy language.

              If a language is hard to fully understand then maybe you shouldn't use it. That's why C still around - it's not that hard to understand while it's also offering some good performance.

              For C++ it has inherited all the bad things from C as well as all the bad things from object oriented paradigms. The bastard puppy of a chihuahua and a great dane.

              The biggest problem with C is the null terminated strings which is one of the core culprits in

            • Re:Spot on... (Score:4, Insightful)

              by Jeremi ( 14640 ) on Saturday April 17, 2021 @11:54PM (#61285424) Homepage

              Those who don't understand C++

              So, pretty much everyone? :)

              (As of C++20, I think the language has reached quantum-mechanics levels of nuance, so "if you think you understand how it works, that's a clear indication that you don't")

              • Re: (Score:3, Insightful)

                Everything that worked before still works, with no extra nuance. There are new features in C++20, but that doesn't change what works. So no, that is just an ignorant lie.
          • Sure but the problem with eschewing C++ for C is you're choosing 400 year old muddy cow paths over the paved roads in their place.

            I wasn't comparing C++ to C.

            I was comparing C++ to Rust.

        • Give it time (Score:5, Insightful)

          by Roger W Moore ( 538166 ) on Saturday April 17, 2021 @05:37PM (#61284806) Journal

          Rust has the advantage of a fresh start.

          Just wait. Given enough time it will accumulate problems as it gets expanded to accommodate new programming techniques. Today's "fresh start" is tomorrow's "crap language".

          • As a Gentoo user I can already tell you that rustc takes more time to get built from source than entire gcc(mostly due to providing own patched llvm in source). So llvm ecosystem already definitely beats gcc on elephant-factor.
        • by jmccue ( 834797 )

          No, I have no problem in the Boston area.

          Now cities like New York and DC, I get lost all the time. Those grid patterns confuse me and takes much longer to get to where you are going. In Boston, you just point your car to where you want to go and drive, no need to do constant annoying right and left turns

          • What could be easier than a grid system? One thing I love about Manhattan is how easy it is to walk anywhere given an intersection.
    • Re:Spot on... (Score:4, Informative)

      by UnknownSoldier ( 67820 ) on Saturday April 17, 2021 @01:59PM (#61284292)

      Or just Crap++.

      For example, Boost's crc [boost.org] is a bloated 2,305 Lines of Code just to implement a CRC that could be written in a mere ~25 lines of C code.

      Because the last time you actually needed to parameterize CRC to have CRC64 was NEVER. If you need stronger hashing you'll be using FNV or SHA variants. But's let use Template Metaprogramming to solve a "solution" in search of a problem. /s

      While C++ has it share of problems, (cue that old C++ joke: C++ has 2 problems: 1. Its design, and 2. Its implementation), the bigger problem is people writing shit code by overengineering the simplest of problems [youtube.com] because they are busing drinking the OOP Kool-Aid (TM).

      • I wonder how long that thing, even compile-time-parameterized, would be as a Lisp macro.
      • Wouldn't the last criticism apply to all object-oriented languages?
      • Re:Spot on... (Score:5, Insightful)

        by Entrope ( 68843 ) on Saturday April 17, 2021 @02:58PM (#61284424) Homepage

        People don't use 64-bit CRC, but they do use 8- and 12- and 16- and 24-bit CRCs. They use CRCs with different initial shift register values, and that differ in whether you shift bits from the MSB or LSB of the next byte into the CRC register (big- or little-endian bytes).

        The C++ code in Boost gets you support for all those variants plus more, efficiently implemented at runtime. Your 25 lines of C don't even get you an efficient, portable implementation, unless (and this would push the 25 line bound) you force the application to call an initialization function.

        • by narcc ( 412956 )

          I'll bet the average developer could still easily beat 2305 LOC.

          • Re:Spot on... (Score:5, Informative)

            by Entrope ( 68843 ) on Saturday April 17, 2021 @08:54PM (#61285148) Homepage

            I bet you're wrong. According to sloccount, there are 816 lines of compiled code in boost's crc.hpp, out of 2307 total lines on my system -- most of the rest are comments, some are blanks.

            The features to implement are:

            • Arbitrary number of bits up to the compiler's largest native unsigned integer type (such as "unsigned long long")
            • Arbitrary generator polynomial
            • Arbitrary initial value for the remainder register
            • Arbitrary bit-mask to XOR into the final result
            • Selection of big- versus little-endian input bytes
            • Whether to reverse the order of output bits
            • Ability to retrieve each of the parameters above given a CRC calculation object
            • Support for both stateful and one-shot CRC calculations
            • Ability to retrieve current state from a stateful CRC calculation object
            • Ability to reset a stateful CRC calculation object, optionally with an explicit value for the remainder register after reset
            • Idiomatic overloads to update a stateful CRC object with function-call-like syntax, and to retrieve its final CRC value
            • Simple (bitwise, table-free) implementation of CRC (for any combination of the parameters above)
            • Accelerated version with table lookup (for any combination of the parameters above)
            • ... with the table generated at compile time
            • Instantiation details for at seven commonly used CRCs

            As additional coding-style constraints, curly brackets must be on their own line. So must the return type, "inline" modifier, and parentheses around parameter lists for functions defined at file scope. Lines must be less than 80 characters long.

            • by narcc ( 412956 )

              It seems so silly. I'm hearing two sides, only one of which is defensible. You say, "look at the greatness of my bloated monstrosity! Look how general it is! See all of the great features!" Everyone else is saying "Dude, just use a 10 line function specific to your application. It'll be smaller and faster."

              Are you the author or something? Why do you care so much about this?

      • Re: (Score:3, Insightful)

        by AmiMoJo ( 196126 )

        C++ is crap for system/embedded programming because all the useful stuff that makes it easy and readable in C has been deprecated, mostly because it was deemed too dangerous.

        C++ is crap for application programming because the benefits over much easier, better designed languages are non-existent most of time. Yeah, it's a bit faster in some cases, but it usually doesn't make any meaningful difference.

        Whenever you come across something written in C++ you get this feeling of dread because you know that it's al

      • by ceoyoyo ( 59147 )

        I think it's unfortunate that so many people's experience with OOP is C++. It's an awful OOP system, in all the same ways that C++ is awful. Java makes things a bit more sane, but also makes it mandatory, which is also bad.

      • I'm sure implementing a template for a generalized CRC algorithm is fun and very satisfying. But so very unnecessary, like most of the output of C++ developers.

      • Re:Spot on... (Score:5, Insightful)

        by Brain-Fu ( 1274756 ) on Saturday April 17, 2021 @06:36PM (#61284942) Homepage Journal

        There is a class of programmer that "clicks" with the OOP concepts of inversion of control, dependency injection, and always coding to an interface. This approach feels so correct to them that they become almost religious in their devotion to it. They believe it is the one-size-fits-all solution to every programming problem, and consider anyone who disagrees with them to simply be less intelligent than themselves (because no rational person could possibly disagree).

        I have worked with such people. They quadruple the codebase, significantly increase development time, and introduce more bugs by doing so, all the while insisting that this will make the code easier to maintain in the long run. But it actually doesn't; it just means that there is that much more code that must be refactored as new features come along.

        They point at the ease with which layers can now be swapped-out as a total win. But in practice 90% of the interfaces have only one implementation. There is nothing to switch anything to because there just isn't any need. And future development isn't simplified by finding just the right layer to adjust; the changes are almost always cross-cutting so you have to refactor all those interfaces and layers top-to-bottom, each time, to get things working.

        It just doesn't work out in practice the way they insist it will. At least, not often.

        The last major benefit they harp on is the ability to test in isolation and use mock objects to keep the test cases simple. That's great if you want to have a lot of automated tests that pass in mocked-out unreal environments, but not so great if you want to actually find the bugs that come out once the code encounters the real world.

        There probably are specific kinds of project that benefit from this approach. But there are many, many more that suffer rather than benefit from it. All the versatility that the code buys you just doesn't deliver value, and all the layers it costs you just get in the way.

    • Re:Spot on... (Score:5, Interesting)

      by Dutch Gun ( 899105 ) on Saturday April 17, 2021 @02:03PM (#61284298)

      I'm a long-time C++ programmer, but I don't exactly get "triggered" by whatever Linux says about C++. We've all long known he has a bug up his ass about C++, after all. I disagree that it's a "crap" language, but anyone who has worked with it can easily see it has a huge number of flaws. Ironically, many of those flaws are there because C++ strives to remain mostly compatible with C and legacy C++ code, which makes it easy to do the wrong thing even if there are more modern ways of solving common problems. But that long-term stability and backwards compatibility are both a strength and a weakness, of course.

      It's easy to forget how ridiculously old the language is. Why replace one ancient language with another not-quite-as-ancient language? Sure, in C++ if you only use modern features and techniques, you can get much closer to memory safety (certainly much better than C), but never all the way there. It's essentially opt-in memory safety.

      Rust, in contrast, forces you to specifically opt-out of memory safety, which ensures you only do it when absolutely necessary, ensuring a smaller footprint of unsafe code to review. It makes more sense, if you're going to switch languages, to use a more modern language that definitely solves memory safety, which some surveys have shown accounts for roughly 70% of security bugs.

      The argument of "just don't make mistakes" or "use better libraries" are just not realistic. All humans make mistakes, and C has serious limitations as a language that still force the onus of safety on the programmer instead of the compiler.

      • Re:Spot on... (Score:4, Insightful)

        by cfalcon ( 779563 ) on Saturday April 17, 2021 @03:43PM (#61284536)

        Hands down the biggest weakness of C++ is also its strength. Using C as a guideline, it can do whatever it wants. And what it wants to do is everything.

        If you code your C++ as "C with classes", that's great. If you hire a bunch of men who do the same, also great.
        If you learned to think in pure OO space and you code that way, that's great. Again, if you hire a bunch of men who do the same, also great.

        But put these guys on the same team and you have guys who have a C-with-extra-stuff language versus people with a completely different paradigm. The second group has more academic stuff to point to, the first group has a metastable nonstandard that everyone agreed with at first glance and it evolved unpredictably over time.

        Some languages are too small to support this kind of thing. Others are too new, even though the language could go in that direction. But C++ is a whole host of programming styles.

        Oh, and it gets worse, because as you include different libraries written in different ways (especially C libraries side by side with stuff like boost), you are including those libraries for their functionality and performance. The code you wrap those in will look even stranger.

        I think someone should write "style guides" for the different types of C++ programming. The "C-with-classes" guys in particular need something written down, as they are, in my experience, the least able to make a coherent point defending their coding style.

      • No C++ is crap.

        I used to write C++ until about 2001. Then I switched to C# and Java and now only Java. Ok do some Python, and Javascript, but I digress. Around 2005 or 2008? I decided to write some C++ code and there was this really weird bug. Namely I was returning a value and it would keep erasing itself and causing a GPF. I thought, did I declare the return value in the function stack? I looked and looked and could not figure it out. Well I did figure it out several days later.

        Apparently between the time

      • Re:Spot on... (Score:5, Interesting)

        by UnknownSoldier ( 67820 ) on Saturday April 17, 2021 @05:59PM (#61284868)

        > I disagree that it's a "crap" language, but anyone who has worked with it can easily see it has a huge number of flaws.

        Hence, CRAP++

        * iostreams is still a complete clusterfuck of bad performance and bad design [youtu.be]
        * cout formatting is shit for performance and verbosity. Thankfully we have libs like fmtlib [github.com]
        * hash maps performance [ankerl.com] is shit [github.io]. Thankfully we have abseil [abseil.io], parallel hash map [github.com], ska hash maps [probablydance.com], etc.
        * modules might finally becoming. Welcome to the 1970's. /s
        * When even a C++ committee member admits he writes in a sub-set of C++ himself [youtu.be] then the language itself is bloated.
        * no standardized name mangling
        * no standardized way to force inline
        * no standardized way to specify function temperature
        * no standardized error/warrning output diagnostic messages ala MS's Visual C++'s Compiler, Linker, etc. [microsoft.com] such as C#### Compile Errors [microsoft.com], and Compiler Warnings [microsoft.com]
        * no standardized way to turn specific warnings on/off because the C++ committee has their head up their ass
        * no standardized way to specify alignment
        * no standardized way to turn off RTTI
        * no standardized way to turn off exceptions
        * no standardized way to specify LTO / PGO
        * Non-standard extensions like __FUNCTION__ exist because no one in committee is interested in pragmatic solution such as standardizing COMMON solutions.
        * etc.

        > many of those flaws are there because C++ strives to remain mostly compatible with C and legacy C++ code

        BULLSHIT.

        * Performance, and
        * Functionality

        Have _nothing_ to do with C compatibility.

        > The argument of "just don't make mistakes" or "use better libraries" are just not realistic.

        As opposed to what? Use the shitty C++ default libs?

        If your code is crashing then you didn't TEST it adequately enough.

        • Re:Spot on... (Score:5, Insightful)

          by Dutch Gun ( 899105 ) on Saturday April 17, 2021 @09:51PM (#61285244)

          I wish people wouldn't mod you down for this. People these days can't handle a bit of spirited debate.

          While I disagree with your opinion / conclusions about C++, everything you listed is a genuine pain point in C++, which at least demonstrates you know the language well enough to legitimately bitch about it. Some are genuine language issues, while others are because C++ only defines a language standard, and doesn't provide a reference implementation like C#, Rust, Go, and others. You missed some important ones too, like the pain of cross-platform build tools and third-party library integration, which requires more third-party solutions like CMake or dependency management systems.

          Just curious, what do you mean by "function temperature"? That's not a term I've heard of before, and searching turned up nothing relevant.

    • Re: (Score:3, Interesting)

      It is very easy to like modern languages when you can fall back to C for efficiency or to do things that the fancy language won't let you do. If that's how you approach languages, clearly C++ can't win. You're hand-waving all drawbacks of those other languages away because you still have C, and then you blame C++ for being a lot like C.
    • by HiThere ( 15173 )

      Actually, I like having a standard implementation of hash tables and strings (though C++ does that poorly compared to Vala or D).

      It solves SOME of the problems with C.

    • Re: (Score:2, Interesting)

      Spot on it completely wrong?

      Linux is now built with C++, because the compiler writers who write C compilers realised that C++ was a much better language than C for complex programs.

    • However, C garbage collection is a solved problem:
      https://en.wikipedia.org/wiki/Boehm_garbage_collector
      https://www.hboehm.info/gc/
      https://www.gnu.org/software/guile/manual/html_node/Conservative-GC.html
  • by jellomizer ( 103300 ) on Saturday April 17, 2021 @01:47PM (#61284260)

    Or Cargo...
    To be fair I haven't tried rust in a bunch of years. My issue wasn't as much around the language, but the set of libraries that came with it. At the time, a lot of them, seems to be poorly implemented and/or badly documented, with a lot competing libraries doing the same thing as each other.
    I am a big fan, of using standard libraries that will have long term support, and very rarely using the third party, unless I really have too. Rust, when I was checking it, seemed way to basic on its own, and adding in the Libraries, seemed like a crap shoot on getting something that will be useful for the next 15 years of the product lifecycle.

    • by HiThere ( 15173 )

      Last year it still didn't have any decent GUI libraries, but Linus wouldn't be concerned about that. For me it meant it was unusable. (Either Wx or Qt would have been good enough...though it's not surprising that they didn't have Qt.)

    • It's better but not solved. There are now lots of high quality crates for many of the standard things you would want to do. But the metadata for working out which is which is not always there, and there are some missing gaps (notably, GUIs I guess).

      The flip side is that you don't have to wait for some major release of Rust to get secondary library updates. In general, Rust updates and advances quite quickly and the improvement has been obvious over the last few years. And I think Rust will also avoid "stand

  • xD It's nice to hear in someone so respected all my beliefs about C++. Mind you, it didn't take him for me to say, "fuck that, I'm not touching C++ again with a ten foot pole," many years ago. I still hear people gasp when I say, if you want the power of C, then use C; and if you want a strongly typed C-like language that is object oriented, use Java or C# (I gagged a little on MS there... but ok). But it is nice to hear it said LOUD and clear. Thank you once again, Linus.
  • by Tranzistors ( 1180307 ) on Saturday April 17, 2021 @01:57PM (#61284284)
    I wonder when was the last time Torvalds tried to write anything in C++? Given that there are several kernels written in C++, dismissing the idea with "LOL" doesn't really add anything to the conversation.
    • by pele ( 151312 )

      I wonder about his competence in anything really. Anyone who almost exclusively dismisses other's ideas is a big time assowl in my book. I know quite a few academics and not once did I come across anyone dismissing anything the way this person does.

    • by GuB-42 ( 2483988 ) on Saturday April 17, 2021 @02:33PM (#61284362)

      Linus has strong opinions, some of them debatable, but I think it helped get Linux where it is now.
      I disagree with that statement in general. I think that C++ is perfectly fine for writing a kernel, but it is not fine for Linux. Linus designed Linux to be C++-less and it should stay C++-less. Rust is simply more in line with Linus ideas that drove the development of the Linux kernel.

      And about the other post calling Linus an asshole. Linus fully assumes his role an asshole. After all, when asked why he called his version control system "git", he answered that like with Linux, he named the software after himself.

    • by bsolar ( 1176767 )
      Can you cite those kernels? this list [wikipedia.org] only shows XNU being written in C with some parts in C++. Even those parts are not in plain C++ but in Embedded C++, which has its own set of limitations compared to C++ proper.
      • How about this [wikipedia.org]?
        • by bsolar ( 1176767 )

          That's a microkernel though, which has a much more limited scope than a monolithic kernel like Linux or even a hybrid kernel like XNU. Taking XNU as example, L4 would be comparable only to its Mach component.

          Still an interesting example though.

    • by nagora ( 177841 )

      I wonder when was the last time Torvalds tried to write anything in C++? Given that there are several kernels written in C++, dismissing the idea with "LOL" doesn't really add anything to the conversation.

      How many goes do you give a language? How many years? I wonder when was the last time Linus tried to write anything in PHP?

  • by stikves ( 127823 ) on Saturday April 17, 2021 @02:17PM (#61284326) Homepage

    Well, he might be right about C++ not being a good fit for the Linux kernel. Yes, the language... but he is known to have strong opinions.

    Then again, C++ works well for other operating systems, like Windows, Mac OS, and even Android (core).

    So this is all dependent on the project.

    • Re: (Score:2, Informative)

      by Anonymous Coward

      "Then again, C++ works well for other operating systems, like Windows, Mac OS, and even Android (core)."

      As far as I am aware, the kernel for all three of these is written in C.

      • by stripes ( 3681 )
        macOS's kernel is _mostly_ C (and a little assembly), but it does allow device drivers to be written in a subset of C++...and many are. So if you think of device drivers as part of the kernel then macOS does have a smidge of C++, if you don't then it doesn't.
  • C++ not crap (Score:3, Insightful)

    by Chuck Messenger ( 320443 ) on Saturday April 17, 2021 @02:40PM (#61284376)

    Which C++ is "crap"? 98? 03? 11? 14? 17? 20?

    The great beauty of C++ is that it "is C". Can you do, in C, something you can't do in C++? Not that I'm aware of.

    With each new iteration, C++ provides improved support for abstraction, and thereby, reduction of redundancy and preemption of bugs. All this, without sacrificing the fact that it still "is C" when you want it to be.

    I'm intrigued by Rust, and see myself potentially migrating to it. However, C++ is, in no sense, "crap".

  • by iampiti ( 1059688 ) on Saturday April 17, 2021 @02:53PM (#61284406)
    I find this statement funny: "More people get involved overall in developing the kernel, thanks to the usage of a modern language."
    I've barely touched kernel-level development (not even developing a kernel, just a driver) but I assume the highest barrier to entry is not the language that was used up to now to write it (C) but the fact that developing a kernel is HARD and certainly something that requires quite a bit of knowledge.
    I'm not saying Rust is not adequate for developing a kernel if saying that you need to know much more than it to be able to do it. Or maybe there're some parts that are not that hard and that a medium-level dev can do.
  • It's just another tool, a tool is only as good as those that know use it. If people write buggy code then, yeah, maybe they should not use that tool. And I know people that shouldn't use knives because they cut their hand, I also know some people that can create artwork with knives safely. You can also put a guard on all knives and force people to use guarded knives, but again this has more to do with with the use of the tool.

  • by dremon ( 735466 ) on Saturday April 17, 2021 @03:45PM (#61284544)
    I've been coding in C and C++ since 90s in a broad range of domains, including hard real time industrial systems, trading software, UIs (yes, MFC as in MotherF*ingC, Qt, etc). I remember the raise and fall of dos extenders, borland and the abortion called managed C++. Since around 2017 I've convinced my current employer to go ahead and adopt Rust for some of the smaller projects.

    We are using it since then and honestly, that was the best technical decision ever. It has a *very* steep learning curve, especially for people not initially familiar with C or C++. However, it pays back big time. At that time it had somewhat lacking 3rd-party library support and tooling, this has been tremendously improved in the last few years. Also plugging in an external C module via FFI is a joy, and C++ is not too difficult either with a little bridge coding.

    Writing software in Rust is really a pleasure. Cargo is excellent, cross-compilation is a joy, standard library provides a lot that C or C++ doesn't, async I/O is great via Tokio (or few other async runtimes), built-in testing support is a huge huge win, I can't stress it out enough how much pain and suffering we had writing unit tests in C++. And of course, memory and thread safety. It really works. Anyway, I don't see a compelling reason to start a new project using some older crap, unless you target some architecture which is not supported by LLVM (or, depending on the requirements, not in Tier 1 of the official Rust list). I worked with Tier 2 platforms without issues (e.g. Android and iOS) but I guess in many cases stronger guarantees are needed.
    • Just curious about your experience here. I'd agree with the steep learning curve especially with lifetimes (surprise, surprise). But, since I started rust (4 or 5 years ago), I've found life times easier and easier (particularly because of non-lexical lifetimes I guess, but for other reasons).

      I *think* the language has got easier in this way and suspect that the learning curve is rather flatter now. But, of course, it could just be because I am better at Rust and, of course, I can't learn it again. What are

      • by dremon ( 735466 )
        I think it is much easier, yes, than 4 years ago. Although my thoughts are similar, having a prior experience makes it opinionated. The IDE support is much more polished (I work mostly with IntelliJ plugin and CLion but occasionally also with VS Code). 2018 edition of the language polished it quite a bit, e.g. ? vs try macro, better modules. lifetime elision, non-lexical lifetimes. The old async coding with 10 levels of map, and_then, or_else was a pain, especially for newcomers. Now with async/await it's w
  • My first introduction to object oriented programming was with operating systems written in C. The OS uses a lot of objects. File systems, device drivers, etc. all are set up where you register a struct that includes a list of function pointers for various features.

    Now the question is whether having the programming language recognize objects as their own thing helps make a better operating system? Does it make it easier for programmers? Does it help to make the code more stable? Does it make the code mo

    • OOP is mostly about two things:
      1) Polymorphism (same as the function pointers used in the Kernel's I/O handling interfaces that different modules fill with different functions).
      2) Creating unnecessary special syntax for the first parameter of a function.

      Lots of people seem to think that 2 is really important and provides some kind of a super duper magic that makes code clearer.

  • D it is then: https://dlang.org/ [dlang.org] If only they had more momentum.
  • by radarskiy ( 2874255 ) on Saturday April 17, 2021 @05:01PM (#61284742)

    I am old enough to remember when adding Python as a dependency merely for configuration purposes was the end of civilization.

    Now it's okay to add another language for kernel development itself?

    • The problem I had with Python dependency was when my project wasn't written in Python. Some dude wanted our build system to use it. It's bad enough C had "make" in the first place. A whole language with libraries and things, just to build? That was my problem. BTW, If Jonathan Blow ever releases Jai, it addresses this issue. There is no "make" in Jai. You build software with a script that's in the same syntax as the compiled language. There is nothing special about running the same language at compi

  • Senior C++ programmers earn a lot money and respect in the industry, Rust programmers, not so much. Maybe it'll change in the future, maybe not.

    Admittedly, to me, Rust just seems like C but with better, compiler supported version of unique/shared pointers and better defaults (having to specify "mut" is pretty cool).

  • So I don't know Rust, so fill me in: What makes Rust easier to integrate into a large C project than C++? It is trivial to add C++ to most existing C projects. Every other language I've integrated with C required me to re-declare my method signatures in a way that is compatible with that language, and had some level of interop trickiness involved. Can I just #include a .h file and call that from Rust? Or is it merely that C++ simply does not offer enough benefit over C, but that Rust does, so Linus is w

  • JavaScript (Score:4, Funny)

    by backslashdot ( 95548 ) on Saturday April 17, 2021 @06:32PM (#61284932)

    Just use JavaScript, make the kernel run off node.js.

  • Next up, Rust# for the .Net world.
  • C++ is a junk language and its because of the idiocy of its rabid fans. They are really the same people that say if you are writing a "real" application you should write it in C/C++, not some safe language. This is not even what Richard Stallman wanted who was a proponent of people using Guile to write apps. If you ask why C++ does not have a concise way to have memory safety they say "We don't want memory safety because it makes things too slow, Dont use those memory safe features and WE WONT put it in our

    • by swilver ( 617741 )

      I always love the argument where the C++ fans say you should get a better programmer if you can't deal with C++. So we did, two experts, only do C++, snicker behind your back and talk condescending when you mention a "safer" language. 20+ years of experience.

      And yes, they really were experts. These guys did excellent work helping us extract code from another project and turning it into a DLL suitable for use into a large budget game (200+ developers involved, the type of code base that takes ages to down

      • So C++ is a bad language because some expert C++ programmers made some bugs.

        Oh well, next time, here Xlang expert programmers and you'll be guaranteed that there'll be no bugs because in Xlang, it is impossible to write bugs.
  • C++ isn't crap, it is just a very unsafe language, if you tell it to blast your foot off it will happily proceed to do it. It has its places and uses but yes other modern languages are usually better suited in most situations as generally you prefer not to blow your foot off.
  • Comment removed based on user account deletion
  • by vbdasc ( 146051 ) on Sunday April 18, 2021 @03:53AM (#61285666)

    By itself, C++ is not a crap language, of course. But it IS a crap language for projects with HUGE NUMBER of contributors, such as Linux, though. Or, one can say, for any "non-cathedral" projects. While C is a semantically simple language, C++ extends it (I know that C++ is not a strict superset of C, don't worry) by adding not only a large number of features and a large number of non-trivial to grasp abstract concepts, but it offers several programming "styles", meaning actually several "ways to do things". The most modern of these "styles" involve writing superficially concise, elegant, "RAD-like" code, which can be very hard to even understand by a non-pro C++ programmer, very hard to verify its correctness, and consequently, hard to maintain. Allowing C++ in Linux would "elitize" the project, it would men that the proverbial "thousands of eyes" that gaze at the code would be reduced to hundreds or even tens. This would defeat one of the main strong points of the whole project.

    tl;dr C is language for the "masses". Even a hobbyist can learn to understand and write good C code. None of these statements is true for C++.

Our OS who art in CPU, UNIX be thy name. Thy programs run, thy syscalls done, In kernel as it is in user!

Working...