5 ms·
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?
- tumdum_ 10y agoAlthough 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.
- deleted 10y ago[deleted]
- morpheyesh 10y agoGo 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 :)
- steveklabnik 10y agoIf the functional constructs are slow, it's a bug. Iterators often compile to identical assembly as for loops, for example.
- lfx 10y agoIs 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.
- jacquesm 10y agoAny compiled language that you already know how to use.
- dsparkman 10y agoI would say Go. Stick with the standard library and you compiling for all the supported platforms is pretty straight-forward.
- hilti 10y agoI'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.
- imauld 10y agoI 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.
- cbanek 10y agoI 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-profile-a-python-script 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.
- brbsix 10y agoI'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 https://github.com/jaredallard/nexe
- vram22 10y agoGo, D, maybe Nim may be worth checking out for this.
- binki89 10y agoI'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.
- ex_amazon_se 10y agoYou are looking for Nim: Python-like syntax, faster than Go, statically compiled.