Transcrypt is a free, open source browsers & extensions project written in Python and released under Apache-2.0. It has 2,916 GitHub stars, 218 forks and 206 open issues, and was last pushed 3 months ago. On this registry it ranks #85 of 133 tracked projects in Browsers & Extensions, with 5 head-to-head comparisons available.

What is Transcrypt?

Transcrypt is a Python 3.9 to JavaScript compiler that precompiles Python into readable, efficient JavaScript for professional, extensive, real-world web applications, and it is for developers who want Python's clean, modular structure in the browser without giving up JavaScript-class load and run speed.

What it is

Transcrypt is a compiler, or transpiler, that takes pure Python 3.9 syntax using Python's native parser and generates JavaScript 6. It lives in the browser and JavaScript ecosystem, and it also runs on top of node.js. The compiler precompiles code into highly readable, efficient JavaScript that downloads kB's rather than MB's, and it generates JavaScript for humans that resembles the Python source line by line, optionally annotated with source line numbers. Integrated sourcemaps allow debugging directly from Python sourcecode. The language support includes multiple inheritance, optional operator overloading, metaclasses, async/await, properties, decorators, and hierarchical modules. It integrates seamlessly with the universe of high-quality web-oriented JavaScript libraries rather than the desktop-oriented Python ones.

The concrete problem it solves is that Python developers who want browser applications previously had to either write JavaScript by hand or rely on tools that compile Python on the fly in the browser. Transcrypt replaces both approaches by compiling, optimizing, and minifying in advance to warrant fast page loads, which the README describes as a design goal fundamentally different from tools that compile on the fly in the browser. It deliberately favors seamless access to existing JavaScript libraries over inclusion of many Python libraries in the distribution, with exceptions such as math, cmath, random, itertools, re, time, datetime, and turtle. There is no eval and exec of Python code. Transcrypt is targeted towards building professional, extensive, real-world web applications that load and run as fast as their JavaScript counterparts while offering Pythonically clean, modular structure and maintainability.

Key capabilities

  • Compiles pure Python 3.9 syntax using Python's native parser into JavaScript 6.
  • Generates JavaScript resembling the Python source line by line, optionally annotated with source line numbers, and includes integrated sourcemaps for debugging directly from Python sourcecode.
  • Supports multiple inheritance, optional operator overloading, metaclasses, async/await, properties, decorators, and hierarchical modules.
  • Integrates seamlessly with web-oriented JavaScript libraries rather than desktop-oriented Python libraries, and includes some Python modules: math, cmath, random, itertools, re, time, datetime, and turtle.
  • Provides integrated static type checking and minification at the tip of a command line switch.
  • Precompiles into highly readable, efficient JavaScript that downloads kB's rather than MB's, with JavaScript 6 optimizations such as call caching, for-loop optimization, and in-line JavaScript.
  • Runs on top of node.js as well as in the browser, carries the Apache-2.0 license, and supports pip-install and go with latest stable release Berlin.

Who uses it and how

  • Developers building professional, extensive, real-world web applications that must load and run as fast as their JavaScript counterparts while keeping Pythonically clean, modular structure and maintainability.
  • Teams that need seamless access to the universe of high-quality web-oriented JavaScript libraries instead of desktop-oriented Python ones.
  • Projects that also run on top of node.js in addition to the browser.
  • Workflows that debug directly from Python sourcecode through integrated sourcemaps, and test from the command prompt using stubs.
  • Applications that require precompilation, optimization, and minification in advance for fast page loads, rather than on-the-fly compilation in the browser.

Getting started

Install with pip and go; the latest stable release is Berlin. The official site is https://www.transcrypt.org.

How it compares

The provided facts do not name any comparable tools. Transcrypt stands alone in this registry; its README only contrasts its precompiled design goal with unnamed tools that compile on the fly in the browser.

When to use it — and when not to

Choose Transcrypt when the target is professional, extensive, real-world web applications that need Pythonically clean structure and JavaScript-class load and run speed, and when precompilation is acceptable. Do not choose it if the project requires eval and exec of Python code, the full CPython standard library, or Python libraries beyond the listed exceptions (math, cmath, random, itertools, re, time, datetime, turtle), or if the intended workflow is on-the-fly compilation in the browser. The facts mention no database, storage, or SMTP service to operate; the compiler is pip-installable, and the repository shows 206 open issues.

project readme (upstream, from github) — read inline

.. figure:: https://www.transcrypt.org/illustrations/ruler_banner2.png :alt: Logo :target: https://www.transcrypt.org

