[Python-ideas] Towards harmony with JavaScript?

Chris Angelico rosuav at gmail.com
Fri Aug 11 13:37:08 EDT 2017


On Sat, Aug 12, 2017 at 3:04 AM, Alberto Berti <alberto at metapensiero.it> wrote:
> For the goal of reducing the friction (the mind switching when working
> with both the languages) I have created a tool (
> https://github.com/azazel75/metapensiero.pj ) which allows me to write
> valid Python and translates this to nice JS while taking care of most of
> these nuances. At the same time it doesn't raise any barrier between the
> translated code and any other JS library around (and I use them a lot).

What do you do about all the places where the languages have
significantly different semantics? For instance, a Python integer can
store more values than a Python float (which is broadly compatible
with a JS Number), but in JS, bitwise operations restrict the value to
32-bit. And subscripting or iterating over a string containing astral
(non-BMP) characters will do different things. Or when you use
non-string keys in a dictionary (notably integers). Transpiling is an
extremely dangerous thing to do a partial job of.

ChrisA


More information about the Python-ideas mailing list