r/rust • • Aug 29 '24

One Of The Rust Linux Kernel Maintainers Steps Down - Cites "Nontechnical Nonsense"

https://www.phoronix.com/news/Rust-Linux-Maintainer-Step-Down
586 Upvotes

374 comments sorted by

View all comments

Show parent comments

-51

u/maxjmartin Aug 29 '24

Because Rust can’t do some things C++ can. Don’t get me wrong. I really like Rust. But as I have been learning and using templates more I find that C++ is the right choice for many situations.

Also that lack of object oriented design support can make things awkward. Also making C++ a good choice for some things.

That said I’m all about using the right tool for the right job. I don’t care how fast a program is if it is broken. Also I don’t think Rust takes memory safety at run time into proper account. In that sense it reminds me of TypeScript in comparison to JavaScript. All of the benefits of TypeScript are lost during the JavaScript runtime. IIR, Rust compiles down to C++. So in effect Rust adds a framework to write better code with enforced safety. Which improves performance and programmer productivity.

But that last fact alone will ensure C++ never dies.

41

u/geckothegeek42 Aug 29 '24

IIR, Rust compiles down to C++.

No?

[Rust] improves performance and programmer productivity.

But that last fact alone will ensure C++ never dies.

How does that follow?

But as I have been learning and using templates more I find that C++ is the right choice for many situations.

Also that lack of object oriented design support can make things awkward. Also making C++ a good choice for some things.

Ill have to disagree. Trying to do OOP in rust is awkward, so don't do it. I seriously doubt there is any real problem that needs OOP. But as long as people try to use OOP to tackle those problems they will think c++ is the right tool. Long term, I think it won't be. Same with ad hoc duck typed templates. You learn a bit about it and think wow what a tool to solve problems. But it's not necessary and extremely fragile when tackling bigger problems.

-25

u/maxjmartin Aug 29 '24

To my knowledge Rust is dependent on C++ for at least a portion of itself. Recently I was wondering if C++ expression templates could be used as a wrapper around the internal implementation of many of Rusts data types. Simply because the simple code I wrote in C++ gave me around the performance I see with methods like zip for example in Rust. Hope that clarifies.

If Rust does depend on C++ for a portion of itself then C++ will never go away. Instead it will evolve. This has happened with other languages. JavaScript for one. C++ for another. C++ code written in Cxx20 is different than the renaissance that Cxx11 was. Which is completely different than Cxx98. In that sense C++ will I’m sure get a memory and borrow checker at compile time. Along with rewriting the standard to remove UDB.

Concepts and Traits are a good example of this evolution.

I really like OOP. But I LOVE functional programming. So for me combining the two makes for a solid workflow and environment. Basically OOP is no different from FP. The methods of an object are simply postscript function invocation using dot method invocation. Or using infix operations by passing an argument.

So having a thing that can be reasoned in that way means that it is easier to manipulate. A Vec is an object. Which can be vec.zip(), vec.push(x), or sum(vec). We naturally just think about things as objects. The concept of a bit is an object. And just think about what reason about it like that has accomplished. There will always be OOP.

25

u/[deleted] Aug 29 '24

To my knowledge Rust is dependent on C++ for at least a portion of itself.

No? Rust uses LLVM but that doesn't make Rust some sort of wrapper around C++.

→ More replies (7)

8

u/geckothegeek42 Aug 29 '24

Recently I was wondering if C++ expression templates could be used as a wrapper around the internal implementation of many of Rusts data types. Simply because the simple code I wrote in C++ gave me around the performance I see with methods like zip for example in Rust.

Why would you want that? Template code is either simple or useful, rarely both. Bringing up iterators is interesting because the rust design is far and away superior to the mess of iterators and ranges in c++ that don't even come close to the functionality, composability or usability of rust iters.

Additionally your understanding of rust and c++ relationship seems woefully misinformed in a way I simply don't even know where to start correcting. Except to say completely forget everything you know about it and read up on how rust is actually implemented.

Along with rewriting the standard to remove UDB.

There is more UB in c++ ever day. It will not be removed and no one working on it wants to.

Concepts and Traits are a good example of this evolution.

Yes and concepts barely cover the functionality and safety of traits. They cannot achieve parity because of how templates work and the need to be backwards compatible. Thank you for illustrating the massive wall that c++ faces to it's evolution.

The methods of an object are simply postscript function invocation using dot method invocation.

Method call notation is not necessary nor sufficient for OOP. Nothing you've described is OOP. Saying FP is no different from OOP may be the most wrong statement possible. If it were then why do you or anyone need OOP? If that's all you want then fine rust supports it. but that's not what people are referring to. Eg, rust does not and will never support inheritance.

There will always be OOP.

Again, disagree and you have provided no justification for this. How many things last forever?

→ More replies (9)
→ More replies (7)

16

u/jkoudys Aug 29 '24

I don't agree with a single thing you've said, but I do respect your bravery for saying it in r/rust

8

u/sm_greato Aug 29 '24

People in r/rust love smearing Rust, IMO (compared to hardcore fans of other languages). Psychologically, it probably means that they don't appear cultist, which is a massive stereotype they probably don't want. A less cynical reason is that yes, maybe people know the limits of the language and really do want to grow. Rust is not super popular. They definitely migrated here. Who's to say they're not willing to do so again, at least to a lesser degree, in terms of advocating for new features or different tooling?

But here, /u/maxjmartin just seems to have a really naive opinion on this. Like Rust is based on C+⁠+ because LLVM is written in C+⁠+? Just no. That's not sound reasoning. For someone to say that, there must be a really big gap in understanding.

1

u/maxjmartin Aug 29 '24

So the point I’m making about C++ is that it isn’t going to die when it is used to define the toolset that compiles Rust. While Rust is to my knowledge compiled to LLVM assembly code, it is still being handled by a C++ written handler LLVM. Also C++ libs are required to run Rust at least on my machine. So there is a coupling there. In other words Rust isn’t a C++ killer.

Also as I was pointing out in another comment I’m not that familiar with macro writing. So not a Rust expert either. Or C++ for that matter. But I do believe in using the right tool for the right job.

5

u/ukezi Aug 29 '24

It's more like you need a compiler. That compiler at the moment uses LLVM and that is implemented in C++. It doesn't need to be implemented in C++. Could use Rust, Go or even Python, but nobody is going to start reimplementing LLVM anytime soon.

For the libs you need certain system libs, mainly a C lib like musl libc or glibc, that expose a standardised C interface. You can write them in a lot of languages, most often it's C, but they could be written in Rust.

3

u/sm_greato Aug 29 '24

That's such an edge case. If all but one project uses C++, I'd still consider the language dead. And who said you couldn't rewrite LLVM in Rust?

Also C++ libs are required to run Rust at least on my machine.

No? What are you talking about?

1

u/maxjmartin Aug 29 '24

In Windows in order to run Rust code I had to have MSVS installed with a specific C++ lib to compile Rust. I do t know if that is still a requirement these days though.

That said I have no idea what portions of Rust interacts with LLVM via C++ or some other method.

1

u/sm_greato Aug 30 '24 edited Aug 30 '24

"A specific C++ lib" What library are you talking about?

I don't know everything about this as I don't use Windows, but Rust needs a linker. By default, it will use MSVC's because that's the default linker for the platform as a whole. This has nothing to do with C+⁠+ as a language. You could use Rust's LLVM's linker as well, or even MinGW's. Furthermore, sometimes you may need Windows' libraries to do things, and you need something to provide it for you. None of those things have to be written in C+⁠+, and in fact, are always exposed through C.

1

u/maxjmartin Aug 30 '24

Well I would have to go back in time to see what was needed specifically. But the fact that the entirety of Visual Studio and the MS build tool was need was surprising to me at the time.

