News for hackers. Stuff that matters.

Ask HN: Which language for writing a fast, distributable command-line tool?

I need to build a command-line tool to perform some fairly heavy computation. I would like end-users to be able to easily run the tool on their own systems.

I have written a proof-of-concept in Python, but it is unacceptably slow: 100 times slower than an implementation of the core algorithm in C++. Also, it would be awkward to distribute to end-users: the best option seems to be a tool such as PyInstaller which essentially creates a large, self-extracting archive. Running the Python code using PyPy fixes the performance issue (only 4x slower than C++), but makes distribution almost impossible.

So, I am looking for another language in which to write the production version of this tool. Which other language(s) would you recommend?

I would rather avoid writing the whole tool in a complex language like C++. Are there any other Python-like, dynamic languages which are faster and easier to distribute?

( 13 comments | 8 points | on HN )
Re:Ask HN: Which language for writing a fast, distributable ... by binki89 on Tuesday July 12, 2016 @03:57PM (#12081875)
I've previously used Go to develop a command-line tool and it worked quite well. I particularly liked the fact that I could cross-compile it so that I had a single static binary that could target various platforms/OSes without the need to compile explicitly on those platforms. I also think that Nim and Crystal could be quite good for this. Crystal, in particular has a remarkable scripting language feel, because of the extensive type inference, despite being natively compiled. It's also faster than Go, which is itself quite fast. Nim is no slouch performance wise either though and has the most pythonic like syntax of the languages I've described here.
Re:Ask HN: Which language for writing a fast, distributable ... by cbanek on Friday July 08, 2016 @05:13PM (#12058692)
I don't doubt that python is slower than a compiled language, but have you tried to do any profiling on your python code? Sometimes little changes could have a huge impact.

http://stackoverflow.com/questions/582336/how-can-you-profil...

I used the command line option described in the suggested answer. It was easy. Most profilers are hard, but this worked fine the first time.

Re:Ask HN: Which language for writing a fast, distributable ... by brbsix on Friday July 08, 2016 @07:44PM (#12059350)
I've been in this same boat a few times (e.g. looking to replace a slow Python tool that has big dependencies like PyQt5). The quick and easy solution (even for someone with very little JS experience) was to rewrite the application in Node.js and bundle it up as a single executable with nexe [0].

[0]: https://github.com/jaredallard/nexe

Re:Ask HN: Which language for writing a fast, distributable ... by hilti on Friday July 08, 2016 @04:32PM (#12058433)
I'm using newLISP for command-line tools and scripting. I love that it's capable of doing bayes calculation, parallel and distributed processing support is built-in and it runs on embedded systems too.
Re:Ask HN: Which language for writing a fast, distributable ... by morpheyesh on Friday July 08, 2016 @03:28AM (#12054050)
Go is definitely a good option. Also try Rust, its a system programming language that is the closest to C. It will be super fast if you don't abuse the functional constructs that the language provides :)
Re:Ask HN: Which language for writing a fast, distributable ... by lfx on Friday July 08, 2016 @12:38PM (#12056794)
Is it possible to distribute Rust `app` as easy as Go? I mean can you write one code and run on all platforms with zero dependencies?

P.S. I'm not proGo, just have near to zero knowledge about Rust.

Re:Ask HN: Which language for writing a fast, distributable ... by steveklabnik on Friday July 08, 2016 @11:02AM (#12056003)
If the functional constructs are slow, it's a bug. Iterators often compile to identical assembly as for loops, for example.
Re:Ask HN: Which language for writing a fast, distributable ... by ex_amazon_se on Tuesday July 12, 2016 @08:30PM (#12083254)
You are looking for Nim: Python-like syntax, faster than Go, statically compiled.
Re:Ask HN: Which language for writing a fast, distributable ... by tumdum_ on Friday July 08, 2016 @03:08AM (#12053991)
Although not a dynamic language, I think Go meets all of your needs.

It is statically compiled - you get one executable without any dependencies.

Its speed is much closer to C than to Python.

Type system and syntax is very simple.

Re:Ask HN: Which language for writing a fast, distributable ... by imauld on Friday July 08, 2016 @04:50PM (#12058550)
I also would suggest Go. Coming form Python writing Go came pretty naturally so you should have no problem taking your POC code and rewriting it in Go.
Re:Ask HN: Which language for writing a fast, distributable ... by dsparkman on Friday July 08, 2016 @11:32AM (#12056223)
I would say Go. Stick with the standard library and you compiling for all the supported platforms is pretty straight-forward.
Re:Ask HN: Which language for writing a fast, distributable ... by vram22 on Tuesday July 12, 2016 @02:55PM (#12081474)
Go, D, maybe Nim may be worth checking out for this.
Re:Ask HN: Which language for writing a fast, distributable ... by jacquesm on Friday July 08, 2016 @03:32AM (#12054061)
Any compiled language that you already know how to use.