Re:Programming languages endorsed for server-side use at Meta
by dralley on Wednesday July 27, 2022 @05:27PM
(#32257240)
> small ... executables.
> clap
Isn't clap kind of notoriously bad about executable bloat and compile times?
Re:Programming languages endorsed for server-side use at Meta
by vlmutolo on Wednesday July 27, 2022 @06:22PM
(#32257803)
Depends 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".
Re:Programming languages endorsed for server-side use at Meta
by ripley12 on Wednesday July 27, 2022 @06:35PM
(#32257923)
clap 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.
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.