8b99cb7f70
Now that ease.js is a GNU project, it has much broader reach than before. Since its very existence is controversial, it would be wise (and polite) to provide a means for others to integrate with libraries written using ease.js without being forced to use ease.js themselves. Further, ease.js users should be able to build off of the work of other libraries that do not use ease.js. This set of changes introduces a number of interoperability improvements, documented in the new manual chapter ``Interoperability''. Since it is documented in the manual, this commit message will not go into great detail; I wish to only provide a summary. Firstly, we now have the concept of interface compatibility; while ease.js classes/etc must still conform to the existing interface requirements, the rules are a bit more lax for other ECMAScript objects to permit interoperability with type-checking ease.js code. For example: var I = Interface( { foo: [ 'a' ] } ), obj = { foo: function( a ) {} }; Class.isA( I, obj ); // true This is also a powerful feature for implementing interfaces around existing objects, as a preemptive interface check (rather than duck typing). Prototypally extending ease.js classes is potentially problematic because the constructor may perform argument validations (this is also an issue in pure prototypal code). As a solution, all classes now have a static `asPrototype` method, which defers constructor invocation, trusting that the prototype constructor will do so itself. Aside from a few bug fixes, there is also a more concise notation for private members to allow prototypal developers to feel more at home when using GNU ease.js: members prefixed with an underscore are now implicitly private, which will satisfy the most common visibility use cases. I do recognize that some (mostly in the Java community) use underscore *suffixes* to denote private members, but I've noticed that this is relatively rare in the JS community; I have therefore not included such a check, but will consider it if many users request it. There are many more ideas to come, but I hope that this will help to bridge the gap between the prototypal and classical camps, allowing them to cooperate with as little friction as possible. |
||
---|---|---|
doc | ||
lib | ||
test | ||
tools | ||
.gitignore | ||
.mailmap | ||
COPYING | ||
Makefile.am | ||
README | ||
README.hacking | ||
README.md | ||
README.todo | ||
README.traits | ||
configure.ac | ||
index.js | ||
package.json.in |
README.md
GNU ease.js
GNU ease.js is a classical object-oriented framework for Javascript, intended to eliminate boilerplate code and "ease" the transition into JavaScript from other object-oriented languages.
Current support includes:
- Simple and intuitive class definitions
- Classical inheritance
- Abstract classes and methods
- Interfaces
- Traits as mixins
- Visibility (public, protected, and private members)
- Static and constant members
Documentation
Comprehensive documentation and examples are available on the GNU ease.js website and in its manual.
Bug Reports / Feature Requests
Please direct bug reports and feature requests to bug-easejs@gnu.org or the project page on Savannah.
Why Classical OOP in JavaScript?
GNU ease.js was created (historically) for a number of reasons:
- To "ease" object-oriented developers into JavaScript by providing a familiar environment.
- To provide the maintenance and development benefits of classical OOP.
- To provide features not included in the language, such as proper encapsulation through private/protected members, interfaces, traits, intuitive inheritance, and other conveniences.
- To encapsulate the hacks commonly used to perform the above tasks.
Many JS purists believe that classical object-oriented programming should be left out of JavaScript and that one should stick strictly to prototypal development. While the two are related (they are both object-oriented), they can be applied to different problem domains in order to achieve results that are more natural or intuitive to developers; GNU ease.js works seamlessly with existing prototypes, allowing the developer to choose whether or not they want to use "classes".
License
GNU ease.js is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
N.B.: Versions prior to 0.2.0 were released under the LGPLv3+. Upon becoming
a GNU project, it was relicensed under the GPLv3+ to help the FSF stand strong
in its fight against proprietary JavaScript. For more information, please see
the NEWS file (which can be built with make NEWS
).