Ask HN: Best high-level language for CLI application?
* Good framework for CLI usage (input, output, auth, etc)
* Performance
* Low, or none at all, dependency-hell
* Good framework for CLI usage (input, output, auth, etc)
* Performance
* Low, or none at all, dependency-hell
What does your CLI app do? What platforms are you intending it run on? Is it going to be doing a lot of CPU-intensive work? Is this CLI app going to be long-lived, run infrequently (e.g. fsck), or run perhaps many times a day by an actual real user (e.g. grep)? Is your app expended to be part of a Unix pipeline? All of these things are the real deciding factor between a compiled language and scripting language.
If it's not doing anything particularly computationally expensive, perhaps a scripting language like Ruby or Python. Hell, you could even do it with JavaScript with NodeJS. CLI apps are usually utilities and their start-up time often matters. With any of these scripting languages there will be a palpable start-up time. This might not be so important if your CLI app is to be run infrequently, or is otherwise something that's long-running.
If you're writing something that's going to munch and crunch data, or is otherwise doing a lot of calculations, or is going to be run frequently and needs a fast start up time, Go, C, C++ are good bets. There are probably others that may be appropriate, but I'm not familiar with Haskell, etc.
The vast majority of CLI utilities are written in C or C++ and this is for a reason. Not many are written in scripting languages, although some are, such as Puppet, Vagrant, Fabric, etc.
From what i could see, Ruby stands out in these terms. I'm not actually looking for a specific language feature, but the ecosystem.
- Cross platform, preinstalled on OSX and most Linux distros
- Awesome string processing and tons of libraries, good performance
- Good ecosystem, fairly modern and stable language with all the stuff you may want
- Wide variety of classes and utilities that comes with the standard lib. You may even use the standard library class, cmd to implement your cli
I'm the author of a CLI called cloudmonkey (http://pypi.python.org/pypi/cloudmonkey). It's an autocompleting interactive shell, CLI and command line tool that has features like;
- Autocompletion and interactive shell
- Also be used as a command line tool
- Auth using api and secret keys
- Pygment processed coloured output
- Tabular output, like mysql (instead of select * you use filter=)
- Pipes, shell input/output within shell
- Just 500 lines of core code, uses meta programming to support over 300 APIs of CloudStack, includes an api discovery feature (think git pull)
- If you want to read more: http://rohityadav.in/logs/cloudmonkey/
Different Python versions are included in various OS and in my opinion, Python packaging system pip is not as robust as Ruby gems or Node's npm.
Anything JVM-based is out, because of long startup times.
You must look at the highline gem too. Here's a small CLI app you can try.. https://github.com/rkumar/cetus