4 ms·
Ask HN: Best high-level language for CLI application?
What's the most appropriate language to develop a large CLI application? By appropriate, i mean:
* Good framework for CLI usage (input, output, auth, etc)
* Performance
* Low, or none at all, dependency-hell
- crazydiamond 14y agoRuby has several frameworks you can use such as vision-commander, main, and thor just to name a few. Boson, too. You must look at the highline gem too. Here's a small CLI app you can try.. https://github.com/rkumar/cetus https://github.com/rkumar/cetus
- kintamanimatt 14y agoThe answer, as with many things is: it depends. 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.
- klaussilveira 14y agoIt's a very big application, that requires an MVC approach for commands and their subcommands. That's why i'm looking for a language that has been battle-tested for complex CLI applications. This means frameworks, libs, docs and more. From what i could see, Ruby stands out in these terms. I'm not actually looking for a specific language feature, but the ecosystem.
- bhaisaab 14y agoPython! Because: - 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 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/ http://rohityadav.in/logs/cloudmonkey/
- klaussilveira 14y agoInsta-love with cloudmonkey. Thanks for the tips! :)
- nivertech 14y agoYou didn't mentioned packaging and installation. For native code you will need to create OS-specific packages. 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.