CrxOop CrxOop: Bringing Object Oriented Programming, and Proper Prototype Based Programming, To Javascript
The aim of the library documented below is to provide developers with a solution to allow development using interfaces and classes as they are known in other object oriented programming (OOP) languages such as C++, C#, Java and PHP. Further more, V1.4 introduces structures, a generalization of the concept of prototypal inheritance, known here as POBP.
Subject
Body*
Email
SUBMIT CLOSE
Menu

5.1 Introduction

Structures are this author's vision, formalation, and generalization of prototypal inheritance and how it would work if javascript was a non scripting for rapid development, strict language like C++ or Java. Structure are CrxOop's implementation of Prototype Based Programming, or as this author likes to call it, Prototype Object Based Programming (POBP).

Some history. CrxOop started out as a proof of concept. It was meant to prove that a sufficiently performant implementation of object oriented programming could be added to current javscript engines (browsers) without much difficulty. Later CrxOop grew beyond that to provide full Object Oriented capabilities with Javascript Itself. Classes were meant to provide a facility for developing complex algorithms, and were not suited for data structures due to their large resource consumption. The underlying javascript plain objects were superior for the task, and a simple function to create an object and attach the required fields was always going to be the more efficient solution for data structures.

As it were, Javascript also provides prototypes, and instead one could use constructor functions to fill objects with data and benefit from the added benefits of prototypal inheritance. These benefits, without being stretched, were very limited this author thinks. Stretching, gave rise to different approaches and code recipes to try and mimick concepts from OOP. Code often looked messy. With the strange syntax that prototypes required, and the different code recipes used by developers to mimick things like private variables, code often looked confusing as well. Some developers were resulting to using underscores below variables or functions names to indicate they were private. An unspoken tradition, that is not always possible to tell whether the code is following it or something else.

One of the most important benefits of OOP, this author thinks, is that the code documents itself. With the need for data structures, a new mechanism had to be developed, and since with javascript it is already very easy to built arbitrary objects, this mechanism had to rival the underlying javascript mechanism. It had to reduce to it. In other words, be a super set of it. It had to be efficient. It also had to give the same aformentioned benefits from OOP. This gave rise to Structures.