3 ms·
> Does anyone really think there is an advantage Rust brings here over everything else -- Golang, Python etc. Yes! IMO building CLI tools is one of Rust's swee
by ripley12 4y ago
> Does anyone really think there is an advantage Rust brings here over everything else -- Golang, Python etc.
Yes! IMO building CLI tools is one of Rust's sweet spots for a few reasons:
- Rust is great at building small, fast, statically linked executables. Python and a lot of other languages are not.
- Rust has excellent cross-platform support. The stdlib and crate ecosystem do a remarkable job of building abstractions that work across *nix OSs and That Other OS. Go's Windows support is relatively mediocre IMO.
- The `clap` arg parser is great
Ultimately I think the proof is the large number of very high-quality CLI tools written in Rust (things like bat, ripgrep, fd, watchexec). They were kind of a gateway drug for me; I first got into Rust because so many of my favourite CLI tools were written in it, and I wanted to compile/tweak them.
- dralley 4y ago> small ... executables. > clap Isn't clap kind of notoriously bad about executable bloat and compile times?
- vlmutolo 4y agoDepends on your definition of "small". Clap will add significantly to the compile time, but your binary won't be too much larger. Rust binaries tend to fall in the range of 2–30MB, depending on lots of things. But that's still relatively small compared to Go, or even Python if you consider needing to bundle the interpreter for "fully statically linked".
- ripley12 4y agoclap adds about 300kb with my usual release mode profile (lto = true, opt-level = 'z', panic = 'abort', strip = true). Bigger than I would like but for most projects I'm OK taking the binary size hit for nicer ergonomics and more features than argh.