Announcement

Collapse
No announcement yet.

A 2024 Discussion Whether To Convert The Linux Kernel From C To Modern C++

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Originally posted by ssokolow View Post

    darkonix's phrasing was less than idea. Rust lets you do all those things too with the unsafe keyword... it just also reliably catches situations where you didn't want to do those things.

    ...like how C++ will catch various nonsensical operations on various data types while assembly won't.
    i dont care whatsoever. unsafe keyword is for babbies that dont know how to code.

    Comment


    • Originally posted by cj.wijtmans View Post

      thats why i LIKE C++. And that is why it would be relatively easy to switch to the C++ compiler and then make new code use C++ features. Or even cuse objects where before it was just a typedef. Also allowing "unsafe" code makes custom allocators easy to implement.
      Note that it is not trivial to compile the Linux Kernel with C++ (see https://lore.kernel.org/lkml/7e72d2e...d0bf0076@p183/). Also many features of C++ will not be accepted easily or at all. And until compilers allow to selectively turn off features (profiles?) It will be difficult to guarantee developers are using whatever accepted subset is allowed.
      Last edited by darkonix; 16 January 2024, 05:14 PM.

      Comment


      • Originally posted by cj.wijtmans View Post

        i dont care whatsoever. unsafe keyword is for babbies that dont know how to code.
        "i dont care whatsoever. C is for babbies that dont know how to code."
        -- Almost literally the kind of thing programmers and users of other languages with unstructured goto said when faced with languages that forbid using goto to jump into the middle of a function, bypassing its beginning.

        Comment


        • Originally posted by darkonix View Post

          Note that it is not trivial to compile the Linux Kernel with C++ (see https://lore.kernel.org/lkml/7e72d2e...d0bf0076@p183/). Also many features of C++ will not be accepted easily or at all. And until compilers allow to selectively turn off features (profiles?) It will be difficult to guarantee developers are using whatever accepted subset is allowed.
          Nobody said its trivial or easy, not sure why this strawman/red herring keeps popping up. And about this "accepted subset", that is how every maintained code works, especially linux, regarding coding style, standard and whatnot. So again a nonargument.

          Originally posted by ssokolow View Post

          "i dont care whatsoever. C is for babbies that dont know how to code."
          -- Almost literally the kind of thing programmers and users of other languages with unstructured goto said when faced with languages that forbid using goto to jump into the middle of a function, bypassing its beginning.

          ​not sure what the argument here is when C allows and even relies on goto when dealing with signals and what rust will have to deal with in the current unix-like ecosystems. And no this is not an argument in defense of it.
          Last edited by cj.wijtmans; 17 January 2024, 09:42 AM.

          Comment


          • Originally posted by cj.wijtmans View Post
            ​not sure what the argument here is when C allows and even relies on goto when dealing with signals and what rust will have to deal with in the current unix-like ecosystems. And no this is not an argument in defense of it.
            C allows structured goto. You can't use goto to jump to an arbitrary other location in the program, bypassing the beginning of a function to start in its middle, like you can with assembly language or pre-structured higher-level languages. If you try, GCC will refuse to compile it.

            ...but, before structured programming became the norm, programmers had a very similar "If you can't keep this straight in your head, you're not a real programmer" attitude toward making your code as spaghetti as possible in the name of optimization.

            Comment


            • Originally posted by ssokolow View Post

              C allows structured goto. You can't use goto to jump to an arbitrary other location in the program, bypassing the beginning of a function to start in its middle, like you can with assembly language or pre-structured higher-level languages. If you try, GCC will refuse to compile it.

              ...but, before structured programming became the norm, programmers had a very similar "If you can't keep this straight in your head, you're not a real programmer" attitude toward making your code as spaghetti as possible in the name of optimization.
              and i fail to see how this analogy applies to a unsafe keyword. i know what is unsafe or undefined behaviour and why it exists and yes the compiler could give a warning or even an error with compile flags so what is the issue.

              Comment


              • Originally posted by cj.wijtmans View Post
                Nobody said its trivial or easy, not sure why this strawman/red herring keeps popping up.
                I wasn't really arguing. I was pointing to that link that was shared previously shows that there would be some effort involved. It may be debatable if easy or moderate.

                Originally posted by cj.wijtmans View Post
                ​And about this "accepted subset", that is how every maintained code works, especially linux, regarding coding style, standard and whatnot. So again a nonargument.
                Yes, it is the same but it adds manual effort from reviewers to ensure not allowed features are not used. Since C++ has much more features than C the effort will be higher than currently. As far as I know there is no compiler setting/tooling to detect automatically if only the allowed subset is used which would mitigate the increased effort.

                Comment


                • Originally posted by cj.wijtmans View Post

                  and i fail to see how this analogy applies to a unsafe keyword. i know what is unsafe or undefined behaviour and why it exists and yes the compiler could give a warning or even an error with compile flags so what is the issue.
                  It's always the same reason transitions to languages happen... compatibility with the existing ecosystem prevents the earlier language from retrofitting the desired new features.

                  In Rust's case, it's that you can't have the compiler check the code for correctness to the level Rust allows, with the level of reliability Rust allows, unless you have a safe-by-default paradigm and a safe/unsafe split (similar to how const-by-default with a mut keyword more properly accounts for actual in-the-wild human behaviour) because we've already seen people reject things like splint's annotations and safer dialects of C again and again... Rust addresses that by disguising writing those annotations for existing C or C++ code as "writing Rust bindings".

                  In essence, it's an exercise in using language design to steering human behaviour and a key part of what makes it work is that people like you find it too much bother to join in and interfere with the development of the language, preferring to stay on languages like C and C++ and complain about how your comfort zone is eroding and "why won't people just see how bad the new thing is?"

                  Comment


                  • Originally posted by ssokolow View Post

                    It's always the same reason transitions to languages happen... compatibility with the existing ecosystem prevents the earlier language from retrofitting the desired new features.
                    this has not at all stopped C++ from innovating, if anything they didnt keep up with the C standard that well(in terms of C compatability). C++ had to adopt some C functionality and it should keep that way. most of C++ benefits come from metaprogramming, RAII OOP, exceptions and STL which all of it exist perfectly fine on top of C coding.

                    Comment


                    • Originally posted by cj.wijtmans View Post

                      this has not at all stopped C++ from innovating, if anything they didnt keep up with the C standard that well(in terms of C compatability). C++ had to adopt some C functionality and it should keep that way. most of C++ benefits come from metaprogramming, RAII OOP, exceptions and STL which all of it exist perfectly fine on top of C coding.
                      I should have made that more clear. C++ can't innovate in the direction Rust does because the innovations are removing things that proved to be bad ideas and are too prone to being misused and C++ won't remove things because that'd break existing codebases. (Hell, the set of constructs allowed by C++ is kind of infamous for effectively being three different languages, from three different eras of language design wisdom, in a trench coat, with the most intuitive syntax being tied up with the oldest, most deprecated approaches, as touched on somewhat in this blog post.)

                      If C++ were to adopt Rust's key innovations in an effective way, it'd be "Rust, but with syntax less optimized for the new usage patterns" because it would have to break compatibility with old C++ codebases (unless wrapped in annotations to add the new information the compiler needs... A.K.A. bindings) to do it.
                      Last edited by ssokolow; 24 January 2024, 02:04 AM.

                      Comment

                      Working...
                      X