4 ms·
Ask HN: CLI – Java or Python or Go?
We want to write a command line interface tool that will be distributed to our customers. It is intended to be used on Linux. This CLI tool primarily will do few remote REST API calls, copy large number of big files from local file system to remote server (like AWS S3) and is expected to take few hours to complete. We have lot of in-house Java expertise. Should we pick Go, Python, Java or some other language? I am biased towards Java but would like to hear additional opinions.
- pkphilip 8y agoWhy not rust? Rust has excellent CLI support, is fast, can do REST calls
- Karhan 8y agoI think you'll have the fewest distribution issues with a go binary. But if you have lots of experience building and distributing java programs to your customers then go with what you know!
- danieka 8y agoBeing able to build Go into a binary without any dependency makes distribution really easy. As a user I prefer a single file that I can download and run and as a developer it has really simplified builds and deploys.
- shoo 8y agoagreed. for a user to get a python cli to work they will need to install python and any open source libraries your cli depends on (unless you use some tool to bundle all the dependencies with your app, in ye olden days this was py2exe or similar for bundling for windows). similarly, for java you place the burden on your users to install a jre with go the standard build toolchain lets you easily cross-compile a bunch of statically linked binaries, so each user just downloads 1 file for their target platform and runs it. personally i am much more productive writing code in python than in go (this is largely a consequence of spending 20x as much time writing python than go) but go is dramatically more ergonomic from a deployment perspective and has a great cross-platform library and cross-compiler support out of the box
- priom 8y agoGo, use cobra. It's awesome and really easy to get started and complete the project.
- verdverm 8y agoCobra is great, add in Viper for config. Goreleaser for creating binaries, home brew, os packages, GitHub releases.
- CyberFonic 8y agoI have written several similar programs using Python's cmd.Cmd class. Command completion, help messages, etc are all taken care of. All I need to do is to write the nitty gritty for each command and copious log the actions taken their return status to catch any networking, REST, etc issues. It is even possible to nest command interpreters within command interpreters to create sub-commands if applicable. I should mention that I am more productive in Python than either Java or Go - so this may taint my view of alternatives.
- haglin 8y agoJDK 11 comes with a new HttpClient. Might be useful and fun to learn. https://docs.oracle.com/en/java/javase/11/docs/api/java.net.http/java/net/http/HttpClient.html https://docs.oracle.com/en/java/javase/11/docs/api/java.net....
- m0ck 8y agoYou ask if you should use Java, Python or Go and the first three replies recommend you Java, Python and Go in that order, I love it.
- Adamantcheese 8y agoJava because you have devs and you can just make a shell/batch script to launch a JAR.
- k0t0n0 8y ago> We have a lot of in-house Java expertise. Should we pick Go Give go an honest try. I am sure it will not disappoint you.
- Foober223 8y agoYou quote "in-house Java expertise" then recommend Go? Man that is not what you should quote, and he should use Java.
- sethammons 8y agoIt depends on your customers. Will they have the right version of python? Will they install the Java runtime environment and the correct one (I assume that is a thing, but I'm not Java person)? Or you can skip all of that and just use Go that runs as a single, stand alone binary and very likely uses less memory than Java.
- _frkl 8y agoAlternatively, you could always use pyinstaller to create a single static binary for a Python app, so no need for python to be installed at all. Not quite as performant as go, but should be good enough for this use case.
- kasey_junk 8y agoGo is excellent at building CLI commands of this type. It maybe the thing that it's best at.
- tmaly 8y agoI really like using Go for this. The single binary with zero dependencies makes it really easy to deploy. You do not need the jvm or python environment setup. If you change something like upgrading your jvm or python or a library, aside from the path, the binary keeps working. Maintaining things is just much simpler with a single binary.
- kevinherron 8y agoA lot of people here are suggesting Go for its single binary with no dependencies, but if you're starting a small green field project in Java you should have no issue making sure it's jlinkable and even compiling it to a single statically linked binary with Graal. This way you can re-use your Java expertise and still get a statically linked single binary with quick startup.
- vkaku 8y agoIf you want to integrate with AWS/Azure, Python is the language of choice for CLI. It's because the actual AWS CLI/Azure CLI is written in Python and they have the most supported interface so far known. I personally like Go because it's easier to ship a static binary but in this case I would recommend otherwise.