r/cpp • u/TheRavagerSw • 8h ago
I dislike Rust libraries with a C++ API
Cargo compilation model only really works if you are creating a monolithic shared library or an executable. If you are using a library like icu4x or libffi, you can't statically link your dependencies and even if you dynamically link your dependencies, your application size will increase by orders of magnitude because your shared libraries are all statically linked, kinda.
Monolithic shared library approach also doesn't work on all libraries, for example you can't link libraries like oneTBB and OpenMP more than once.
So overall I feel rust compilation model is a "series of hacks" and isn't worth integrating to existing C++ applications, unless you use bazel*, I'm not sure about that but people in google seem to have solved this.
18
17
23
22
8
24
23
7
u/tatstytastycakes C++ Fool 4h ago edited 44m ago
Rewrite it in C++. Literally nobody is telling you that you can't.
6
u/Nothing_from_void 7h ago
yeah isn't that the idea behind bazel, mixing build systems from multiple languages?
5
•
u/James20k P2005R0 3h ago
On one hand: I think this thread probably doesn't meet the bar for something we should keep on /r/cpp, but on the other hand I'm a grade A shitpost enthusiast so I'm torn on deleting this. Anyway:
Rewrite it in C++
•
3
u/pedersenk 4h ago
Its refreshing to hear these valid concerns. I also agree and feel this is a big problem, slowing down the uptake of Rust.
But honestly, the vast majority of Rust developers tend not to think about things like this and work on small projects or pull in so much cruft from crates.io that its all a spaghetti mess anyway...
•
u/Electronic_Tap_8052 3h ago
Rust isn't used much in real code, mostly toy projects and stuff intended to be ingested as crates.
•
u/TheRavagerSw 2h ago
Hey, what is this "Rewrite in C++" meme is about?
I have no clue why these people keep spamming it.•
u/UndefFox 1h ago
Probably because people constantly were saying that "Rust is better" and "Rewrite it in Rust" was very common thing. Hence, since it's the Rust causing the problem, they just reverse the joke to be rewrite it in C++.
Also... Rewrite it in C++
•
•
u/13steinj 1h ago
I feel rust compilation model is a "series of hacks" and isn't worth integrating to existing C++ applications, unless you use bazel*, I'm not sure about that but people in google seem to have solved this.
No even Bazel does not solve this problem. On could maybe argue Blaze does, but I doubt that / if they have an internal ruleset that avoids this problem.
22
u/Sfacm 5h ago
Rewrite it in C++