Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Thank you for your insight. I have but one question.

What does Cargo the rust package management tool have to do with make, the declarative build system? It would seem they are unrelated to an outsider such as myself.



Part of managing packages is how those packages are actually built. For example, let's say that I'm starting a project in C. I'd write some code, and write a makefile to make it easier to build, so that just a 'make' suffices. In Rust, you use Cargo instead of make: "cargo new foo" will give you a Cargo.toml pre-filled, and a src directory to put your code in. "cargo build" will then build your project.

Work goes on, and how I want to use, say, a library for a hashmap of some kind. In my C project, I would probably be adding a git submoule, and then modifying my make files to build the dependency, and configure how to link it in with my code. With Cargo, I add a line to my Cargo.toml, and "extern crate bar" to my source file, and upon the next "cargo build", Cargo will handle the downloading, compiling, and linking of that library, as well as any sub-dependencies it has.

Now, it's also true that make is broadly more general than Cargo, and so in some circumstances, you'll use them together. I have a hobby OS project, for example, and so I have a Makefile which calls nasm to compile the assembly, cargo to compile the Rust, and ld to link the two together. Eventually, I would hope that Cargo can do it all, and I could probably make it work, but it's not inherently bad to use make either. Stuff like operating systems are the only case where I've felt that need; Rust itself is currently built with Make, because it pre-dates Cargo, but we're in the process of cargo-ifying our build as well.

Does that make sense?


Yes thank you for the clarification. I have been mostly pleased with the things I've seen and heard from the rust community and I really should dive in.

I am pleased to hear that Cargo, rather than attempting to be a rust-specific make replacement, is a tool that obviates the need for using make or make-like tools by automating the things you would have used it for, only.

Make and Cargo together sounds like just what I wanted to hear, and your hobby OS project sounds like fun.

Finally, I think it's great that Rust will be using Cargo itself soon, but I am curious if the reverse is possible -- if I want to put in the extra effort, can I build my own rust software in make alone WITHOUT Cargo?


You can absolutely use Rust without Cargo, you'd just call `rustc` yourself directly.


That's just what I wanted to hear!

Thanks again.


To elaborate on Steve's comment, Cargo fundamentally operates by calling rustc itself. You can pass the `--verbose` flag to Cargo to see the commands that it generates.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: