Python Browser Compilers
Ever since JavaSript became the default language for web browsers, the demand for technology that could translate to it has been unending. Assemblers and compilers, two subsets of translators, are the technology used to perform this conversion from another programming language to JavaScript. With Python becoming the most common "first-language" for developers due the simple syntax, the demand for a Python compiler is great. Coupled with it's powerful back-end capabilities, it is clear why programmers are looking to use it to build a whole app. There is still no standard compiler, but in this blog we'll look at three leading the pack. Brython Transcrypt PyOdide Dream of many programmers to use Python instead of JavaScript for front-end coding, but there is a simple unmovable obstacle. Browsers all support JavaScript, but not Python” Marc Nealer, Practical Brython What sets each of these apart comes down to some important factors including: at what stage of execution the code is compiled, how they interact with the DOM, and they utilize Python itself Other important features include the ways they handle Javascript events, and whether or not they utilize JavaScript or Python libraries Brython With a name meaning "Browser Python", it is fitting for Brython to top many lists of these compilers. Straight forward and python focused, Brython describes itself as an implementation of Python3 running in the browser. It interfaces directly with the DOM by inserting Python code directly inside HTML5 with script tags. ... A full example of a simple HTML page running Python might look like this: from browser import bind, document, alert @bind(document['mybutton'], 'click') def echo(event): alert(document["zone"].value) click ! Event handling is done via event listeners set up inside the Brython code: from browser import document, bind # get the element from the document el = document["mybutton"] #setup a function to be called def button_clicked(evt): print("mybutton clicked") #bind the element to the function so its run when the event occurs el.bind("click", button_clicked) However, this easy to use technique is also Brython's downfall. Brython compiles at the time of execution, giving it slow load times. Transcrypt Transcrypt the fastest. Interacts with traditional js libraries and has react for front end. Fastest Piodide Pyodide is perhaps the most traditional compiler due to it's association with WebAssembly. WebAssembly (WASM) Still need to understand basic front end js, css and html. But the more complicated aspects of JavaScript are taken care of in python

Ever since JavaSript became the default language for web browsers, the demand for technology that could translate to it has been unending. Assemblers and compilers, two subsets of translators, are the technology used to perform this conversion from another programming language to JavaScript.
With Python becoming the most common "first-language" for developers due the simple syntax, the demand for a Python compiler is great. Coupled with it's powerful back-end capabilities, it is clear why programmers are looking to use it to build a whole app.
There is still no standard compiler, but in this blog we'll look at three leading the pack.
- Brython
- Transcrypt
- PyOdide
Dream of many programmers to use Python instead of JavaScript for front-end coding, but there is a simple unmovable obstacle. Browsers all support JavaScript, but not Python”
Marc Nealer, Practical Brython
What sets each of these apart comes down to some important factors including:
- at what stage of execution the code is compiled,
- how they interact with the DOM,
- and they utilize Python itself
Other important features include the ways they handle Javascript events, and whether or not they utilize JavaScript or Python libraries
Brython
With a name meaning "Browser Python", it is fitting for Brython to top many lists of these compilers. Straight forward and python focused, Brython describes itself as an implementation of Python3 running in the browser. It interfaces directly with the DOM by inserting Python code directly inside HTML5 with script tags.
A full example of a simple HTML page running Python might look like this:
id="zone">
Event handling is done via event listeners set up inside the Brython code:
from browser import document, bind
# get the element from the document
el = document["mybutton"]
#setup a function to be called
def button_clicked(evt):
print("mybutton clicked")
#bind the element to the function so its run when the event occurs
el.bind("click", button_clicked)
However, this easy to use technique is also Brython's downfall. Brython compiles at the time of execution, giving it slow load times.
Transcrypt
Transcrypt the fastest. Interacts with traditional js libraries and has react for front end. Fastest
Piodide
Pyodide is perhaps the most traditional compiler due to it's association with WebAssembly. WebAssembly (WASM)
Still need to understand basic front end js, css and html. But the more complicated aspects of JavaScript are taken care of in python