MoonScript vs classic, middleclass and hump.class2017-11-20 14:14, 1 year and 10 months ago
Yesterday I did a little speed-test on MoonScript OO vs 30log. People liked it, they suggested I should do the same thing but with more popular OO libraries, so here I am, writing this post. My last comparison was a bit iffy though, I don’t really know 30log that much so I don’t know if they way I did it was the fastest, I also used a different loop for inserting objects into a table so maybe that had some slight effect. This time I’m going to try my best to limit the varibales down to simply creating objects, their methods and inheritance.
adn made this hypothesis. We’ll see if it’s true.
I’ll be doing a similar test as MS vs log30, testing object creation, methods, and inheritance. Graphs on the left are log-log scale, where-as the right is log-linear
We’ll create an object called
X, and insert it into table
We’ll add a method called
moveXtoY in class
X, that makes
self.y = self.x.
We create another class called
Y, that is a child of
X and create a bunch of them.
I think it’s pretty obvious that middleclass is the slowest one here, that’s mainly because it’s jam-packed full of extra features whilst the other stay minimal hence the overhead.
And the winner is…
No-one? In all honesty most of the lag starts to build up when you get past >1000-ish objects, there are only slight millisecond/microsecond differences between the top three libraries. I’d say looking from these graphs that classic and moonscript are a close tie, hump.class in second place and middleclass last, but at the end of the day it’s all just preference!
Here’s the link the the LaTeX graphs used in this post.