from Hacker News

Ask HN: CLI – Java or Python or Go?

by itpragmatik on 3/22/19, 5:07 AM with 18 comments

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.
  • by kevinherron on 3/22/19, 5:07 PM

    A 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.

  • by haglin on 3/22/19, 8:05 AM

    JDK 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....

  • by priom on 3/22/19, 5:38 AM

    Go, use cobra. It's awesome and really easy to get started and complete the project.
  • by Karhan on 3/22/19, 5:12 AM

    I 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!
  • by CyberFonic on 3/22/19, 6:29 AM

    I 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.

  • by tmaly on 3/22/19, 4:32 PM

    I 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.

  • by sethammons on 3/22/19, 12:54 PM

    It 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.

  • by vkaku on 3/23/19, 4:02 AM

    If 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.

  • by Adamantcheese on 3/22/19, 10:22 AM

    Java because you have devs and you can just make a shell/batch script to launch a JAR.
  • by m0ck on 3/22/19, 9:56 AM

    You 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.
  • by k0t0n0 on 3/22/19, 10:38 AM

    > 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.

  • by kasey_junk on 3/22/19, 1:41 PM

    Go is excellent at building CLI commands of this type. It maybe the thing that it's best at.
  • by pkphilip on 3/22/19, 4:00 PM

    Why not rust? Rust has excellent CLI support, is fast, can do REST calls