4 ms·
Maybe it's just because I am more familiar with C/C++, but I disagree. Cargo is very opinionated, forcing upon you certain directory structures and even a defa
by dahfizz 4y ago
Maybe it's just because I am more familiar with C/C++, but I disagree.
Cargo is very opinionated, forcing upon you certain directory structures and even a default VCS. If you have a large project, cargo makes you jump through hoops. Building multiple binaries and libraries from one project is a pain, and has to be done exactly as cargo wants.
In terms of being able to "just get started", I think `gcc app.c` is way easier than using cargo. But that's not really important. You're not going to replace a million line C project with Rust just because "getting started" was a few seconds faster/slower.
- cgh 4y agoDoes Cargo have the equivalent of Maven’s archetypes? Eg, project templates to generate a particular directory structure, some default files, etc.
- ssokolow 4y agoCurrently, it has two built-in ones for `cargo new` and `cargo init` (--bin and --lib) and there are third-party tools like `cargo generate` which provide for more, but they haven't accepted anything into the main distribution yet. https://github.com/cargo-generate/cargo-generate https://github.com/cargo-generate/cargo-generate
- jitl 4y agoYou can `rustc app.rs`, and do all the C Makefile stuff that way too (example in the kernel: https://github.com/Rust-for-Linux/linux/blob/rust/rust/Makefile https://github.com/Rust-for-Linux/linux/blob/rust/rust/Makef...). Nothing is forcing you to use Cargo except for convenience.
- linkdd 4y ago> Cargo is very opinionated, forcing upon you certain directory structures No, it expects source code in `src` like most C/C++ projects anyway. Then it's `lib.rs` or `main.rs`. The opinionated directory structure (`pkg.rs` or `pkg/mod.rs`) is rustc not cargo. > even a default VCS Because it's the one used by most projects. Anyway, nothing prevents you from using mercurial, svn, ... > Building multiple binaries and libraries from one project is a pain Have you heard of Cargo workspaces? Because I've had no troubles with it. > I think `gcc app.c` is way easier than using cargo Agree to disagree. Because really soon, you'll want to manage dependencies.
- einpoklum 4y ago> it expects source code in `src` like most C/C++ projects anyway In C/C++ there's no expectation of the code being anywhere. > Because it's the [VCS] used by most projects. I don't see how a VCS being popular is a reason to require it. It's not even "essentially all projects", just "most projects".
- linkdd 4y ago> In C/C++ there's no expectation of the code being anywhere. That's not what I said. I said that most project do it this way anyway, regardless of any expectations. So who cares? > I don't see how a VCS being popular is a reason to require it. It is not required.
- virtualritz 4y ago> I don't see how a VCS being popular is a reason to require it [...] Neither do the authors of cargo: `cargo new --vcs none`
- OJFord 4y agoAnd linking? Dependency management? C & Rust come from different eras of easy-getting-started, IMO: C - I just want to get shit done, I'm not taking on any dependencies, I'll just write it myself and sure it won't be the best but it'll do what I need and keep it simple; Rust - I just want to get shit done, surely there's a lib for this and that, I can just glue them together. So with Rust that's no harder to do than doing anything at all; with C it's quite a bit harder but also a bit easier if you don't. Agreed that's not going to hold any weight in deliberating switching a million line project, but I do think it matters what hobbyists/spare-timers are using, what people want to work with, etc. Slowly. (E.g. my day job is mainly python; if we needed something highly performant or embedded or whatever I'd be way more comfortable in Rust than ropey university-C.)
- ssokolow 4y agoThat's Cargo's by-convention auto-discovery. You can manually specify the same information in Cargo.toml if you prefer to customize it. https://doc.rust-lang.org/cargo/reference/cargo-targets.html#target-auto-discovery https://doc.rust-lang.org/cargo/reference/cargo-targets.html...