Skip to content

Comment on Stop Using Constructors in JS (2012)parent

Comments

It sounds like you're explicitly adding function properties to every object. This is slow and wasteful or memory. In Python, method lookup scans the __class__ of the object to find the method function. Python also automatically binds the object instance to the first (self) parameter.

What you're describing does not bear much resemblance to Python.

This is true, but I believe that in modern JS implementations, the performance difference isn't as large as one might expect.

The similarity to Python is limited to syntax — I just wanted to raise the point that in both Python and prototype-free JS, higherOrderFunction(object.method) does what it looks like it will do.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.