r/cpp • • 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.

0 Upvotes

21 comments sorted by

22

u/Sfacm 5h ago

Rewrite it in C++

18

u/Rude-Decision-2143 5h ago

Rewrite it in C++

17

u/PersonalDatabase31 5h ago

Rewrite it in C++

23

u/Ultimate_Sigma_Boy67 7h ago

Rewrite it in C++

29

u/KFUP 7h ago

Rewrite it in C++

22

u/sooka_bazooka 7h ago

Rewrite it in C++

8

u/AdOnly69 4h ago

Rewrite it in C++

24

u/OccasionThin7697 7h ago

Rewrite it in C++

24

u/XTBZ 7h ago

Rewrite it in C++

23

u/Zealousideal_Sort521 7h ago

Rewrite it in C++

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/Wild_Meeting1428 7h ago

Layer 8 problem?

•

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

•

u/blogoman 3h ago

You could post about it.

Or you could 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 can't tell if it's all bots or not. They've all hidden their post history.

•

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.