Apparently, ES2022 wants to add full-blown C++ class-type handling to JavaScript. This is total madness, trying to transform JS into some bastardized form of C++! I don't understand why this is even wanted, in the age of transpilers and WASM there's not even a need for someone who refuses to learn proper JS programming paradigms to not use C++ straight away anyway...
Just have a look at this kind of nonsense (of course already implemented in Chromium because... well you all know by now why):
Code: Select all
// public instanced class fields
class C {
x = 'x';
}
new C().x === 'x';
// Private instanced class fields and initializers
class C {
#x;
constructor(x){
this.#x = x;
}
x(){
return this.#x;
}
}
new C(42).x() === 42;
class C {
#x = 42;
x(){
return this.#x;
}
}
new C().x() === 42;
// Private static methods
class C {
static #x() { return 42; }
x() {
return C.#x();
}
}
new C().x() === 42;
I'm pretty much speechless at this point. If people want C++ SO BAD, make a new web scripting language like "Web-cpp" or something that does all that stuff and leave JavaScript alone.
I'd love to know what Brendan Eich would think about this.