Python in the browser, precompiled for speed: https://www.transcrypt.org

  • Precompiled into highly readable, efficient JavaScript, downloads kB's rather than MB's
  • Multiple inheritance, optional operator overloading, metaclasses, async/await, properties, decorators, hierarchical modules etc.
  • Seamless integration with the universe of high-quality web-oriented JavaScript libraries, rather than the desktop-oriented Python ones
  • Pure Python 3.9 syntax, using Python's native parser
  • Debug directly from Python sourcecode, through integrated sourcemaps
  • Generates JavaScript for humans, resembling the Python source line by line, optionally annotated with source line numbers
  • Lightning fast JavaScript 6 code: call caching, for-loop optimization, in-line JavaScript etc.
  • Integrated static type checking and minification at the tip of a command line switch
  • Also runs on top of node.js
  • Extensive documentation with many code examples
  • Apache 2.0 license
  • Pip-install and go!

Latest stable release: Berlin

>>> GET STARTED! __

Thanks to everyone who contributed!

Readability

As can be seen below, there's a simple parallel between the Python and the JavaScript code. In combination with the use of sourcemaps, this enables efficient debugging. Also, code can be tested from the command prompt using stubs.

.. figure:: https://www.transcrypt.org/illustrations/class_compare.png :alt: Screenshot of Python versus JavaScript code

**Classic OO with multiple inheritance in JavaScript**

Main differences with CPython

  • Web batteries: Seamless access to any existing JavaScript library has been favored over inclusion of many Python libraries in the distribution. There are some exceptions to this rule, e.g. math, cmath, random, itertools, re, time, datetime and turtle, and some more may follow, but in general the accent is on libraries that are relevant in the browser.
  • No eval and exec of Python code. This is again part of the concept. Transcrypt code is compiled, optimized and minified in advance to warant fast page loads. In this respect its design goal is fundamentally different from tools that compile on the fly in the browser. Transcrypt is targeted towards building professional, extensive, real world web applications that load and run as fast as their JavaScript counterparts, but offers Pythonically clean, modular structure and maintainability.

License

Copyright 2014 - 2023 Jacques de Hooge, GEATEC engineering, www.geatec.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

How to contribute

Transcrypt started out as a personal repo, owned by Jacques de Hooge. As the project caught on and the number of people contributing issues, ideas and code grew, the repo was transferred to the QQuick organisation, to be able to form a developer team on GitHub. Then more recently, to insure its continued development, the GitHub repo has been moved to TranscryptOrg _, where Transcrypt and related projects can be more centrally located.

There was also a clear message in this: Transcrypt isn't owned by anyone in particular. It is the collective property of everyone using it or contributing to it. At the same time the need was felt to keep a very firm grip on code quality, especially of the core.

Everything under ../transcrypt/modules/org/transcrypt plus the file ../transcrypt/__main__.py is considered to be part of Transcrypt's core. A major design goal is to keep the core small and fast. This means that some CPython facilities were deliberately left out or simplified. Core development is still mainly done by Jacques, but with the input of many great ideas submitted as issues. If you want to improve something in the core, this is best initiated by first opening an issue for it. Opening a pull request directly can lead to disappointment, although all effort is made to take good ideas seriously.

All other parts of Transcrypt are referred to as periphery. While a good quality pull request for the periphery stands a reasonable chance of being accepted, still it is wise to start an issue beforehand, allowing coordination and preventing waste of effort.

A special place is taken by implementing standard libraries. While Transcrypt mostly relies on browser-centric JavaScript libraries, availability of a limited number of standard libraries will help acceptance by Python programmers. So you're most welcome to make a contribution here. The design goal again is: better 90% complete, fast, small, and reliable, than 100% complete, slow, bulky and buggy. If you contribute a library, please also contribute an autotest (see docs) and some documentation for it. The supported platforms are Windows and Linux (and, with that, OSX).

While being open and respectful to any good ideas, the final say as to what gets in and what doesn't, is with Jacques. So this is a dictatorial rather than a democratic project. Being a sailer himself, Jacques values the notion of having one captain on a ship. The captain doesn't own the ship, but he serves the passengers by consulting with the crew and plotting one stable course.

Another possibility to contribute libraries to Transcrypt is by submitting them as separate packages to PyPi. In that case be sure to add the keyword Transcrypt to allow people to find your package. Making your package pip-installable will also help it to catch on. Contributing packages via PyPi of course means total freedom for the developer.

Deployment testing

The full set of testlets is described in the documentation and comes with the distribution. Each release is preceded by at least the following tests:

  • The automated back to back test described above, not only on Linux but also on Windows and, in case of relevant issues, on OSX.
  • Automated compilation of the manual tests, human exercising of the resulting applications and a visual check of the results.
  • Automated compilation of the demo's, human exercising of the resulting applications and a visual check of the results.
  • A documentation build, followed by a visual sample check.

What's new in the latest commits

  • Code generator adapted to Python 3.9 parser
  • Updated README and packaging configuration

Known bugs in latest commits

None

Other packages you might like

Frequently asked questions

Is Transcrypt free to use?

Transcrypt is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does Transcrypt do?

Python 3.9 to JavaScript compiler - Lean, fast, open!

What is Transcrypt written in?

Transcrypt is primarily written in Python. Its source is publicly available at https://github.com/TranscryptOrg/Transcrypt, and it has 2,916 GitHub stars.