NAME

Joose.Manual - What is Joose, and how do I use it?

WHAT IS Joose?

Joose is a complete object system for JavaScript. Consider any modern object-oriented language. It provides keywords for attribute declaration, object construction, inheritance, and maybe more. These keywords are part of the language, and you don't care how they are implemented.

Joose aims to do the same thing for JavaScript. We can't actually create new keywords, but we do offer "sugar" that looks a lot like them. More importantly, with Joose, you define your class declaratively, without needing to know about prototype chains, etc.

With Joose, you can concentrate on the logical structure of your classes, focusing on "what" rather than "how". A class definition with Joose reads like a list of very concise English sentences.

Joose provides complete introspection for all Joose-using classes. This means you can ask classes about their attributes, parents, children, methods, etc., all using a well-defined API.

Joose is based in large part on the Moose system, which in turn borrows a lot of from Perl 6 object system, as well as drawing on the best ideas from CLOS, Smalltalk, and many other languages.

WHAT ISN'T Joose?

Joose isn't a new language or sources preprocessor. The code written in Joose, executes like regular JavaScript, and can be run in any modern JavaScript engine.

WHY Joose?

Joose makes JavaScript OO both simpler and more powerful. It encapsulates JavaScript power tools in high-level declarative APIs which are easy to use. Best of all, you don't need to be a wizard to use it.

But if you want to dig about in the guts, Joose lets you do that too, by using and extending its powerful introspection API.

AN EXAMPLE

    Class('Person', {
        has : {
            firstName : { is : 'rw' },
            lastName : { is : 'rw' }
        }
    })

This is a complete and usable class definition!

    Class('User', {

        isa : Person,

        has : {
            password : { is : 'rw' },
            lastLogin : { is : 'rw' }
        },

        methods : {

            login : function (pwd) {
                if (pwd != this.getPassword()) return false

                this.setLastLogin(new Date())

                return true
            }
        }
    })

We'll leave the line-by-line explanation of this code to other documentation, but you can see how Joose reduces common OO idioms to simple declarative constructs.

TABLE OF CONTENTS

This manual consists of a number of documents.

JUSTIFICATION

If you're still asking yourself "Why do I need this?", then this section is for you.

AUTHORS

Nickolay Platonov nplatonov@cpan.org

Based on original Moose::Manual content, written by:

Dave Rolsky autarch@urth.org

Stevan Little stevan@iinteractive.com

COPYRIGHT AND LICENSE

Copyright (c) 2008-2011, Malte Ubl, Nickolay Platonov

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Documentation is based on original Moose::Manual documentation, copyright 2006-2009 by Infinity Interactive, Inc.