Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upPlease use a name without `this` in it #31
Comments
This comment has been minimized.
This comment has been minimized.
joelnet
commented
Nov 29, 2018
•
|
I'm already using I'm gonna vote against |
This comment has been minimized.
This comment has been minimized.
getify
commented
Nov 29, 2018
|
I am 100% in support of @rauschma here. Please, please reconsider. |
This comment has been minimized.
This comment has been minimized.
mchandleraz
commented
Nov 29, 2018
|
Also in complete agreement with @rauschma et al. |
This comment has been minimized.
This comment has been minimized.
KoryNunn
commented
Nov 29, 2018
•
|
browserify also maps Using EDIT: Just noticed this:
And I have to say, as much as I get the "don't break things" attitude, the future is slightly more important than the past. |
This comment has been minimized.
This comment has been minimized.
|
Is there another name we could have proposed to investigate that doesn't cause enough breakage to be seen as a web compat problem? Several have been investigated already including |
This comment has been minimized.
This comment has been minimized.
rauschma
commented
Nov 29, 2018
|
@bmeck I appreciate how difficult it is to pick a name and how important it is not to break anything! I’m fine with literally anything that doesn’t have the word |
This comment has been minimized.
This comment has been minimized.
smolinari
commented
Nov 29, 2018
•
|
Scott |
This comment has been minimized.
This comment has been minimized.
|
We should avoid jests if we can here. It takes a huge amount of time to check any given thing and generally means some browser needs to actually roll it out if it seems safe enough, see what breaks and then roll it back. |
This comment has been minimized.
This comment has been minimized.
feross
commented
Nov 29, 2018
|
Has |
This comment has been minimized.
This comment has been minimized.
smolinari
commented
Nov 29, 2018
|
@bmeck - Maybe some humor might make the language even more fun? |
This comment has been minimized.
This comment has been minimized.
|
This is the option we decided to go with. The only better name imo is global, and breaking the web is unacceptable (the future of the web depends on not breaking the web). globalThis is the global this value, which applies to sloppy mode Scripts, the Function constructor even in modules, and the upcoming Realms API - it’s not the global object, and being correct (not merely pedantic) is important. |
This comment has been minimized.
This comment has been minimized.
rauschma
commented
Nov 29, 2018
This comment has been minimized.
This comment has been minimized.
rauschma
commented
Nov 29, 2018
|
@ljharb I completely understand how tricky all of this is and how important not breaking the web is! I wouldn’t be as emotionally invested if I didn’t see almost daily people who are confused about |
This comment has been minimized.
This comment has been minimized.
kleinfreund
commented
Nov 29, 2018
|
From the readme's rationale (emphasis mine):
That sounds like that's the main goal here. |
This comment has been minimized.
This comment has been minimized.
|
@kleinfreund that's a very good point - that sentence does imply that the name should have something to do with "global object". I'll try to update it to make that more clear. I understand it’s confusing, but that’s what this proposal is for - the global this value. The global object is not actually directly accessible, and altho most community members (myself included) colloquially refer to it as the global object, browser representatives on TC39 flatly refused to allow it to proceed unless it explicitly did not imply that it was the global object. |
This comment has been minimized.
This comment has been minimized.
rauschma
commented
Nov 29, 2018
|
@ljharb Hmm. What is their name for what the global |
This comment has been minimized.
This comment has been minimized.
|
The same as in the spec, and in this proposal - the “global this value”. Browsers have the concept of the “WindowProxy” (mentioned in the readme) that encapsulates access to the actual global object - i believe for security reasons dealing with iframes and cross-window access. |
This comment has been minimized.
This comment has been minimized.
rauschma
commented
Nov 29, 2018
|
OK, I see and accept the constraints. I’m still unhappy, because my hope (enabled by ES6!) had been that we’d be able to eventually (mostly) forget about |
This comment has been minimized.
This comment has been minimized.
|
I'm on your team here :-) I'd be delighted if the warts of the language, including sloppy mode semantics, would eventually be able to fully disappear - I think things would be much clearer for everyone, new and experienced users alike. Unfortunately, I suspect that won't be the case :-/ Thank you for the feedback - I’m not happy about the result either, but web compat has left no other palatable practical options. |
This comment has been minimized.
This comment has been minimized.
KoryNunn
commented
Nov 29, 2018
|
I would advocate doing nothing over
|
This comment has been minimized.
This comment has been minimized.
|
Doing nothing would be worse - we desperately need a non-eval way to access the global this value, especially with CSP as a thing that exists. If you’re content with “nothing”, I’m not sure why this identifier that you can choose not to use will matter to you - if you’ll use it, by don’t like the name, then “nothing” certainly shouldn’t be preferable. |
This comment has been minimized.
This comment has been minimized.
KoryNunn
commented
Nov 29, 2018
|
Probably getting a bit off-topic, but why would I not advocate against something that I believe would be worse than nothing?
|
This comment has been minimized.
This comment has been minimized.
rauschma
commented
Nov 29, 2018
|
@KoryNunn Jordan just explained the constraints against |
This comment has been minimized.
This comment has been minimized.
rauschma
commented
Nov 29, 2018
This comment has been minimized.
This comment has been minimized.
smolinari
commented
Nov 29, 2018
|
And what about Scott |
This comment has been minimized.
This comment has been minimized.
rauschma
commented
Nov 29, 2018
|
@ljharb Got it. To clarify: Given that it’s called “global |
This comment has been minimized.
This comment has been minimized.
|
@smolinari it's not actually a scope (global const/lets, for example, are not properties on the global this value), and there isn't any reified "scope" concept in the spec (by design). |
This comment has been minimized.
This comment has been minimized.
getify
commented
Nov 29, 2018
|
By "global this value", are we meaning "the thing 'this' will point to in a non-strict function that has a 'this' reference"? If so, I'd suggest that perspective on that value, used to name it, is far less relevant (and becoming less so as time goes on) compared to "the object that holds properties of all my global variables". IME the latter is far more common in terms of mentally describing what that thing is, and why we want to access it. The former is literally something most of us teach and advocate as "you should never access that if you can avoid it." I've said countless times in my courses, "if you're trying to access 'this' and it's the global object, that's usually a mistake, and that's why strict mode took that away." So "globalThis" may be pedantically correct but it's not even remotely the common name we should be propagating for it. As usual, @ljharb, the tone of "it's already been decided, get over it" is not helpful. You didn't consult enough of us teachers likrle @rauschma and myself to realize that TC39's perspectives here are skewed from the direction we should be going. I know that's upsetting to hear, but every time you ignore this perspective you can expect (and I assume, ultimately ignore) my pushback. For the sake of bikeshedding, I would have preferred "globalContext" or "globalScope" or even "globalSelf" infinitely more than "globalThis". Those names all point to the identity and purpose of that object that more closely aligns with how devs interact with it, and also what many of us teachers are trying to steers devs towards. |
This comment has been minimized.
This comment has been minimized.
|
I don't think I've offered a tone or wording of "it's been decided, get over it" here, and I don't think that's being particularly charitable. Also, I don't think it's fair to assume that nobody on TC39 is a teacher - I consider myself a teacher of JavaScript, too, in some ways. (regarding bikeshedding, "globalScope", as I've explained above, would be a very confusing name - a scope is not a noun in javascript. "globalContext" is interesting, but "context" isn't a commonly used term, so I'd find that confusing as well, and "globalSelf" would imply it's different than "non-global |
This comment has been minimized.
This comment has been minimized.
suchipi
commented
Nov 29, 2018
|
I think |
This comment has been minimized.
This comment has been minimized.
|
Given that some browsers would refuse to implement it under that name, what else would you suggest? |
This comment has been minimized.
This comment has been minimized.
suchipi
commented
Nov 29, 2018
|
Under the name |
This comment has been minimized.
This comment has been minimized.
ianstormtaylor
commented
Nov 29, 2018
This comment has been minimized.
This comment has been minimized.
|
@suchipi they refused it specifically because it's not actually the global object, and they did care about the WindowProxy duality. |
This comment has been minimized.
This comment has been minimized.
suchipi
commented
Nov 29, 2018
|
Well, I think that is an example of elitist pedantry getting in the way of the needs of the average user. What about |
This comment has been minimized.
This comment has been minimized.
|
As I commented on #32, it was in my original list of possibilities, but the general reaction I got was that it's not a constructor and not quite the same as a namespace like Math, JSON, Reflect, etc. At some point, I had to create a minimal list of 3-5 possibilities in order to gather web compat data, and I had to make a judgement call to prune the longer list down to that, and it didn't include Global. |
This comment has been minimized.
This comment has been minimized.
suchipi
commented
Nov 29, 2018
|
Sorry for the duplication, I'll move to #32 |
This comment has been minimized.
This comment has been minimized.
pleerock
commented
Nov 29, 2018
|
If |
This comment has been minimized.
This comment has been minimized.
|
@pleerock it’s already been suggested, and it’s one of the ones i collected data on - it’s not an option, because of web compatibility. |
This comment has been minimized.
This comment has been minimized.
AshleyScirra
commented
Nov 29, 2018
•
|
I agree
whereas normally I'd expect the reverse (the terminology to be determined for the language then written in to the spec). I appreciate this has moved far along enough to shipping to be difficult to change - especially since this looks to ship in Chrome stable in 5 days... maybe that should be postponed for a little more thought? I can see how this will quickly turn in to an epic new episode of bikeshedding, but I can't resist throwing in In fact the term "the global reference" is natural enough that it was mentioned in #32, apparently in passing, without being directly suggested (emphasis added):
So it seems to be a relatively natural term that doesn't use "this" and doesn't call it a global "object", "scope", "context" or anything else that might be misleading, since like all object variables it is indeed a reference. As for web compatibility though, I don't know - I can only say anecdotally I've not seen it used. |
This comment has been minimized.
This comment has been minimized.
fkling
commented
Nov 29, 2018
|
I haven't been following this proposal TBH, so I might be missing something, but this confuses me:
Is it not the purpose of this proposal to be able to access the global object? I assume what you are referring is the following (from
ATM there don't seem to be any requirements imposed by the spec onto the relationship between the global this and the global object. Is this going to change? Because if an implementation decides to use different values for Another thing I want to point, even though I know that non-normative sections are not .... well ... normative, the fact that the spec contains the following statement probably isn't helping the discussion:
https://www.ecma-international.org/ecma-262/9.0/#sec-global-environment-records |
This comment has been minimized.
This comment has been minimized.
|
@fkling due to browser concerns all global property access should go through WindowProxy not the Realm's global object which is the Window, see tc39/ecma262#1200 for an example of this being brought up. |
This comment has been minimized.
This comment has been minimized.
fkling
commented
Nov 29, 2018
|
@bmeck, I think I understand that. Global However, afaik, the spec currently does not require property access to be forwarded from the global Or am I missing something? |
This comment has been minimized.
This comment has been minimized.
|
@fkling global variables are different from global properties since they are not on the global this nor the global object actually and this is where we get more into the weeds. This proposal is about exposing the intended view of the global namespace of properties not variable inspection. I'll leave this as an example of how to see the difference in global variables vs properties: $ node
> let a = 1
undefined
> a
1
> global.a
undefinedWhen we talk about non-browser environments, there are none that I know of that differentiate the global object and the global this value such that they are different. |
This comment has been minimized.
This comment has been minimized.
fkling
commented
Nov 29, 2018
•
|
@bmeck I guess I was referring to "global properties" then.
So this proposal assumes that
even though neither is enforced in the spec? If that's the case it should at least be pointed out or it should be made clear that there are plans to amend the spec. Either way, it seems that the argument for using the name |
This comment has been minimized.
This comment has been minimized.
STRML
commented
Nov 29, 2018
•
|
Naming is hard. I would just like to voice my support for something other than I understand how it got this way but I strongly believe new language proposals should feel like they are making the language more approachable rather than less. JS got to its massive level of acceptance in large part because it was a small, approachable language. It's obvious that the community is resisting this change. As it is not yet shipped in mainline versions nor accepted into the spec it is a perfect time to demonstrate that this body embraces the community, rather than proceeding on without them. The cost of going back to the drawing board is minimal. The cost of alienating the community is high. @ljharb: I think this is a good opportunity for you and TC39 to consider how community feedback is solicited and handled. In particular, these comments are contradictory and make us feel shut-out:
Given the upcoming Realms API and especially https://github.com/tc39/proposal-realms#example-simple-realm, why not |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
selipso
commented
Nov 29, 2018
•
|
I've been programming in JS for 5 years and started using JS frameworks in year 2 because of this, global, and window. It's already too late to solve those problems at the language-level but frameworks abstract it away really well and I've never looked back at unscoped this and global except for the occasional polyfill that needed a tie-in between global and window. With all due respect, I think the energy-to-impact ratio of this discussion is already too high. The web, to me, as an intermediate developer and JavaScript tutor, has always stood for interoperability and cross-device compatibility. Any name that accomplishes those goals with agreement from browsers and maybe saves a few lines of polyfill code, I would be fine with. Unlike when JavaScript first appeared, the web now has another competitor: native code. The more we as a community can focus on issues related to interoperability and cross-device compatibility, the more we can move towards allowing JavaScript to be used with richer APIs that resemble modern native functionality. On a lighter note, since naming is hard and it's a variable that isn't supposed to be accessed anyways, why not make that obvious to a beginning programmer? My favorite so far has been |
This comment has been minimized.
This comment has been minimized.
felipenmoura
commented
Nov 30, 2018
•
|
IMHO, if I understand it right, this const foo = 123; // this will NOT appear in globalThis
globalThis.foo = 123; // this one, willIs this the goal for it?
The Or am I not understand its objective correctly? |
This comment has been minimized.
This comment has been minimized.
TeoTN
commented
Nov 30, 2018
|
I'd say... are you insane? Have you seen this kind of rubbish naming being praised in any other programming languages? |
This comment has been minimized.
This comment has been minimized.
AshleyScirra
commented
Nov 30, 2018
|
@TeoTN - I think your attitude is unacceptable. This discussion should not involve calling people "insane". I would point out the TC39 code of conduct which emphasises being respectful, friendly, patient and considerate, and identifies personal insults as a potential harassment and exclusionary behavior. |
This comment has been minimized.
This comment has been minimized.
pladaria
commented
Nov 30, 2018
|
Can |
This comment has been minimized.
This comment has been minimized.
TeoTN
commented
Nov 30, 2018
•
|
@AshleyScirra it doesn't address any of concerns presented neither by me nor by anyone else here. It wasn't also directed to anyone just drawing attention. I'd say though it's against code of conduct that multiple people voices here are simply ignored, voices that are coming from quite significant personas for the JS community for the sake of "we have already written that in this way so deal with it". |
This comment has been minimized.
This comment has been minimized.
|
Thanks for everyone's input here. We (representing @tc39/code-of-conduct-committee) are going to lock this issue as it is no longer productive. For more context on why a long list of potential names didn't work, check out #32. @TeoTN: As mentioned by @AshleyScirra, the comment you made above is in violation of the TC39 Code of Conduct. Whether used as a direct attack or for the purpose of gaining attention, the language used was highly aggressive, with no intention to be productive. This form of communication is unacceptable. |
gesa
closed this
Nov 30, 2018
tc39
locked as too heated and limited conversation to collaborators
Nov 30, 2018
This comment has been minimized.
This comment has been minimized.
|
First, I want to thank all of you that have taken the time to provide your thoughts - @rauschma, @joelnet, @getify, @mchandleraz, @KoryNunn, @smolinari, @feross, @kleinfreund, @ianstormtaylor, @suchipi, @pleerock, @AshleyScirra, @fkling, @STRML, @j-f1, @selipso, @felipenmoura, @TeoTN, @pladaria, and many others. I really appreciate your feedback, and I know that you're all coming from a place of caring about the JS language. I've tried to take some time away from this thread to collect my thoughts, and I want to reiterate that I appreciate any and all feedback. My tone has at times come off as dismissive and overly harsh, and I apologize for that. Sometimes I respond when tired, or stressed, or when emotional, and I'll try to get better at taking a pause so that I can respond calmly, respectfully, and with an open mind. We humans on TC39 take community feedback very seriously - and at the November meeting, we had an emergency break from our agenda to take the time to address this proposal's recent feedback. I asked another committee member (who was concerned about ensuring we listen to the community, and particularly prominent educators) to conduct the discussion, so as to ensure that any of my personal bias was minimized. The first browser that will be shipping this proposal, Chrome, shipped recently (after the meeting). The Chrome team assured the committee that they would have no problem removing the feature if the committee decided to make a change, but that pulling it at such a late hour would be a hardship. The purpose of stage 3 proposals is to gather feedback - from both users and implementations - and this thread’s feedback is part of that. I do want to collect all the name suggestions in one place, and others have asked for this as well. I’ve started by detailing the suggestions and some of the constraints here. Please feel free to file new issues if you have additional names to suggest, or if you think the document can be clarified. No decision will please everyone, but I truly hope that detailing the constraints (something I clearly failed to do much earlier in the lifecycle of this proposal) will help you understand the decision-making space available, and that we can all move forward with everyone on the same page. I would like to see our community go in a direction that is positive, where people’s opinions are respected and their voices are heard. While there were personal attacks against myself, there was also a lot of hostility in general, and that hostility makes it more difficult to achieve that positive outcome. We’ve been working hard at TC39 to improve our communication and have developed a Code of Conduct that we will hold ourselves to, and would like to ask our community members to do the same. |
rauschma commentedNov 29, 2018
•
edited
I know it’s late, but please reconsider the name
globalThis:thishas always been a topic that mystifies programmers, especially those who are new to JavaScript. There is a constant stream of blog posts about it.thisinside method definitions.globalThisdoesn’t even refer to an existing concept.The name
globalThiswould makethismore complicated again.One possibility (but I’m OK with anything that doesn’t have
thisin it):globalObject– that’s what it’s always been called.global*is not really the global object, but I don’t find it helpful to be pedantic in this case.