4

I am faced with building a front end application for a scientific project, where the original scripts come from R and python. I found this interesting framework called OpenCPU(https://www.opencpu.org/) which claims to provide a seamless integration between R and javascript.

Now I am faced with the issue for python and javascript integration. Are there any good frameworks for this? Please help with suggestions?

P.S.(converting the python script to R script is ruled out since the python script depends on external libraries specific for python)

1

Since you can't run python on client side, you can either port it yourself or use a compiler/converter. Here's some python to javascript compilers:

  • PYXC-PJ [CS friend] Python to JS. Can generate a (line/col)-number mappings file.
  • Pyjamas Python to JS.
  • Pyjaco Python to JavaScript compiler with module support.
  • Pyjs Python to (readable) JS.
  • Skulpt Python. Client side.
  • PyCow Python to MooTools JS.
  • PyvaScript Python-like syntax to JavaScript.
  • RapydScript JavaScript with a Pythonic syntax.
  • Brython browser python
  • PythonScript Python-like compiled to JavaScript
  • pythonscript Python compiled to readable JavaScript using the AST. (proof of concept)
  • PythonJS Integrates several python to js methods into one project. Very Active.
1

There are a number RPC protocols out there, usually the problem is the other way around - Python is well supported but R isn't.

I wouldn't completely rule out CGI in this scenario. Just be sure to keep the number of round-trips required to an absolute minimum. It's a very old and simple idea - the request comes in and the web-server runs an instance of Python or R - whichever the requested script requires, and returns the output. JSON is a likely to be a very good choice of output format as it can easily be written by both Python and R, and consumed by JavaScript.

Given that Django is well regarded Python web-framework and Shiny is a well regarded R web-framework - neither of which I know anything about - I'd be inclinded to find out what they have to offer before committing myself to introducing a third language, JavaScript, into the mix (even though it is by far my favourite language of the three).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.