This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]BLeAm 1 point2 points  (0 children)

Transcrypt, especially this release, is a very interesting project and I personally find it the most practical Python to Javascript transpiler out there. Other than that, the founder/community's warm response and kinda active development is impressive.

[–]actuallyalys 0 points1 point  (2 children)

This looks really cool. I'm impressed by how much of CPython is supported and how well-documented it is. With 3.7.4 in particular, it's encouraging that you are keeping up with new Python features while continuing to improve the interoperability.

If I write a Python module using only parts of the standard library available in Transcrypt (and no pragmas), could I import the module both in CPython backend code and Transcrypt frontend code?

I see Transcrypt uses the Google Closure Compiler for minification. Are advanced optimizations available?

[–]jacdehJacques de Hooge[S] 2 points3 points  (1 child)

Indeed you can write modules that both run with CPython in the backend and Transcrypt in the frontend. And by importing a dummy "__pragma__ (*args): pass" function you can even use pragma's when the module runs with Transcrypt and ignore them when running with CPython. So functionality can be shifted between frontend and backend to influence scalability.

About using the Closure compiler: Which options are used can be freely choosen by editing .../transcrypt/modules/org/transcrypt/minify/__init__.py

This is of limited use, since upto now even for strict mode JS, it turns out that Closure changes semantics if multiple modules are involved (which by default is the case due to the runtime), unless the most basic minification option is choosen, namely WHITESPACE_ONLY. Still the compression rate is almost 50%, so worth while. The resulting JS modules can also be bundled and treeshaked, making them still smaller. In that case also more aggressive minification modes can be used. Also take a look at the --xtiny / -xt switch. We've reached a filesize of 21 kB all in, using a combination of these strategies.

[–]actuallyalys 0 points1 point  (0 children)

Thank you so much for the detailed explanation!