JavaScript Getters/Setters Considered Slow "considered harmful" is link bait
"Considered harmful" considered harmful?
JavaScript Getters/Setters Considered Harmful
11–14 of 14 posts
Re: JavaScript Getters/Setters Considered Harmful
#12JavaScript Getters/Setters Considered Slow "considered harmful" is link bait
"Considered harmful" considered harmful?
In Java accessors are almost mandatory if you intend for your object's properties to be publicly available (even the IDEs imply it, by automatically creating them for you). Whereas in languages such as Python and JavaScript, the implementation of this "pattern" makes them optional. You don't have to use accessors if you don't need them right now, since you can always go back and create them later without affecting client libraries.
What the article shows is that, surprisingly, JavaScript's native feature to do this is actually slower than the Java way (what the author called old-fashioned). Is this really a reason to revert to a clumsier pattern because we're optimizing for speed?
Saying that it's "harmful" might get many newbie JavaScript programmers run to start peppering their code with getter and setter Java-style. What happens later when the different scripting engines fix the bottleneck.
Re: JavaScript Getters/Setters Considered Harmful
#13JavaScript Getters/Setters Considered Slow "considered harmful" is link bait
"Considered harmful" considered harmful?