3 ms·
Well, if TC39 weren’t a bunch of kids running with scissors, you probably wouldn’t have this problem, would you? You wouldn’t have to have to bolt on .meta ont
by dmitriid 8y ago
Well, if TC39 weren’t a bunch of kids running with scissors, you probably wouldn’t have this problem, would you?
You wouldn’t have to have to bolt on .meta onto import after the fact. You wouldn’t have to create horrible polyfills for the horribly named globalthis. And so on and so on and so on.
Hint: just spend actual time actually designing the language.
Hint: Introduce System namespace/module with System.globals. There. Solved. Trivially polyfilled. The BS about “we can’t easily introduce new global objects/modules” is BS after WeakMaps and SharedBuffers and god knows what else.
- realityking 8y agoHow would System.globals be any easier to polyfill? The problem described in this article is how to reliable get access to the global object (or bow globalThis) in currently shopping JS environments in the first place.
- dmitriid 8y agoAh, true. I re-read the article. You’d need the horrible polyfill anyway. So, my other point still stands: instead of any long-term planning and robust design, TC39 keeps introducing features that are badly specified are underspecified, and that require patches and workarounds in the language itself (yup, .meta, globalThis and some others are nothing but poorly thought-out patches) and conplex workarounds for the various JS environments that may or may not support these features.
- thrower123 8y agoIf Javascript needs anything, it is a breaking change to go back and clean out all the cruft that has accumulated over two decades of being bent and banged and globbed onto. I don't think that that can actually happen, so we just keep trying to cake more lipstick on the pig; maybe in five years we can put it out to pasture and use WebAssembly instead.
- colejohnson66 8y agoAren’t arrow functions and “use strict” attempts to fix common gotchas?
- codedokode 8y agoAccess to global object was intentionally restricted in strict mode and modules and now you (JS devs) want it back. That's not what rational people do.
- realityking 8y agoAccess to the global object is not at all restricted in strict mode. The changes in strict mode related to the global object are: - can’t define implicit global variables (you need to be explicit) - “this” doesn’t refer to the global object The problem is that different host environment have different names for the global object. That’s what make it hard to write code that works independent of the host environment and that’s what globalThis is aiming to fix.