4 ms·
> 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 els
by 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.