Likely my last shot on this thread, explaining why the goal of this proposal is to improve interoperability ...
We have already Pyodide and MicroPython working out of the box, meaning one can write the following code and be sure that when, and if, the interpreter changes, everything will still work as expected:
import js
js.document.body.textContent = js.Date.new().toISOString()
We can provide, if needed, modules that normalize access to the global context (that is import js
that points at import pm
), but when it comes to PythonMonkey, that code will break/fail because it doesn't use the same convention.
Theoretically though, that code could work as is also in other PLs, but that's a stretch ... what I am after here, is the fact interoperability is a very well understood problem in NodeJS vs bun vs deno vs gjs vs thingamabob (aka: any other runtime) but somehow nobody understands this argument in here ... this proposal would like to seal the deal around JS bindings and instantiation of classes, as it's a nightmare to explain, document, or even understand, everyone doing something slightly different out there to obtain the exact same result.
We don't need to explain much that if Python (or others) don't understand new Class
keyword, or it's reserved, the way to do the same is to use Class.new(...)
instead, and the code that could run in various interpreters with JS bindings in it, will keep working, as long as the code doesn't use/have specific interpreters gotchas in it ... but that's not on us, all we're trying to do is to ensure our users that they can swap runtimes when they feel like it's needed (MicroPython takes few ms to boostrap, Pyodide takes up to 2 seconds or more, if there are foreign packages to also fetch and orchestrate) ... so that as a user, I'd love to write code that works and when I need more from the interpreter just change such interpreter (we also allow Workers to bootstrap different interpreters for the same PL behind the scene, so ... there's that too!).
This is the background around this request, this is obvious to me daily, but I hope now that's written down in words becomes obvious to you too that Class.new(...)
already exists and it will keep existing, so it'd be great to consolidate that pattern or it's chaos out there, and TC39 is partially responsible for it if there's no action following this request.