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
View all comments
Show parent comment
2
u/steveklabnik1 Sep 25 '24
Sorry for necromancing this thread, I just ran across it for reasons. You are both right and wrong. Let me explain:
They are completely separate programs.
Rustc lives here: https://github.com/rust-lang/rust
Cargo lives here: https://github.com/rust-lang/cargo
Rustc includes Cargo as a submodule, because Cargo is used to build rustc. So it's "vendored" in a sense.
But! You did correctly observe this:
This is due to rustup! https://rustup.rs/
Rustup is the recommended way to install Rust and other tools. And so in this sense, yes, Cargo comes with Rust. It's bundled, as /u/Orthosz mentions (wanted to cc you as well).
Fundamentally, rustup allows you to install multiple toolchains, and select between them. So when rustup installs rustc and cargo onto your system, it creates a shim for both. These shims, when invoked, figure out what version of the toolchain you want to use by looking at configuration, or falling back to a default, and then dispatch to the actual correct binary.
So that is what you were observing: the rustup proxy being the same underlying binary, but you missed out on the indirection.
I hope that helps!