Joose is an open-source, self-hosting meta-object system (class framework) for the JavaScript programming language. It provides a declarative, class-based object-oriented programming layer on top of JavaScript's prototype-based model, offering support for classes, inheritance, roles (also known as traits), method modifiers, attributes, and runtime introspection.
Overview
Joose was created to make object-oriented programming in JavaScript easier, more consistent, and less tedious. Rather than introducing a new language or a source preprocessor, Joose code executes as regular JavaScript and can run in any modern JavaScript engine. It focuses exclusively on the class system, following the principle of "do one thing, and do it good," and is therefore often used in conjunction with other JavaScript frameworks that handle DOM access and AJAX.
Joose was heavily inspired by Moose, the object system for Perl 5, which itself drew from the Perl 6 object system, as well as ideas from CLOS, Smalltalk, and other languages. Unlike Moose, however, Joose does not support multiple inheritance.
Key Features
- Classes and inheritance: Joose allows developers to define classes declaratively, with support for subclassing.
- Roles (traits): Roles provide a way of adding behavior to classes that is orthogonal to inheritance.
- Method modifiers: Joose supports "before," "after," and "around" method modifiers, allowing developers to wrap or augment method behavior.
- Attributes: Joose provides a rich attribute system, including automatically generated accessors (e.g., read/write accessors).
- Introspection: Joose provides a meta-API that allows classes to be queried about their attributes, parents, children, methods, and more at runtime.
- Mutability: Joose classes are dynamic, allowing attributes and methods to be added or removed at runtime.
Example
A basic class definition in Joose:
Class('Person', {
has : {
firstName : { is : 'rw' },
lastName : { is : 'rw' }
}
})
This declarative style allows developers to focus on the logical structure of their classes rather than the mechanics of prototype chains.
History and Development
Joose was developed by Malte Ubl, Nickolay Platonov, and Jeremy Wall. The project was created around 2008–2009 and was hosted on GitHub. The core package was reported to be approximately 8 KB (YUI+gz). Joose was tested using an automated unit-test suite run across major browsers (Firefox, Internet Explorer, Safari, Opera, and Chrome) and also supported the Node.js platform.
Distribution and Usage
Joose was available for installation via npm (npm install joose) and was distributed through JSAN (JavaScript Archive Network). It was tested for compatibility with several other JavaScript frameworks, including jQuery, YUI, Dojo, ExtJS, Prototype, Mootools, and PureMVC.
Licensing
Joose was released under the New BSD License. Its documentation was based in part on the original Moose::Manual documentation, copyright 2006–2009 by Infinity Interactive, Inc.
Status
Joose is a relatively early (2008–2011 era) JavaScript framework. While it was used in production environments and considered stable by its developers, it is not among the widely adopted JavaScript frameworks of the present day, and its active development has largely ceased.