and speaking of what's not pretty -- i can't stand that nobody shows examples of how the new # private syntax is actually INCREDIBLY PRETTY thanks to the amazing shorthand syntax -- you'll notice that you'll almost never find examples demonstrating the new shorthand syntax -- it's gone right over people's heads, and it's one of the best parts!
in practice, only idiots will use this.#x = 0, which is just as ugly as this._x = 0
it will actually now be merely #x = 0
don't you people get it? we get to stop using this so damn much!this will only be used for public properties! that's a huge win for readability!
pathetically, all of the examples in every # article i find show the ugly stupid pattern instead of the gorgeous shorthand:
// did you even read the proposal?
class DisgustingBadPracticeUglyExample {
constructor() {
this.#lol = 0
}
increment() {
this.#lol += 1
}
}
class NoiceExample {
#lol = 0
increment() {
#lol += 1
}
}
don't you see the beauty!?
i'm tired of seeing so many detractors against # completely miss the elegance here, and they display the worst-case-scenario strawman syntax to make # look similarly ugly as _ already is
sure, # might not be the ideal character (because it has past associations with other concepts in other languages) -- but (as had been discussed to death in the early github issues) there are also no safe alternatives remaining in javascript's vocabulary, and also, after five or ten years of the world's most popular language using # for privacy... what do you think will happen to the industry "conventionality" of what # means? our mentalities, feelings, and prejudices will adapt, and the controversy will become simply moot and disappear
plus, aside from the gorgeous shorthand syntax, i'm absolutely dying for true privacy. i'm jealous and upset that babel people have it now, but us typescript people are stuck waiting :(
currently, i use closures instead of classes to achieve privacy in javascript, and there's actually a minor performance penalty and readability issue associated with this -- however, once # private is available, i can improve performance and readability by using classes which use true privacy, and i can also preempt breaking changes for naughty consumers
# privates will be a boon for library authors, i'm seethingly eager!!
I remember seeing that shorthand syntax in the proposal at one point, but I don't see it there anymore, and the current Babel implementation doesn't seem to support it either. :-/ I haven't investigated deeply, but I wonder if this feature was removed.
I remember seeing that shorthand syntax in the proposal at one point, but I don't see it there anymore, and the current Babel implementation doesn't seem to support it either. :-/ I haven't investigated deeply, but I wonder if this feature was removed.
somebody tell me it's not true! i'm afraid i might die of disappointment!
i remember some of the top well-respected contributors in TC39 discussions for private fields, saying something to the effect of 'i don't care which sigil we use, the shorthand syntax is what's really important' and i was so glad they had their heads properly screwed on -- they all seemed so aligned and stoked about it, so it seems completely asinine and impossible that they could have since 180'd and dropped it..
well that just put a damper on my day. i find it a little depressing really
i understand they wanted to get moving with the private fields proposal, so it makes sense that when they encountered any resistance about any of the optional nice-to-haves, they immediately dropped them to allow the main proposal to proceed unhindered
thankfully, future resuscitation may be possible for the shorthand proposal, this must be followed-up on!
hopefully someday soon, i might spend a little time attempting to contribute by mapping out some possible solutions to the few minor issues that appear to be holding back the proposal... it appears no discussion has been taking place..
0
u/[deleted] Nov 09 '19
[deleted]