Hacker News new | ask | show | jobs
by santa_boy 2567 days ago
I'm having the requirement to work with Node and Python now. I write my webapps in node but have data analytics scripts written in python to be invoked. I'm planning to use [python-shell - npm](https://www.npmjs.com/package/python-shell)
2 comments

Have you considered GraalVM? You can run both languages inside the same managed runtime (JVM), sharing the same data structures, inlining across language boundaries, and debug both with Chrome Dev Tools.
"Analytics" generally means "cython only". The numpy dep ends up being a problem.

Generally if you want python/java interaction, we maintain a tool called javacpp that handles this, we even bundle cpython: https://github.com/bytedeco/javacpp-presets

GraalVM itself also depends on javacpp for a portion of its features (LLVM wrapper): https://github.com/oracle/graal/blob/315f5dcf69c2e73fd13a5f8...

I'd be happy to answer questions about the overlap of the 2. I can say I happily execute python scripts from our embedded python and even point the python execution at an anaconda distribution.

How much have you used GraalVM? I'm curious to know if it really works like that in practice. I've read what it says on the tin a few times and been impressed, but haven't actually sat down and played with it yet. The skeptic in me thinks that in a real-world production scenario, such a thing is surely a house of cards that falls down all the time in unexpected and difficult to diagnose ways. It'd be great to hear if there's people who can vouch and say it actually delivers on its promises of a polyglot utopia :)
Graal itself still has limitations with many libraries yet, the biggest one being having any library that heavily uses reflection. I'd look at some of the work red hat is doing with some of its java libraries and quarkus: https://developers.redhat.com/blog/2019/03/07/quarkus-next-g...
IIRC you also end up relying on a graal-provided version of python that may or may not be kept up-to-date by a project for which it's just a secondary target. Been there with IronPython and Jython, it's no fun.
Thanks for the input.

I remember coming across GraalVM. However, as I solo developer, I have found learning another new thing to be detrimental to my ability to getting things done. I have wasted way too many hours learning new frameworks, languages, platforms, etc.

I'm doing my best to avoid learning something new except when a strong compatibility with my current stack exists and is quickly implementable.

There's also python-bridge: https://github.com/Submersible/node-python-bridge

I don't recall now why I chose it over the much more popular python-shell. Sigh - the exploratory-spike log is sparse, and then "that all works, so why revisit low-commitment choices". I used it last year for a python helper, to offload some opencv and tensorflow optical tracking from electron.

(Both exist, and work, in javascript. But opencv had painfully subtle issues even with py3 vs py2, so I payed complexity to be closer to then mainstream center py2. And then moved tf over to work around chromium's excellent video latency and load (for passthrough AR) becoming much less so when also touched by the cpu.)