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

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++.

-20

u/maxjmartin Aug 29 '24

I’m not saying Rust is a wrapper. I’m saying that at least a portion of it does rely on C++ or at least has in the past. Look to the need for C++ on Windows in the past. Or the fact that many crates are C++ wrappers. When is that code ever going to be rewritten in Rust?

16

u/[deleted] Aug 29 '24

What portion of the Rust language relies on C++?

And what does Rust crates binding to C++ have to do with anything? That isn't Rust being dependant on C++.

When is that code ever going to be rewritten in Rust?

  1. Lots of code is being rewritten in Rust, it's not an immediate process but there's lots of progress (see Fish for a recent example)

  2. Why does it need to be rewritten if the bindings work well?

-6

u/maxjmartin Aug 29 '24

LLVM is written in C++. So there is that. Also IIRC there are or were some C++ bindings tied to different platforms. Those I can’t say if that is true today.

I have a project I want to rewrite into Rust but can’t. Due to how a simple template can’t be utilized in Rust. Now I could rewrite almost all the rest in Rust. But that one part would have to stay in C++ and interface with the Rust code.

If old code runs solid there may also not need to be a reason to rewrite it. So having project dependencies rely on other languages does mean those languages will never die.

The best part about Rust is it remove many of the other languages complexity through abstracting it away.

9

u/Zde-G Aug 29 '24

I have a project I want to rewrite into Rust but can’t. Due to how a simple template can’t be utilized in Rust. Now I could rewrite almost all the rest in Rust. But that one part would have to stay in C++ and interface with the Rust code.

Sorry, but I don't belive it even for a nanosecond.

Would the solution done in Rust with macros and traits be more awkward and hard to support that template-based C++ solution? Absolutely.

Does it mean you couldn't switch to Rust for everything, including that part? Heck, no.

I'm also using TMP a lot and use it a lot in my $DAYJOB. And I like it.

But could I replace that 1000 LOC TMP-based solution with 10000 LOC Rust solution?

Absolutely.

Sure, it would be much larger and more awkward and harder to support, but if that's only 1% of my library then I have just made 10% of my library harder to deal with while 90% is easier to deal with. A clear win!

And I'm yet to see any problem where TMP comprises more than few percents of the whole code for a business-requested task.

-3

u/maxjmartin Aug 29 '24

Well I haven’t found a solution yet! I’m using templates for method overloads. That way I can have different classes invoke different behaviors when called by a function without needing to define inheritance. All while abstracting away the memory management and memory safety.

10

u/Zde-G Aug 29 '24

That's called traits in Rust and doesn't require any tricks. You are probably omitting some important detail in your description.

Templates are replaced with macros in Rust and sometimes using traits there could help, too. And yes, they are much more awkward to use, but as I have said: if we are talking about small part of the codebase then you can tolerate it.

Large, entirely TMP-based libraries like Eigen couldn't be ported to Rust and need full rewrite, but if your TMP-based code is only part of the larger thing (as is usually the case) then solution could be found, if you'll think deeper about it.

5

u/maxjmartin Aug 29 '24

To be fair I haven’t played with macros that much. I have been looking at generics instead. But you aren’t wrong that the argument abstract of a macro might be feasible. After your comment I revisited the learn Rust books section on them.

So the difference is probably my ignorance in Rust vs C++ for porting that over.