Ad
  • Custom User Avatar
  • Custom User Avatar

    JSClass is as old as 2007, and just because it exists doesn't mean it's a good idea at all.

    It tries to copy Ruby syntax, but ends up in a incomprehensible, poorly designed mess. Putting obvious early JS overriding nonsense aside (1 parameter call and 2 parameters call has very different meanings to the arguments on each position), Ruby doesn't use new Class at all, only Class.new is used to instiantiate a class; JSClass uses .initialize and new interchangably in schizophrenic ways. Like, why do we new the result as a function instead of .initialize which is clearly the constructor? Why is this function then fed in like an object? Two different things are being fed into the function and it can easily break in some edge cases.

    this.super is also superfluous: the only correct way of doing inheritance in JS is to use the prototypical chain (.prototype and .constructor), the language feature that has always existed. this.super is an ugly hack that is completely unneccessary, prone to breaking (what if I have a method named super too?), not to mention just plain wrong.

    My point is, the whole idea this kata is based on is horrendous, and turning a horrible idea into a kata is one of the worst things ever. There are lots of people in the JS ecosystem who develop ways to use JS incorrectly and attempt to make JS behave like other languages because they have a terrible understanding of programming languages, and they should not be perpetuated.