I was wondering if it is possible to run native python code in chrome instead of javascript. I have seen projects like pyjs or brython, but what they do is compile python to javascript. While those are great projects a problem with this approach is always that you cannot easily debug the original python code.
Amongst other things I stumbled upon this thread, describing how to develop custom code for chromes-sandbox. But this would probably lead to implementing a python interpreter in the sandbox, which would be an overkill.
Any help is appreciated! (I don't want to start any python vs. javascript discussions, but only find out if this would be possible and if so, how to do it)
Kind Regards,
Marco
Python is a programming language, you can't run native code of a programming language. You can however, run programs written in python in the browser.
So can I run python code in the browser or not?
Update June 2013: The Brython project is now available letting you run Python 3 code in your browser. You can check it out at http://www.brython.info/ .
You can use run LLVM in JavaScript using ECMAScripten. This means you can compile c-python from C to JavaScript and just run JS in the browser. The link to the ECMAScripten wiki provides more details on how to do that.
(Here is a live demo of a python REPL running in the browser)
There also exist python 2 implementations that work in the browser.
But should I?
Probably not, JavaScript and python are similar in many things, both are dynamic, both are compact and both are clever. If you know python you can learn JavaScript very quickly.
If you like python's syntax, you might want to consider CoffeeScript which has similar syntax to Python (and somewhat to Ruby) and compiles to JavaScript transparently.
Solutions that run python in the browser will also tend to be much slower, at least until more browsers will support asm.js (currently only firefox nightly).
I believe you can create a compiler in Javascript, to run simple python code. There are probably some available programs as well that will allow this to be carried out. Although, it is not possible to run python directly through a web browser.