Using classes and JS performances ?

Julien Bayle's icon

Hi there,
are there some advices to use or not use classes in js executed in jsui ?
I'm building a small gui for myUniverse project with jsui/mgraphics and it would be useful to define some classes like vec3f, things like that.

Darwin Grosse's icon

Well, I've never avoided classes - in fact, I love 'em. As long as you aren't too kooky about the number of instances you create, you should be in good shape. Since internal to Javascript the classes are just variations on function pointers, you shouldn't see a real hit to performance (this is just based on experience, not any specific knowledge of the turning gears in the system...).

[ddg]

Julien Bayle's icon

Hi Darwin and thanks for your answer.
AFAIK, the JIT compiler processes the javascript and indeed it is VERY fast.

Your informations are precious.
I'm building the GUI of myUniverse system :)
Initially wanted to keep that outside of max and linked via OSC, but finally, integrating it right now inside Max!

Lee's icon

i'm using lots of classes in JS and no problems at all.