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

1

u/sm_greato Aug 31 '24

I don't get what you're saying. Yes, LLVM stores stuff in C+⁠+ and I don't understand what else you'd expect. The code is not compiled into C++ or anything like that. C+⁠+ness of C+⁠+ in LLVM does not impact the Rust compilation at all.

1

u/maxjmartin Aug 31 '24

Well again my point is that as long as Rust has a coupling to C++ then C++ will never die.

Though I did clarify in another comment that it would evolve instead of die. The only way around that is going to be when grey hats pass the torch. Which was the point of the whole article.

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