Language for CLI

Is Rust suitable for creating fast and lightweight cli apps? I tried to compare with C, but they are not having much differences at output executable.

Yes! For lots of really small utilities, the c binary may be smaller, but rust binaries isn't so big that it matters for normal cli programs (and when it does matter, it can often be fixed).

I think are two sweet spots for cli progams in rust: 1) The really small and simple cli, using only the std library, is easy to write in a nice and clean way with rust. 2) Even better, for the more advanced cli, there are great crates (rust libraries) to handle advance command line arguments (clap, structopt), input parsing (serde, nom, etc) and lots of other things.

2 Likes

I stumbled on a blog post Rewritten in Rust: Modern Alternatives of Command-Line Tools the other day and you might find it interesting. I think CLI apps are something Rust has really excelled at so far.

One of the killer features of Rust for CLI is the structopt crate. It uses derive macros to parse command line arguments into a strongly-typed configuration struct, with basically zero boilerplate. Nothing beats that.

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.