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

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?

1

u/maxjmartin Aug 29 '24

The issues with C++ is also complicated by the refusal to break the ABI. Taken into consideration UDB will never go away either. But I do see the footprint being reduced over time.

We as people just think in terms of objects. The Platonic Theory of Forms, or mathematical category theory. All topics highly and with passion discussed about by advocates for particular perspectives in those fields.

So how we reason about things will always be in relation to one or more objects and how those object can be classified by conceptual traits, and manipulated by operations constrained by the classified traits of an object. Which can be done in multiple different ways.

Which bring me to your comment about traits. C++ has traits. Just like you can ensure a template argument needs to have a specific method implemented in Rust you can do that in C++ too. But the complexity in C++ is way higher. Which IMO make Rust superior in that sense.

C++’s biggest problem is its complexity. Rust on the other hand doesn’t have that level of complexity and doesn’t guarantee the ABI won’t change. Which also is IMO better.

I do think in general Rust is the better choice of the two. But that doesn’t mean C++ doesn’t have its place or does some things better depending on the needs of the project.

11

u/geckothegeek42 Aug 29 '24

But I do see the footprint being reduced over time.

It is not. Objectively. Almost Every single paper they accept into the standard adds UB and there is little interest in a paper doing the opposite.

We as people just think in terms of objects. The Platonic Theory of Forms, or mathematical category theory. All topics highly and with passion discussed about by advocates for particular perspectives in those fields.

Meaningless word salad of unjustified half claims. Forget passion, what does platonic theory of forms have to do with "class Square extends Rectangle" let alone my embedded program or my webapl?

So how we reason about things will always be in relation to one or more objects and how those object can be classified by conceptual traits, and manipulated by operations constrained by the classified traits of an object. Which can be done in multiple different ways.

You realise you are still not describing OOP right? That's fine many don't actually know what OOP is and think an object is just any thing. (Just like they think functional programming is having a lot of free functions or having higher order functions, it's not) But if you're going to seriously discuss it's merits, legacy and future as a design principle you must study up. Look into smalltalk for a start. A bit on it's own is not a value.

C++ has traits.

Close, it has concepts, which categorically cannot do all the same things a rust trait (or Haskell typeclass) can do. It's most basic failure is that I can write a function asking for a concept and then use other capabilities not covered by that concept. Thus my function is not actually strongly typed the way the signature implies. Which means the function cannot be typechecked until after monomorphization. They also don't enable runtime polymorphism. Theyre also structural rather than nominal (automatic rather than opt-in) thus having no way to check semantics on semantics only syntactic checking.

But that doesn’t mean C++ doesn’t have its place or does some things better depending on the needs of the project.

I theoretically agree but you still haven't really said and justified a place where it has its place. And that doesn't mean it will always have that place.

0

u/maxjmartin Aug 29 '24

We can disagree on specifics. And if I’m not going into enough detail as to those specifics that is probably because we are on Reddit and the size of those posts would be huge.

You can do compile time type checking and runtime polymorphism very easily in C++ with string type checking. Just write a class that invokes an interface. That interface has a single template argument that defines an object which is passed to a private struct implementation of the interface. The struct holds a pointer of the template argument. Then the struct calls another templated function of the struct data type.

Now I can write any class I want that overloads the final functional call as a friend function. That way at compile time the templated function evaluates to the right one to be invoked at runtime. And if the class doesn’t overload the templated function then nothing happens other than a simple definable default behavior that doesn’t create UB.

Oh and the class handles memory management and safety. So it is completely possible to use a monad very easily if desired in C++.

2

u/geckothegeek42 Aug 29 '24

String type checking? That mess of steps you described is very easy? Yeah right. I can't even begin to figure out whether that achieves anything I want it to.

Let me describe runtime polymorphism with traits in rust.

dyn Trait

Thank you for coming to my Ted talk

Your comments are a great example of why C++'s life is limited

1

u/maxjmartin Aug 29 '24

lol. Rust will not kill C++ anymore than C++ would or will kill C.

Rust will and is totally influencing its evolution though. Unfortunately though I don’t see C++ ever becoming as simple to use as Rust makes some things.

1

u/geckothegeek42 Aug 29 '24

Nah c++ will end itself. Whether that means it's completely gone or just a miniscule amount (yes that counts as being dead, no gotchas acting like "killed" has to mean not a single bit of c++ left, its obvious what I mean practically)

1

u/maxjmartin Aug 29 '24

Right because that happened to C…….. 🙃

2

u/LovelyKarl ureq Aug 29 '24

What do you mean Rust doesn't guarantee the ABI won't change? Rust doesn't have a (public) ABI apart from the C-ABI, which is extremely guaranteed to not change.

1

u/maxjmartin Aug 29 '24

Yes my point. As in the design of Rust tries to not create things which can’t be changed later. Which I do like about the language.