Python to JavaScript: Overview of Transcrypt, Jiphy, Brython, and RapydScript
An overview of four projects—Transcrypt, Jiphy, Brython, and RapydScript—that enable converting Python code to JavaScript, highlighting each tool’s features, limitations, and the broader context of Python’s role in web front‑end development and its ecosystem.
Choosing between Python and JavaScript? While many still debate which language is currently more dominant or has a brighter future, in the web front‑end domain the answer is clear: without JavaScript there is essentially no viable project on the browser platform.
However, the answer is not absolute. JavaScript has become the target for many languages to compile to (e.g., TypeScript, Emscripten, Cor, Cheerp). Python, with its large community and extensive libraries, is also an attractive source language for conversion or transpilation to JavaScript.
Below are four projects that can smoothly bring Python into the JavaScript world, one of which stands out with flexible bidirectional conversion capabilities.
Transcrypt
Transcrypt is a recently emerged Python‑to‑JS transpiler that promises high‑quality generated code. It preserves much of the original Python structure, including multiple inheritance and lambda expressions, and allows Python code to call objects in the JavaScript namespace directly (e.g., accessing document.getElementById from Python).
According to its documentation, Transcrypt leverages CPython’s abstract syntax tree module to perform the translation, accessing Python’s own parsing mechanisms. Although still in alpha testing, it has already shown impressive appeal.
Jiphy
Jiphy (JavaScript In, Python Out) enables bidirectional conversion between the two languages, allowing mixed code before translation.
The current limitation of Jiphy is that it only supports a subset of Python features; classes and default arguments are not yet supported, though decorators and exception handling work. The project is also looking to incorporate newer ES6 features to broaden Python support.
Brython
If WebAssembly becomes mainstream, developers could choose any preferred language for web development. Brython, targeting Python 3, already provides a JavaScript library that simulates all Python 3 keywords and most built‑in modules, allowing Python scripts to be embedded directly in web pages. It also offers a high‑level Python‑to‑DOM interface that can be used from JavaScript.
Nevertheless, Brython inherits the same limitations as JavaScript in the browser, such as the inability to access the local file system.
RapydScript
RapydScript promises “Pythonic JavaScript that isn’t terrible.” Similar to CoffeeScript, it lets developers write code in a Python‑like syntax that compiles to JavaScript, combining the best of both languages. It features clear Python syntax while providing JavaScript capabilities like anonymous functions, DOM manipulation, and compatibility with libraries such as jQuery or Node.js.
Source: http://www.infoworld.com/article/3033047/javascript/4-tools-to-convert-python-to-javascript-and-back-again.html Author: Serdar Yegulalp Reposted from: 51CTO http://developer.51cto.com/art/201602/505811.htm Translator: 核子可乐
The article concludes with a QR code and promotional text for a mobile app offering online video courses, supporting Android and iOS.
Qunar Tech Salon
Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.