Announcement

Collapse
No announcement yet.

More Rust Code Readied For Linux 6.3 - Closer To Having Rust Drivers Upstreamed

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

  • #31
    Originally posted by uid313 View Post
    Linux doesn't use C++ but maybe such changes can find themselves back in C with newer versions of the C language?
    Is C2x getting any safety improvements?
    Linux kernel does not use a stock C as anyone who as tried to port Linux kernel to different compilers has found out. You start off that the Linux kernel uses GNU extensions to C. Then you have sparse that static analyzer and a GNU plugins on to to validate submitted code.

    The Linux usage of C is a lot more memory safe than stock C++ usage. Yes this is purely because its not stock C and they have extend C. Yes sparse looks for extra attribute information in code that if not there it errors out. The plugins are looking for stack overflows and objects leaks. Objects Leaks are interesting one C++ and Rust are default tooling does not cover this.

    How the argument to use C++ with Linux kernel has always falling apart is the same issue. Linux kernel C has been extended for a long time picking up issues a stock C or C++ compiler is not going to pick up. Adding C++ support would equal making the tooling to detect those extra faults more complex.

    Rust has advantage with it borrow checker that it does check for at least some of what the extend C Linux kernel developers have made does check for as well as it base language being more strict.

    C++ vs C with what is in the standard C++ wins the problem is this is not what the Linux kernel is. Linux kernel custom version of C happens to detect and prevent issues that stock C++ is going to let slide.

    Lot of C++ so called better features end up depending on classes that end up using name mangling that creates it own form of issues for runtime introspection for kernel panics and the like. Rust yes has name mangling but you don't have to use name mangling features to get most of it extra protections.

    The part where the instruction modern C++ falls apart is if I say you are forbin to usage of name mangling modern C++ no longer works to provide the protections.

    Yes rust does not have classes but has traits that can be used to do same basic thing. Remember catch here coding a program in rust and being secure does not mandate you use traits/classes. Not using them means no name managing. No name managing less complexity in crash reporting code in OS kernel code.

    Linus Torvald argument against C++ is mostly we can do X protections without name managing so what is the advantage of C++ other than making crash reporting code more complex. Rust language has lots of protections without using the name managing so Linux kernel developers see it as future acceptable.

    Comment


    • #32
      Originally posted by uid313 View Post
      Bjarne Stroustrup the father behind C++ says that C++ has unfairly got a bad reputation and claims that modern C++ is much more safe and secure than it used to be back in the days and that they're working on improving C++ to make it even more safe and secure.

      Linux doesn't use C++ but maybe such changes can find themselves back in C with newer versions of the C language?
      Is C2x getting any safety improvements?
      Not to sound demeaning, but I'm guessing you haven't used either Rust or C/C++, or don't know how language evolution works.

      The reason Rust is not just safe, but the safest non-pure language ever made (so far) is because of it's ownership system. Rust's ownership system is extremely complex, mechanically speaking (it's easier to understand for end programmers than people give it credit for, but highly complex to actually implement). It's built in to the language for a reason, because the language itself was built around the ownership system. You cannot retrofit the ownership system on to a language, it's literally impossible. If you tried it, you would simply create an entirely new language. And that right there is the issue. Yeah, you technically can retrofit an ownership system in C or C++. It would make a language where zero amount of existing code would compile. So you have, in effect, made a new language that nobody uses and has no support or ecosystem.

      This is why Stroustrup is full of it. It's legitimately impossible to make C++ as safe as Rust without simply adding an entirely new system or meta-language on top of C++, you'd basically be making an entire new opt-in language over C++. That's the biggest rebuttal against his tirade, that even if he accomplished such a butchery of his language, it would merely be opt-in, as in, not default, not the pit of success. It would be an option, and who knows how many people would take it (certainly not 100% of people). And then, if he accomplished it, none of the existing code would work with it. Existing C++ libraries would be just as cumbersome to use from "Safe C++" as it is now from Rust. His argument is "C++ is already here". Well, if Rust is already here, and already safe, why not just work towards using C++ from Rust rather than waiting to work at using C++ from "Safe C++".

      Safe C/C++ is a moot point, because, in effect, you're asking to create a whole new incompatible C-like language and asking everyone to stop using existing C/C++ and go to the "safe C/C++" and modify all their existing code to work with the new "safe C/C++". Guess what, that's literally what Rust is. And that's why Stroustrup's argument is completely irrelevant.

      Comment


      • #33
        Well, but we have been writing C/C++/assembly for quite a while now and so far things work just fine.... Even in the kernel. Along comes a new wanna-be kid on the block claiming great things because they've moved the 'extreme complexity' (words from above) into the compiler and framework. Rather than a KISS compiler (relatively) we now have an 'extremely complex' one. Hmmm. How's that going to work out in the long run . I'd rather it be the other way around myself. But academia deems there has to be a better mouse trap... and right now Rust is the new darling for those who want safety over freedom to code (sounds political doesn't it) .

        Meanwhile in the real world ... IEEE has Rust down at #20 on language usage. ( https://spectrum.ieee.org/top-progra...22#toggle-gdpr ) At least it is recognized on the chart . Someday it may even have a 'standard' written for it .
        Last edited by rclark; 13 February 2023, 10:04 PM.

        Comment


        • #34
          Originally posted by rclark View Post
          Well, but we have been writing C/C++/assembly for quite a while now and so far things work just fine.... Even in the kernel. Along comes a new wanna-be kid on the block claiming great things because they've moved the 'extreme complexity' (words from above) into the compiler and framework. Rather than a KISS compiler (relatively) we now have an 'extremely complex' one. Hmmm. How's that going to work out in the long run . I'd rather it be the other way around myself. But academia deems there has to be a better mouse trap... and right now Rust is the new darling for those who want safety over freedom to code (sounds political doesn't it) .

          Meanwhile in the real world ... IEEE has Rust down at #20 on language usage. ( https://spectrum.ieee.org/top-progra...22#toggle-gdpr ) At least it is recognized on the chart . Someday it may even have a 'standard' written for it .
          Did you perchance want to try Rust instead of pretending Assembly language of all things is a good language to program non-trivial programs in?
          I don't understand the injection of politics. I've used dozens of languages, Rust is the first one to make me feel confident my program works before I even bother running it. I feel more "free to code" (what the hell does this mean?) than ever before. Honestly, I feel almost irritated I had to put up with so many runtime errors from other languages when they should have told me ahead of time my code didn't make sense. That's kind of the point of a programming language.

          Comment


          • #35
            rclark Until you find out how complex gcc and llvm is and how complex the C++ language is.

            Comment


            • #36
              Originally posted by Berniyh View Post

              > “There are two kinds of languages: the ones people complain about and the ones nobody uses.”

              Which one is Rust?
              > Stack Overflow Survey [...]

              Programmers were too busy coding to vote. Getting stuff done that runs the world (and all those other programing languages many of which are just fancy C++ programs).
              -- https://developers.slashdot.org/comm...0&cid=62651212 (Score:5, Interesting)

              Comment


              • #37
                Originally posted by rclark View Post
                Well, but we have been writing C/C++/assembly for quite a while now and so far things work just fine.... Even in the kernel. Along comes a new wanna-be kid on the block claiming great things because they've moved the 'extreme complexity' (words from above) into the compiler and framework. Rather than a KISS compiler (relatively) we now have an 'extremely complex' one. Hmmm. How's that going to work out in the long run . I'd rather it be the other way around myself. But academia deems there has to be a better mouse trap... and right now Rust is the new darling for those who want safety over freedom to code (sounds political doesn't it) .

                Meanwhile in the real world ... IEEE has Rust down at #20 on language usage. ( https://spectrum.ieee.org/top-progra...22#toggle-gdpr ) At least it is recognized on the chart . Someday it may even have a 'standard' written for it .
                Popularity is problematic because in your list there is only 3 programming languages that are quite "modern" - Rust, Kotlin, and Go. Go is slighty older and has easier learning curve and reached initial version 1.0 much earlier then Rust so that explains why Go is higher in ranking. Kotlin meanwhile is similar ranked. And except that there is no modern languages on par with those.

                It is because it is hard to push big corporation to try some new technology. In fact only biggest corporations are willing to spend resources to go forward. Where i work people are using non stop on frontend Angular or React. Over and over again, meanwhile I see Svelte, Vue, Solid and i see they are superior but managment is unwilling to take risks.

                This is visible in Rust, communities like Reddit, Discord, Stackoverflow (and tons of threads here on Phoronix included) are full of discussions about Rust - people are interested in it, people are willing to learn it or already learned it. But then managment is looking at top ok we don't have resources to make entire new project in Rust because everyone would need to learn it etc.
                Last edited by piotrj3; 14 February 2023, 06:56 AM.

                Comment


                • #38
                  Originally posted by rclark View Post
                  so far things work just fine
                  Clearly not. There's a constant stream of bugs and vulnerabilities, and although we're getting better at finding or preemptively mitigating them, it's taking more and more work to do so.

                  Along comes a new wanna-be kid on the block
                  Rust 1.0 is 8 years old now, it's not a pet personal project anymore. It has convinced engineers of all skill levels, across a range of project types and company sizes. It's not hype, many aspects of Rust are a fundamental step up compared to C/C++, which have only managed to drop-feed incremental improvements over the past decades.

                  Rather than a KISS compiler (relatively) we now have an 'extremely complex' one. Hmmm. How's that going to work out in the long run . I'd rather it be the other way around myself.
                  Modern C and C++ compilers are far from KISS, they are complex, hard to diagnose/maintain pieces of code. Some KISS C compilers exist, but they're not what most people use. The rust compiler isn't any more complex than gcc or clang, and probably easier to maintain thanks to carrying less baggage and Rust being easier to write than correct C/C++. Rust moved some complexity from the developer to the tooling; that's the whole point of software engineering.

                  Meanwhile in the real world ... IEEE has Rust down at #20 on language usage
                  And in another real world, rust development has already overtaken C and will likely overtake C++ this year. You can argue about source bias and proper ranking methodology, but you can't argue that Rust is one of the mainstream languages now, and getting more popular every year.

                  In the end you should not care about the language, just about writing better software. Have C and C++ gotten better and will they continue to improve ? Of course, like all languages, from Rust to Javascript. Will they catch up to Rust level of correctness and ease of development ? Not in the foreseeable future. Will something better than Rust come along someday ? I sure hope so, but reaching mainstream is really hard.

                  Comment


                  • #39
                    Originally posted by rclark View Post
                    Well, but we have been writing C/C++/assembly for quite a while now and so far things work just fine.... Even in the kernel. .
                    And you don't get a feeling that anything could be improved about those languages? Fascinating

                    Comment


                    • #40
                      Originally posted by Weasel View Post
                      That guy literally said "as will most programmers", despite C++ being far more popular than Rust.

                      Sounds to me like he's living in a big delusion like all "Rustaceans".
                      What he “literally said” is: “I will continue to use other programming languages, that are already memory-safe, for my new projects, as will the majority of programmers.”

                      And that’s true, definitely more programmers start new projects in Rust + Java + Python + JS + Kotlin + C# + Ocaml + Haskell +Elixir + … than those who start new projects in C++ (or in C, or in Assembly). Even if there are still more C++ programmers than Rust programmers, that sentence wasn’t about Rust alone, nor only about low-level close-to-metal projects. He makes that very clear earlier, when saying “As I mention before, safe programming languages have existed for a long time. Many programming projects that in the early 90’s would have been done in C or C++ have in fact been done in safe programming languages instead (…)”.

                      Of course, there are still domains where C++ or C are more common (definitely more C++ programmers in gamedev than Rust people, though I guess most gamedevs actually write C#), embedded (though Rust becomes more and more popular), etc.

                      But the point made implicitly is that with Rust people tend to use the language in the whole stack, all the layers – not just the lowest-level library with higher-level logic calling to it from Python/Java/whatever – because Rust works as a relatively pleasant high-level language too (even if one difficult for quick prototyping, you probably want something like Python for that). While the unsafe languages are limited to the lowest-level stuff where you need all of the control, and most (but by no means all, there are fans of C++ out there, of course) programmers avoid those languages whenever they can.
                      Last edited by silmeth; 14 February 2023, 09:31 AM.

                      Comment

                      Working...
                      X