News for hackers. Stuff that matters.
Re:Future JavaScript: what is still missing? by megous on Sunday January 27, 2019 @06:54PM (#19014519)
I'm not saying classes are fake. There are no classes in the JS runtime. It's all just objects and some property sharing via a prototype chain.

You can implement anything in any general purpose language. But that doesn't mean the language has that concept.

Re:Future JavaScript: what is still missing? by Dylan16807 on Sunday January 27, 2019 @06:58PM (#19014539)
The language has the keyword and the implementation.

It's pretty normal for runtimes to not know about certain language concepts. The C runtime has never heard of switches or while loops, no big deal. If it's in the compiler it's part of the language.

Re:Future JavaScript: what is still missing? by megous on Monday January 28, 2019 @11:20AM (#19018651)
Objects don't have a class in JavaScript. It's that simple. You'll not change that with word games.
Re:Future JavaScript: what is still missing? by Dylan16807 on Monday January 28, 2019 @01:41PM (#19019901)
You're missing the forest for the trees. A fixed and reusable prototype, with a constructor, is a class. And when that's part of the language spec, that means the language has classes.

And it doesn't matter what typeof says. I could take a C++ program, replace every instance of the word 'class' with 'struct', and it would work fine. It would still be using classes, even though typeof says 'struct'.

Typeof in javascript calls the constructor a function and it calls objects objects. That's correct and fine. You can't put a class itself into a variable in C++ anyway.

And if you really want to get into the gritty details, it's possible to make a very similar argument that C++ of all languages doesn't have classes. Sure they exist in the source code, but all that pretty syntax gets thrown away and you end up with a naked object or one that just has a pointer to a struct it inherits from. And there's not even a 1:1 relationship between source-code 'classes' and those structs!

Re:Future JavaScript: what is still missing? by megous on Tuesday January 29, 2019 @12:37PM (#19028199)
> You're missing the forest for the trees. A fixed and reusable prototype, with a constructor, is a class. And when that's part of the language spec, that means the language has classes.

Yes, but prototype is not fixed. Prototype chain is not fixed (you can extend it at any point). All of that is changeable at runtime. You can also change the object's prototype at runtime.

It's all dynamic, and prototype ("class" as you say) doesn't provide any structure/constraints to the object. Thus it's pretty pointless to call it a class. It's just property sharing via a prototype chain. It's nothing like classes in languages like C++, Java, PHP, etc. And it doesn't help anyone understand the language, if you try to see it through that paradigm.