The Jay Framework and Guide

Released 4 years ago , Last update 3 years ago

A concise guide to understanding javascript best practices with the standard library that overcomes javascript's inconsistencies and provides a framework for best practices, common problems and more readable code.

This is an exclusive preview release of the first version of the Jay project, "checkout" at the top right to download the guide and library package.

Introduction to the Jay Project

The Jay project aims to look at the nature of Javascript and produce a standard library which makes it easier for you understand and use Javascript to develop high quality code.

Javascript admittedly lacks many features and contains many as yet unaddressed flaws that make it difficult to develop in, harder to learn, and much less powerful than it can be.

The Jay project introspects the language and uncovers it's true nature, proving that Javascript is a beautiful and consistent language. Through the utilities provided in the standard library Jay morphs Javascript into a language that is beautiful, consistent and powerful.

What the Standard Library Provides

The standard library provides a framework for the following aspects of javascript:

  • Object Manipulation

  • Type Creation

  • Type Checking

  • Namespacing

  • Iteration

  • Concurrency

Guide Book to More Intuitive Javascript

This package includes the "More Intuitive Javascript" guide book to the Jay standard library. The guide walks through each of the standard library modules and how Jay is able to conceptualize Javascript as a beautiful, elegant and intuitive language.

  • Flowing with Javascript
    • Object Customization
    • Inlined Functions
    • Closure Scope
  • Manipulating Objects
    • The 3 Means of Defining Objects
    • Customizing Objects
      • Overlay and Underlay
      • Definition
    • Arbitrary Inheritance
    • Specializing
  • Creating Types
    • Objects of Differing Types
    • Type Hierarchies
    • A Prototypal Language
    • Defining Constructors
    • Prototyping
  • Type Checking
    • Built-in Types
    • Primitive vs Objects
    • Constructor Reflection
    • Type Hierarchy Reflection
    • Arbitrary Inheritance Reflection
  • Iteration
    • Forms of Iteration
    • Built-in Iteration Constructs
      • Numerical Iteration
      • Property Enumeration
      • Custom Iteration
    • Jay's Iterators
    • Customizing Iteration
    • Implementing a Numerical Collection Type
    • Implementing an Each Iterator
    • Useful Iterator
    • Functional Iteration
      • List Comprehensions
      • Mapping
      • Breaking out
  • Namespacing
  • Concurrency

Benefits of a Standard Library

  1. Simplifies the understanding of javascript through usage tools.

  2. Best practices become core mechanisms of the language.

  3. Guide developers towards the best technique to achieve something, by including best practices as core mechanisms of the language.

  4. Abstract over the ugly parts of javascript to avoid complexities, and add utilities to improve power and keep the consistency.

  5. Have a consistently implemented core javascript environment across all engines.

  6. Readability of code is enhanced tremendously by having common techniques built into the language.

  7. Improve community collaboration and cohesion by having a common way to do things.

  8. Solutions to common problems are provided by default, for problems you know, and for solutions you may not have realized are possible.

5.0
  • 5 1
  • 4 0
  • 3 0
  • 2 0
  • 1 0
1 Reviews Read Reviews

Pricing

FREE

Personal License

  • Perpetual license

  • 1 site, unlimited servers

  • No distribution (hosted use only)

  • Commercial use

Example Usage

Defining Types

Jay provides a very simple and core mechanism to define types intuitively.

var Node = type(Object, function() {
    this.constructor = function() {}
})

var Element = type(Node, function() {
    this.constructor = function(tagName) {
        this.tagName = tagName
     }

    this.byId = function(id) {
        return
    }
})

Type Checking

Javascript's type checking mechanisms are very poor and difficult to use for what we often want, Jay provides type checking mechanisms that are simpler to use and make sense of Javascript's type system.

isPrimitive("hello")
istypeof("hello", String)
istypeof(new String("hello"), String)
typeOf("hello") === String

typeOf(new Element) === Element

Iteration (and Namespaces)

The namespace utility allows you to ensure that a container object holds a certain hierarchy of properties, so that you can safely reference that hierarchy and place contents in it.

Here you can also see the block function, which will just execute a function immediately as if it were just a block of code.

Jay provides a very foreach iteration function which can iterate any object, allows you to specify custom iteration on objects, and enables powerful functional programming techniques such as list comprehension.

namespace (global, 'Iteration', function() {

namespace (global.Iteration, 'Golden Rules', function() {

    block(function objectEnumeration() {

        var properties = { 1: null, 2: null, 3: null, 4: null }, counter = 1;

        foreach (properties, function(v, k) {
            if (properties.hasOwnProperty(k))
                assert(k == counter++)
        })

    })


    block(function arrayIteration() {

        var items = [1,2,3,4,5], counter = 1;

        foreach (items, function(v, k) {
            assert(v == counter++)
        })

        // never try to iterate arrays with for (var i in items), that is property enumeration

    })

})

namespace (this, 'Customizable Iteration', function() {

    var Range = function(from, to, skip) { skip = getDefault(skip, 1)
        this.each = function(F, iter) {
            var r, n = 0; for (var i = from; i <= to; i += skip)
                r = F(i, n++, this, iter)
            return r
        }
    }

    foreach (new Range(5, 10), function(v, k) {
        assert (v == 5 + k)
    })

})

namespace (this, 'Break Free', function() {

    var items = [1,2,3,4,5], counter = 1;

    foreach (items, function(v, k, array, iter) {
        assert(v == counter++)

        if (v  == 3)
            iter.stop()
    })

    assert(counter == 4)

})


namespace(this, 'List Comprehension', function() {

    var doubles = foreach(range(1,20,4), collector(function(v) {
        return v * 2
    }))

})

})
License » Personal License Download

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.


Or enter your name and Email
No comments have been posted yet.