mop4js v0.0.11
mop4js
A toy project motivated by implementing MOP (Meta Object Protocol) for Javascript ES6.
A "learn by doing" prototype of MOP for Javascript. This project follows my quest of an Interface class for Javascript (see mixin-interface-api).
I now think that using mixins is more a workaround than a "nice piece of cOOPcake". Recently, I remembered the Meta Object Protocol and sought if it was applied / applicable to Javascript. I found JOOSE and JOOP, there is also a reference MOP for PERL: MOOSE.
Regarding MOP (Meta Object Protocol), this paradigm is there for a while, since 1991 at least in the "The Art of the Metaobject Protocol" book which describes CLOS, a MOP for LISP (CLOS is the acronym of Common Lisp Object System).
My intent in this toy project is two-fold:
- First: "Give it a try" and share a naive implementation.
- Second: promote the usage and knowledge of MOP among Javascript developers.
Release 0.0.10 changelog
- Documentation update.
Release 0.0.9 changelog
- First Prototype ("Proof of concept") at a very early stage (the implementation is clumsy ATM).
Please find below a code sample:
const $$MetaClass = require('./src/mop4js.js').$$MetaClass;
var $$Interface = new $$MetaClass({ 'name': "$$Interface" }); // MetaClass Factory
console.log($$Interface + "\n");
var $ILogger = new $$Interface({ 'name': "$ILogger"}); // Class Factory
console.log($ILogger + "\n");
var logger = new $ILogger(); // Object instantiation and numbering
console.log(logger + "\n");
References
- The Art of the Metaobject Protocol
https://en.wikipedia.org/wiki/The_Art_of_the_Metaobject_Protocol - GOOPS Manual: Metaobjects and the Metaobject Protocol
https://www.gnu.org/software/guile/docs/goops/Metaobjects-and-the-Metaobject-Protocol.html - JOOSE
https://www.npmjs.com/package/joose - MOOSE
https://metacpan.org/pod/distribution/Moose/lib/Moose/Manual.pod - What's wrong with extending the DOM
http://perfectionkills.com/whats-wrong-with-extending-the-dom/