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 Kver View Post
    I mean, it'll never happen, but if nobody is happy with any language being used in the kernel - well - Mozilla has proven you can make your own tools.
    Mozilla (although Rust is now independently managed) showed that it is possible to develop a new language. Every single time, someone has tried what you are suggesting which is just make a "better C" those efforts have consistently failed including Cyclone

    Comment


    • Originally posted by patrick1946 View Post
      OOP is anyway a very fuzzy term.
      To you perhaps it is, because there are many OO languages out there, some of which implement more and others less of the OO concept and maybe this is why it appears fuzzy to you.

      Object-orientation in C++ comes with a definition of access scope, data encapsulation, initialisation order, inheritance, and more, and it would be great to have in the kernel, especially for people who want to create devices drivers without first becoming gurus or kernel hackers. Instead, many drivers are copy&paste of the same code, which makes larger changes to a subsystem difficult, because the copy&paste code in the drivers needs to be managed, too. Worse, some developers make use of data and functions in their code they should not use simply because they have access to these, are used to doing it this way, and because they only understand procedural programming and do not understand (or do not respect) the boundaries they are crossing. Object-oriented programming, like in C++, allows one to set clear boundaries of what developers in a project are allowed to access.

      Back in the days when procedural programming was introduced were projects of a small size and the need for control of what developers can access in their code just was not there. This is why we now have object-oriented programming, because it makes large code projects much more manageable. Ask yourself, how many times did you come across a driver that failed to compile with a new kernel, because a function signature was changed or an element in a structure was moved? Such problems should not even happen, and yet they do, because procedural programming was never designed to handle it. I would go as far as saying that the whole kernel hacker mentality, including man-child behaviour and abusive language, has often been a substitute for not having proper control over who can do what in their code.

      Anyhow, this is drifting too far from the topic, because I do not see this happening with the current kernel. We sooner see a new project emerge which makes full use of C++ (like it is the case with LLVM). The discussion of using some minor C++ features in what is otherwise C code is not really worth the trouble. They should just let them use them where it is reasonable to do so, meaning, where it is of no consequence or just minimal impact to the rest of the kernel.
      Last edited by sdack; 10 January 2024, 01:51 PM.

      Comment


      • Originally posted by user1 View Post

        I assume you mean Windows NT? I heard it started using some Rust lately, but isn't it mostly C, just like Linux?
        Yes, Windows NT is the kernel I mean. Apparently you're right and it is mostly C with some rare C++, but they did ship some Rust lately. Most of the low-level userspace code is C++ in contrast.

        Comment


        • Originally posted by sdack View Post
          To you perhaps it is, because there are many OO languages out there, some of which implement more and others less of the OO concept and maybe this is why it appears fuzzy to you.
          Thank you for proving my point. As somebody who likes languages it is very obvious that usage of words are very important. And the term OOP is used widely differently. That was I wanted to express.

          Comment


          • Originally posted by sdack View Post
            To you perhaps it is, because there are many OO languages out there, some of which implement more and others less of the OO concept and maybe this is why it appears fuzzy to you.

            Object-orientation in C++ comes with a definition of access scope, data encapsulation, initialisation order, inheritance, and more,
            It's a lot more fuzzy than that. The person who coined the term OOP had to say this about C++

            Alan Kay also said: "I made up the term "object-oriented", and I can tell you I did not have C++ in mind."
            Your definition is not universal and there isn't a consistent understanding of what it means.

            Comment


            • Originally posted by spicfoo View Post
              It's a lot more fuzzy than that. The person who coined the term OOP had to say this about C++

              Your definition is not universal and there isn't a consistent understanding of what it means.
              You do not need to have a universal definition of it. You just need to understand what it is C++ offers you, because this is what we are talking about. It is still about moving from C to C++, not about creating tangents for ego's sake.

              Comment


              • Clickbait. More discussed here than on LKML ;-) ¯\_(ツ)_/¯

                Comment


                • I would rewrite everything in Pascal and release it under an MIT or BSD style license.

                  Even better, and I am 100% serious about this, write a proper compiler for Python and rewrite the whole thing in Python and release it under a truly free license, a simple 1 line that says "You can do whatever you want with this code".


                  Last edited by sophisticles; 10 January 2024, 03:01 PM.

                  Comment


                  • my prediction linus will accept c++ sooner or later. this is what happens when your project adopts a code of conduct.

                    Comment


                    • Originally posted by fitzie View Post
                      my prediction linus will accept c++ sooner or later. this is what happens when your project adopts a code of conduct.
                      Sure. Setting a minimum standard for acceptable social behaviour to facilitate inclusivity and growth logically implies your decades old project is bound to accept at least one more modern and expressive language

                      I can certainly see what angle you are coming from...
                      Last edited by Veto; 10 January 2024, 02:34 PM.

                      Comment

                      Working...
                      X