3 ms·
I don't understand what the issue with explicitness is. Python uses self and people seem to be pretty OK with that.
by axiak 16y ago
I don't understand what the issue with explicitness is. Python uses self and people seem to be pretty OK with that.
- silentbicycle 16y agoIt's really not a big deal. Just a bit cumbersome. Lua has syntactic sugar where table:method(arg1, arg2, ...) is exactly equivalent to table.method(table, arg1, arg2, ...). All it really does is establish a convention and eliminate "self" from argument listings in methods, but it's still handy - its presence is an immediate sign of OO-style code.
- kls 16y agoRight, I in fact like using the "this" reference, I use it in Java and C# as well when accessing any member variable. For me, it helps the way my mind thinks, I instantly know hey, this thing is not local, be careful. The bigger issue to me is that functions can be passed independent of class in JavaScript, so you have to have some way of making sure the object tags along for the ride. There are various implementations to do this such as Dojo's dojo.hitch(this, "foo"); which, is not that bad given that you can hand stuff off for callbacks, it is a pretty good trade off. It just takes some getting used to, but the JavaScript is a poorly designed language is a tired meme. I have used it from the day it was released and never saw what all the fuss was about. There are some design decision I would not have made, like no matter where you scope a variable in a routine it is visible to the entirety of that routine. But none of it is so offensive as to earn it the reputation it has had. Further subsequent standards also went a long way to improve on many of the early shortcomings as well.