
What is the best language/framework to write CLIs in 2018? - wawhal
Hello HN,<p>I have an idea for a CLI and want to start writing it soon. I want a robust language&#x2F;framework that is meant for writing CLIs. I have used Golang&#x2F;Cobra before and I have done minor things using C++.<p>I also want this to be a learning experience. So I will be starting with the language&#x2F;framework from absolute scratch.<p>So the secondary question behind this Ask HN is, which CLI framework should you know in 2018?
======
stevekemp
It depends largely on what you're doing, and where it will be running.

If you're writing something that takes a bunch of flags, then parses text, I'd
use perl. If you're using somethign that must be easily installed on 100+
hosts then perhaps a binary compiled from go - because that's easy to install.

For frameworks? That's probably secondary to the actual core of your
application. If you're writing a complex UI with (n)curses then that's more
interesting and complex than calling getopt a few times..

------
donatj
I know you’ve used Go, but I personally think it’s unbeatable mostly because
it’s statically compiled binaries make them super portable. Compile once and
you can distribute a single binary file per platform.

------
neilsimp1
Granted, I've only ever written CLI apps using this and nothing else, but I've
written a few smaller CLI apps in C# using
[https://github.com/commandlineparser/commandline](https://github.com/commandlineparser/commandline)
and found the library to be a pleasure to work with.

------
jordancampbell
I write all my CLIs in Python.

I find that I always need various random things to work together and have
always found Python to be the most robust at this. Plus it has pretty much
anything you'd need already implemented.

~~~
wawhal
Type safety is important to me. So not going for python.

Otherwise python is the go-to because of the libs.

~~~
dragonwriter
> Type safety is important to me.

Isn't that what mypy is for?

------
BjoernKW
In terms of portability and installed base Python or Perl probably are the
best choices. They come installed with most UNIX, BSD or UNIX-like operating
systems such as Linux.

~~~
vgy7ujm
Python can feel sluggish due to slower startup time so I would skip that and
use either Perl or Go.

Definitely Perl for UNIXy stuff.

------
vgy7ujm
Perl or Go for sure.

~~~
wawhal
Never used Perl. Would love to learn it. Just went through the overview. Looks
like a high-level scripting language which inherits a lot from C.

After all the research, I am still highly inclined towards Golang. Since you
said "Perl or Go", you seem to have used Golang. How does Perl compare with
it?

~~~
vgy7ujm
Perl has decades worth of high quality libraries to do heavy lifting.
[https://metacpan.org](https://metacpan.org) You can get away with easy
scripting for creating significant programs.

UNIX commandline and Perl is a match made in heaven.

Using Golang will demand significantly more effort when doing more complex
stuff but will give you concurrency, easier deploys/multi-platform support and
better performance if doing CPU intensive stuff.

~~~
vgy7ujm
I use Go for what I previously maybe used C for.

Thanks to the quick compile time and good tooling Go almost feels like a
scripting language when developing but especially for UNIXy stuff it can't
replace Perl for me.

