Rust is heavily based on Ruby’s design
I would not say “heavily based”. Literally only the closure/lambda syntax, which is cosmetic. Rust is mainly inspired by ML-family languages and C++.
I think Ruby is a reasonable choice for small scripts which someone might otherwise use Python for. But Rust is very well suited to more complicated or long-lasting command-line tools, especially if performance is at all a concern. Clap alone is super nice, but there are a lot of awesome libraries for making rich CLI tools easily.
- colored or owo-colors for adding terminal colors super easily
- crossterm for cross-platform terminal feature support
- rustyline for all your fancy readline needs
- cursive for TUIs
- comfy-table for command-line tables
And like…a hundred more I could mention. Idk, for anything that’s not completely trivial, which will be used and maintained by humans and not thrown away, Rust is really nice.
swordsmanluke@programming.dev 1 year ago
Aw man, you can’t write all that and then not give an example!
Ruby makes scripting drop-dead simple. You can run any shell command by surrounding it with back ticks.
That’s it! No messing around with popen3, or figuring out pipes or signals. Those are there too if you really need them, but if you just wanna write a quick script with a less arcane syntax - try Ruby!
snowe@programming.dev 1 year ago
Haha sorry, I wrote it all on my phone while traveling. and yeah, if you’re running just shell commands it looks almost the exact same as a bash script, and then when you need actual scripting capabilities you get them.