That is when I discovered that LLVM uses C++ bindings to define language structures that are compiled to the assembly byte code which is compiled. This includes writing actual classes that define the code. Though that isn’t the only way.

But that is the sort of coupling of Rust with C++ I’m talking about. For example the iteration functionality in Rust is fast and intuitive. Like crazy fast. The only way I get that in C++ is using an expression template to removes the temporary objects. Is that just an optimization applies by the compiler, or is part of the language interfaced using C++ and an expression template? Which would be super easy to do for any class. So is that part of the compiler or a specific design choice?

But that is one of the best strengths for Rust. The abstracting away that complexity while focusing on string type and memory safety. But that also makes certain things ungodly hard to do in Rust. That is also one of the reasons I don’t see C++ going away either. Because you can use it for almost anything in simple ways. As well as easily abused and broken ways too.

1

u/sm_greato Aug 30 '24

That is when I discovered that LLVM uses C++ bindings to define language structures that are compiled to the assembly byte code

Well, I don't know what else you would expect when LLVM is written in C+⁠+ and I also don't get how that changes anything.

1

u/maxjmartin Aug 30 '24

Well if the bindings are used then the Rust code is being written to a C++ class. One that can take advantage of things easy to do in C++ that aren’t easy to do in Rust.

A hypothetical example- would be using an expression template to remove temporary so that the compiler can optimize it for fast computation of a loop. Again hypothetical but possible.

→ More replies (0)

2

u/angelicosphosphoros Aug 30 '24

It is not important on which language the compiler toolchain is written as long as it compiles programs correctly.

1

u/maxjmartin Aug 30 '24

Agreed!

LLVM allows code definitions via C++ classes. There are other ways of doing language descriptions though. I would need to double check the documentation but it is my understanding that code gets compiled to assembly through the C++ interface through some C++ intermediate code in some instances.

So in that sense if Rust uses that interface then it does rely on C++. Or is taking advantage of the optimization that can be applied in that way.

So in that sense C++ will never die. But I do think it will get used more in partnership with other memory safe languages.

1

u/fintelia Aug 30 '24

Yeah, if you want to farm up-votes in r/rust just make a post asking what everyone else thinks is bad about the language

2

u/maxjmartin Aug 29 '24

I just had to come back up for air after laughing at the truth of your comment.

Rust is pretty phenomenal, and so are others. The best part about Rust though is it looks out for my stupidity as a programmer.

9

u/Daniyal_Biyarslanov Aug 29 '24

"The lack of object oriented design can make things akward" my dude once i've found out about traits and enums i've never looked back

-1

u/maxjmartin Aug 29 '24

I can totally appreciate that!

To be clear though. I’m not advocating for C++ over Rust. I’m just saying make use of the right tool and the right modeling for the specifics of the task. So if code is written I. Rust (or memory safe language) is used then the right attention can be given to the unsafe code so to prevent issues.

4

u/Zde-G Aug 29 '24

Except OOP is never the right tool for any job, in a today's world.

OOP is a hack which had it's time and is no longer needed.

It's not suitable for a tiny micros with a few kilobytes of RAM. It's useless on large systems with memory measure in megabytes (and today we usually measure it in gigabytes).

It's a smart hack which made amazing things possible on original Alto but which is either useless or dangerous in today's world.

It's really amazing how much imprinting affects us: decades after something stopped being useful we are still clinging to it simply because that's something that was shown to us as the way to write programs decades ago.

1

u/maxjmartin Aug 29 '24

I respect your opinion. But I don’t agree. I think that the right kind of abstraction needs to be utilized for the situation at hand. And OOP can totally fit that need. But that doesn’t mean it is the only or best way to

2

u/sm_greato Aug 29 '24

Great ideals, but in practice, use what you like the most. It will probably improve both your mood and the chances of you actually getting done with it. There's nothing that's fundamentally incompatible with either C+⁠+ or Rust.