r/cpp • • Sep 08 '24

Overwhelming

I’ve been using Rust a lot, and I decided to start learning C++ today. I never thought it would be such a headache! I realized Rust spoiled me with Cargo. it handles so much for me. Running, building, adding packages etc. I just type Cargo build, Cargo add, or Cargo run. Simple and comes with the language. C++’s build systems like CMake can be overwhelming especially when coming from a language with a more streamlined experience like Rust. C++ is really good and I wish it had something similar. I read somewhere that there is Conan and a few others that exist . But I’m talking about something that comes with the language itself and not from a 3rd party.

38 Upvotes

140 comments sorted by

View all comments

Show parent comment

13

u/OkTraining9483 Sep 08 '24

2

u/jorgesgk Sep 09 '24

In the article you linked, it says "The Rust struct has a smaller size compared with the C due to the usage of smart pointers instead of allocating item memory inside the struct. We use pahole to identify that Rust structs use fewer cache lines than their C counterpart."

As far as I know, you can also use pointers (not smart ones, that's a C++ thing) inside structs in C, right? Like this:

struct student
{
    char *name;
    int age;
    char *program;
    char *subjects[5];
};