Is it possible to run native python code in chrome?

后端 未结 2 1074
春和景丽
春和景丽 2021-02-13 19:13

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 com

相关标签:
2条回答
  • 2021-02-13 19:55

    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).

    0 讨论(0)
  • 2021-02-13 20:14

    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.

    0 讨论(0)
提交回复
热议问题