Announcing Mixen: Multiple Inheritance in JavaScript
dev.hubspot.com
dev.hubspot.com
When you use this library, you're including a JavaScript file in your page (or requiring it in your Node project). It just so happens that in this case, the author(s) happened to use CoffeeScript to help them write that JavaScript.
Misleading title...
This is from an older SO post I made[0]: (The context is immediately invoked function expressions) IIFEs are often confusing to read and personally, I have no idea why they have become so mainstream. I think code should be easy to read and concise. Attempting to simulate language behavior that is not part of the language specification is often-times a very dumb idea.
For example, JavaScript does not support multiple inheritance, polymorphism, or many other interesting paradigms. So a lot of times, we see people trying to create these crazy ways of sorta'-kinda' having polymorphism or private members, etc in JS. I think this is a mistake.
[0]: http://stackoverflow.com/questions/12078812/how-to-choose-oo...
(function(){
//implementation methods and variables
return{
//public methods
};
})()
to be far easier to read than var myObject = {
//A random mix of public and implementation details
};
Though I will admit that my main reason for believing the above, is that when you work with developers who do not spent much time in JS, and they realize they have to write something complicated without private methods, they tend to write either monstrously long public methods as a result, or write as normal and litter the interface of the object, thereby completely breaking SOLID. The first method above avoids that problem.On the web, many developers are "forced" to write JavaScript when they don't really understand it (which is a massive pet peeve of mine, but that's a rant for another time). These developers tend to try and shoehorn design patterns from their language of choice into JS, or they just don't use any design patterns at all. Either way, it just doesn't work; the code just ends up being horrible.
At least libraries like this allow people to use design patterns that are more familiar to them, which should (hopefully) result in cleaner code.
Composition > class hierarchies