lainchan / λ
Rust and C++ interoperability
CarlosMZ · 2024-11-19 21:11
https://www.heise.de/en/news/Rust-and-C-hand-in-hand-strategies-for-better-interaction-10055678.html
https://foundation.rust-lang.org/news/rust-foundation-releases-problem-statement-on-c-rust-interoperability/
In an avalanche of bad news, this one made my day better.
This mature, wise attitude on the part of the Rust Foundation about living in harmony and coexist with other tools instead of thinking about replacing and deprecating languages only for ego racing has managed to change my perspective for the better on Rust, because now I do really want (and I'm excited to) try the language for personal projects and serious development. This will bring many benefits both on a technical and human level.
We are not enemies. We do not have to fight.
Cooperation will lead us to awesome things.
What should be obsolete by now is the idea of killing languages and tools just for the sake of it. That childish attitude will get us nowhere. We are programmers, not evangelists.
XERXES · 2024-11-20 07:58
I've said this before, but I've always seen Rust less as a replacement for C++ (and even less as a replacement for C!), and moreso as a mid-level language akin to Objective C and C#, where performance matters, but not quite as much as security and correctness. The only reason people make the C++ comparison to begin is because Rust happens to do its job exceptionally well, blowing its actual competition out of the water.
Spooky · 2024-11-22 10:14
>Problem Statement
Even if they get to implemented proposals, the C++ standards good old boys' club will veto it if they don't feel the vibe
https://izzys.casa/2024/11/on-safe-cxx/
CarlosMZ · 2024-11-22 20:18
>>40471
I truly beg you, please do not be so pessimistic.
I acknowledge that there are undesirable, pedantic people on both projects who will act with bad faith. But I honestly hope the individuals with the final word will take the correct and most beneficial decision for both sides. Pointing fingers and picking fights will not get us anywhere.
If I must give an opinion on the article you provided: I can tell that the person who wrote that tantrum just likes to start arguments and pick fights for the sake of it. The best thing to do would be to completely ignore this type of people who would be better off doing politics in some dishonest congress instead of Computer Science.
Spike Spiegel · 2024-11-22 21:03
>>40471
>its a CoC on CoC battle
The drama is exceptional, I'm very much enjoying it from a distance.
Dox · 2024-11-23 10:24
>>40460
It's a welcome initiative, but I'm not sure what "misery" they want to find a way out of. I recently finished a C++ project with core business logic inside of a Rust library and did not experience any misery with cxx, it was a very smooth sailing. LTO worked very well across the language barrier too, and the resulting binary was much smaller than we expected, knowing that Rust is famous for its bloated runtime.
Ivan Petrov · 2024-11-27 06:39
>>40462
>The only reason people make the C++ comparison to begin is because Rust happens to do its job exceptionally well, blowing its actual competition out of the water.
The whole reason rust was created was for mozilla to rewrite their C++ browser engine.
>Rust happens to do its job exceptionally well, blowing its actual competition out of the water
What examples do you have of large real world rust projects doing "exceptionally well"? From what I've seen all "rewrite X in rust" projects have failed miserably.
>>40471
This looks like a very long rambling rant from a mentally ill person. I expect most people read the first line, look at the scroll bar, roll their eyes and close the tab. Is there any specific part you think is valuable and want to highlight?
Pulse · 2024-11-27 14:19
>>40491
>The whole reason rust was created was for mozilla to rewrite their C++ browser engine.
That doesn't change what it ended up actually being.
>What examples do you have of large real world rust projects doing "exceptionally well"?
I meant that it accomplishes the task exceptionally well. In terms of performance, Rust blows every other mainstream mid-level language out of the water.
But in terms of adoption, you're kind of right, although it's definitely doing better than the likes of D and Nim. Rust is a good language, but it stands on well-tread ground. Most of the software that probably ought to be written in Rust is already written in something else that does that job well enough that Rewriting It In Rust really isn't worth it. Off the top of my head, the biggest project I can think of that's primarily written in Rust is Ruffle, which is a very ambitious (and thus-far, successful) Flash emulator.
Naomi Nascimento · 2024-11-28 12:59
>>40499
>I meant that it accomplishes the task exceptionally well. In terms of performance, Rust blows every other mainstream mid-level language out of the water.
You mean in contrived benchmarks and useless toy applications.
>But in terms of adoption
They managed to force rust support into the linux kernel and yet nobody is using rust for any serious kernel code. All they've got is a few example drivers. Strange since rust is such a brilliant language.
Terzibashjian · 2024-11-28 15:37
>>40505
>You mean in contrived benchmarks and useless toy applications.
This is just what I observed, so your mileage may vary, but in my experience actually working with Rust, it's a much faster language than the likes of Objective C and C#, which, realistically, are what Rust is competing with. Resolving lifetimes statically alone gives it a huge leg up in terms of performance.
>>40505
>and yet nobody is using rust for any serious kernel code
Because it was a bad idea. Despite its best efforts, Rust is not C and never will be.
>Strange since rust is such a brilliant language.
What is it about Rust that makes people furiously angry? It's far from a perfect language, but it's definitely not a bad one.
Six · 2024-11-28 15:47
>>40506
>about Rust that makes people furiously angry?
Its fanbase. Since a language doesn't exist in a vacuum and most people don't want to use a language with inexistent community, since that implies no tooling, libraries and whatnot, the community of a language does affect people's perception of it.
Stallman · 2024-11-28 21:32
>>40506
Rust for me tends to be very frustrating as I've had to use it before in production. Rust as a language is very poorly designed and at odds with itself.
Further since Rust is a batch language (there only exist a batch compiler), one gets very long feedback cycles meaning the only tool people really have to quickly check if things are wrong is it's type checker. The Type checker isn't magic and won't solve one's issues. Since Rust's typing is much more limited than some other MLs I've used this just makes it even more frustrating. If you come from languages which aren't batch this feels very jarring, as in live languages you can live inspect values even using these values to design new modules/classes for your system as you write it. I've been pampered myself in using environments that give me guis for data structures I create as I write to help aid in correct and explainable code, making this issue of long feedback cycles with opaque more frustrating.
> it's a much faster language than the likes of Objective C and C#, which, realistically, are what Rust is competing with.
I believe if your use case can withstand GC, then rust is not a good language to chose for a project, as the major limitations that leads to rust making sense is use cases where GC can't be used and thus your pool of languages is limited to Ada, C, Forth, CPP, and Rust. Since Ada and Forth are rare these just leads to people to compare CPP, C and Rust for the task.
However if GC is allowed, then it's about how far you can push a language for a particular architecture you care about. Erlang for example doesn't top any charts on numerical performance, however since Erlang is tailored towards building distributed fault tolerant systems it actually performs quite well when making systems like that that one might make slower in an attempt to gain some of Erlang's properties. Greensputh's tenth rule strikes again and again:
"Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp."
Kay · 2024-11-29 15:03
>>40508
I guess I (>>40506) like Rust for what it is, rather than what it isn't, which sounds passive-aggressive, but is mean in complete earnestness. Maybe it's because my primary language is C, but the way Rust handles so many high-level things that I previously thought needed expensive runtime support right at compile time impresses the hell out of me.
Liet Kynes · 2024-12-09 13:42
>>40507
This can only say a person who have never programmed in Rust and only read some soykafposts on 4chan (I can go on that further but I'd rather not).
The community in Rust is amazing. People are always understanding and helpful to the point where I got answers to almost all questions I had (by asking on users.rust-lang), this is amazing compared to the usual elitist passive-aggressive responses I was getting from C/C++ communities before.
>>40508
> batch compiler
The first time I am hearing this term.
> Rust as a language is very poorly designed and at odds with itself.
Any examples?
> as the major limitations that leads to rust
Which limitations? Most of the modern C++ programs look exactly like Rust (with std::shared_ptr instead of Rc<RefCell<T>>).
>>40506
> Because it was a bad idea. Despite its best efforts, Rust is not C and never will be.
While I agree that unsafe in Rust is very finicky and annoying (compared to writing things in C). Most of the kernel code is high-level enough that you don't really need to use unsafe when working there. Also Microsoft is rewriting a lot of core code to Rust and Fuchsia exists, so not a bad idea after all?
Nemissa · 2024-12-10 07:34
>>40635
>Microsoft is rewriting a lot of core code to Rust
>a lot of
How much is that?
() · 2024-12-10 07:37
>>40639
* 2 projects: dwrite and Win32k
* 2 devs, 6 months to rewrite 152KLOC C++ to 90KLOC Rust re dwrite
* Performance increases of 5-15% re dwrite
* Only about 10% of Win32k code is unsafe
* No perf regressions re Win32k
* Syscall in the Windows kernel now written in Rust
And this was more than a year ago.
Lukasiewicz · 2024-12-11 06:47
>>40640
LMAO
I think Haskell transpilled to C has much adoption.
Iverson · 2024-12-11 11:32
>>40650
dwrite is one of the most common places vulnerabilities pop up on Windows.
But you can live in your world where Rust doesn't matter and is useless, not like it matters in the end.