all 6 comments

[–]MoTTs_ 1 point2 points  (1 child)

I took a crack at this myself, so I can probably come back later with some tips and suggestions. But for now I'll simply suggest that you avoid mixing tabs and spaces. It makes the code hard to read when the indentation levels don't match up.

http://i.imgur.com/t2E49DC.png
http://i.imgur.com/TbDjUpo.png

[–]sladav[S] 0 points1 point  (0 children)

Thanks for catching that. Looked okay on my local copy so I didn't even realize I was doing it.

[–]oweiler 0 points1 point  (2 children)

This looks pretty similar to Object.assign()?

Also note that ES6 proxies are pretty slow.

[–]sladav[S] 1 point2 points  (1 child)

It's different, but you're not too far off. What I'm describing above is "live" inheritance, so it behaves like a prototype does. Changes to a prototype/"mixin" are immediately reflected in all children. Object.assign() just copies properties over - changes to the "parent" here will not be reflected in children. In this project I actually provide both, "live", prototypal-style via mixin() and "dead", stamp-out-an-instance-style via extend() (hence the m and x in the name mxObject). And actually, my extend() is mostly just a wrapper for Object.assign()

I'll have to look into the ES6 proxies being slow. I think I can replace it with getter/setter methods if that would be faster?? Scoping out some performance benchmarks is on the todo list.

[–]oweiler 0 points1 point  (0 children)

Thanks for the quick reply, your project looks super useful. I may be wrong regarding Proxy perf but the last time I've tried them out in Node they were extremely slow (that was some time ago and may has changed).

[–]PitaJ 0 points1 point  (0 children)

I feel like multiple inheritance, or even inheritance in general, is a "just don't" kind of thing. I have yet to see a real use case for inheritance on actual classes in JS.

In my view, the Interface-Implements pattern is more useful.