5 ms·
Chrome 72 Beta: Public class fields, user activation and more
- josteink 8y ago> Public class fields As a TypeScript-user, I hadn't really realized this wasn't just plain, regular Ecmascript yet and thus assumed it had to be something else. So I had to read the blog-post to see what it was, and find out that I no longer know regular Javascript ;)
- mattferderer 8y agoI'm having to write JavaScript (ES5) without TypeScript right now & using jQuery. Whew... The folks who did ES6 upgrade & TypeScript improvements can't be thanked enough.
- Waterluvian 8y agoES6 is really the main thing that made me stop hating web dev. A long way to go but that was a watershed moment.
- ordinaryperson 8y agoClasses don't really exist in JS. They're (mostly) syntactic sugar for OOP programmers. e.g. https://stackoverflow.com/questions/36419713/are-es6-classes-just-syntactic-sugar-for-the-prototypal-pattern-in-javascript https://stackoverflow.com/questions/36419713/are-es6-classes...
- jchw 8y agoBy this logic what differentiates JS classes versus, say, C++ classes? C++ classes compile down to almost nothing. Non-virtual calls are static dispatch, virtual calls are just an indirection into a vtable. I suppose the main difference is that in JS the implementation semantics of classes are defined and can be prodded at. Is that really so different though? I think it's just a bit strong to say ES classes "don't exist" because the methods by which they operate can be observed at a lower level.
- zamalek 8y ago> virtual calls are just an indirection into a vtable. Exactly, and `.prototype` is just a runtime and programmable vtable. You copy (by reference) everything from the base prototype and replace (override) every member that you need to. You can even call overridden methods with `BaseType.prototype.foo.call(this, ...)`.
- JeremyBanks 8y agoThe prototype concept is little more than an annoying implementation detail for vendors to worry about. No use of it other than the `class` pattern ever saw any adoption. It causes more confusion every day than it provided distinct value in the last decade. With any luck we'll have so completely abstracted over it by ES12 that it won't even need to be mentioned in the spec.
- vbezhenar 8y agoFor me they definitely exist in JS. Prototypes are just an implementation detail.
- manigandham 8y agoUnfortunately the coming private fields spec is far more messy and will result in typescript having different compile-time and run-time private fields syntaxes.
- jdlyga 8y agoNothing to see here.
- MrStonedOne 8y agoThe User activation properties should have been added when they first started restricting apis to user initiated actions. I said such in the mailing list for the framebusting change to require activation.
- jordanthoms 8y agoYeah, there's a bunch of nasty code we have which is essentially trying to predict if the window.open call will be blocked (in which case we have to get them to click a button instead to open the window). Once that API has enough adoption we'll be able to remove that which is nice.
- deleted 8y ago[deleted]
- wakeywakeywakey 8y agoThere is a lengthy debate surrounding private field syntax [1][2]. As a TypeScript user, I prefer regular-JS drop this proposal altogether, rather than use the current syntax. Refactoring and index-access notation become awkward with it. Anecdotally, the vast majority of serious developers I know transpile to JS. [1]: https://github.com/tc39/proposal-class-fields/issues/177 [2]: https://github.com/tc39/proposal-class-fields/blob/master/PRIVATE_SYNTAX_FAQ.md
- aasasd 8y agoI'm pretty sure transpilation is supposed to gradually adopt something more modern than es5.
- wakeywakeywakey 8y agoI agree overall, but some language/env enhancements (e.g. BigInt) transpile more naturally than syntax-dependent ones like #private.
- jkrems 8y agoThe discussion seems to be mostly driven by people who are used to a very specific syntax and can't understand why it wouldn't work for a real implementation for private. Nothing will stop these people from keeping their use of "private as documentation only" while others will get their proper implementation of private state that isn't as fragile as the one offered by TypeScript. That last part isn't a dig at TypeScript - it's just that at the time it was the best TS could possibly offer. I expect that TypeScript will adopt this proposal given that some of the people working on and defending the proposal seem to be part of the TypeScript team. > Refactoring and index-access notation become awkward with it. Given that other languages have similar solutions and this actually has more information in the source file, I assume that refactoring will become quicker and index-access will just move to private maps. Adding arbitrary fields at runtime and dynamic access to private fields are both tools with limited value compared to the potential for introducing subtle bugs.
- TACIXAT 8y ago>Anecdotally, the vast majority of serious developers I know transpile to JS. TIL I'm not a serious developer. I actually think compiling Javascript is a huge barrier to entry to would be devs. I think a development experience of put the code on the page and it runs is a lot better than configuring npm/gulp/grunt.
- lwansbrough 8y agoNo public signals from any other browser vendors? No thanks. Miss me with that monoculture bullshit.
- jjcm 8y agoThe only one that has major implementation changes is the Public Class Fields proposal, which has positive public signals from other browsers: Proposal - https://github.com/tc39/proposal-class-fields https://github.com/tc39/proposal-class-fields Firefox Implementation Tracker - https://bugzilla.mozilla.org/show_bug.cgi?id=1499448 https://bugzilla.mozilla.org/show_bug.cgi?id=1499448 Safari Implementation Tracker - https://bugs.webkit.org/show_bug.cgi?id=174212 https://bugs.webkit.org/show_bug.cgi?id=174212 The others are largely security updates which honestly I'm fine with browsers pushing ahead with. The User activation query API stuff is great and is gonna solve a lot of headaches around misbehaving sites. Safari already has a rudimentary implementation around this with autoplay as well, so this is an effort to standardise some existing "monoculture bullshit". As far as depreciating TLS 1 and 1.1, I don't think there's anyone out there arguing that that isn't a good idea.
- seanwilson 8y agoCan someone explain what a user activation is? I couldn't work it out from the article or the naming.
- aravindet 8y agoIIUC many APIs (e.g. requestFullscreen()) are only callable from JS during a short window of time following a user interaction. The userActivation property allows programs to check whether those APIs are callable, rather than calling them blindly and catching errors.
- aravindet 8y agoIs there any standard for the user activation APIs? Changing the signature for postMessage seems like a particularly aggressive change.