Unobtrusive JavaScript Typing via JSON Schema Interfaces June 23rd, 2009 at 10:05 am by Kris Zyp

One of the frequently expressed frustrations with JavaScript, especially from users coming from more static languages, is the lack of typing capabilities in JavaScript. Typing provides the ability to define and enforce contracts between interfaces such that interactions can be validated before violated assumptions result in later difficult-to-find bugs. On the other hand, many users that have grown fond of JavaScript have come to enjoy the fast and free style, and the minimalism of simply defining behavior without needing to make extra type definitions. However, these two coding preferences do not need to be mutually exclusive.

The abandoned ES4 effort made a valiant attempt to add typing (without losing dynamism) via gradual typing; however this still demanded the inclusion of intrusive typing annotations—thus adding type constraints to code polluted the otherwise simple direct JavaScript programming style necessitating more complex, difficult-to-follow code. Other efforts include libraries to define types on functions without extending syntax.

It is now possible to unobtrusively define type constraints on properties and methods in JavaScript with portable JSON schema based definitions called JSON schema interfaces (JSI). JSI is a typing system for JavaScript that does not force any new syntax on JavaScript. Schema structures can be used to define the type constraints in a way that works with existing JavaScript classes and objects.

(more…)

Using REST Channels with cometD June 15th, 2009 at 1:02 am by Kris Zyp

REST Channels provides a mechanism for receiving notifications of data changes and integrates Comet-style asynchronous server sent messages with a RESTful data-oriented architecture. Dojo includes a REST Channels client module which integrates completely with Dojo’s JsonRestStore, allowing messages to be delivered through the Dojo Data API seamlessly to consuming widgets, with minimal effort. The REST Channels module will automatically connect to a REST Channels server, like Persevere (which offers REST Channels out of the box). However, existing infrastructure may necessitate the use of an alternate Comet server like Jetty’s cometD server. REST Channels can be used on top of another Comet protocol like Bayeux’s long-polling protocol and with a little bit of reconfiguration, you can use Dojo’s REST Channels with a cometD server to achieve Comet-REST integration.

(more…)

JavaScriptDB: Persevere’s New High-Performance Storage Engine April 20th, 2009 at 8:47 pm by Kris Zyp

The latest beta of Persevere features a new native object storage engine called JavaScriptDB that provides high-end scalability and performance. Persevere now outperforms the common PHP and MySQL combination for accessing data via HTTP by about 40% and outperforms CouchDB by 249%. The new storage engine is designed and optimized specifically for persisting JavaScript and JSON data with dynamic object structures. It is also built for extreme scalability, with support for up to 9,000 petabytes of JSON/JS data in addition to any binary data.
fast-commit.png

(more…)

Security in Persevere March 6th, 2009 at 1:01 am by Kris Zyp

Persevere’s security system provides a powerful infrastructure for controlling access to a system by combining the best aspects of capability-based security with role-based security. Persevere has a full user management system and granular per-object access control with inheritance. This system is designed such that it is very easy to use the default Persevere security to handle your access or integrate with an existing authentication system. Any part of the security system can be redefined and customized. Persevere can also be started without enabling security to make it easier to start development.

(more…)

Storing Binary Data in Persevere March 2nd, 2009 at 5:46 pm by Kris Zyp

Persevere stores structured data in the same way data is represented in JavaScript and JSON. Various different data types can be persisted including numbers, strings, booleans, objects, arrays, dates, functions, and even binary data. Most of these data types are familiar to JavaScript developers; however, binary data is usually not seen in JavaScript. Support for binary data opens up a powerful realm of application capabilities by allowing data such as images, audio, and video to be stored directly in the Persevere database and referenced by JavaScript/JSON style data structures.

(more…)

Deterministic Client/Server Interaction February 27th, 2009 at 1:04 am by Kris Zyp

The module dojox.rpc.Client was introduced in Dojo Toolkit version 1.2, providing extra request headers on XMLHttpRequests to facilitate implementing deterministic request handling on servers. Browsers typically use two or more TCP connections to send HTTP requests to a server, while subsequent requests are often routed on separate TCP connections. This means there is no guarantee that the request that is sent first will arrive at the server first. With sophisticated web applications, non-determinism can lead to bugs that are very difficult to track down.

If a web application sends multiple requests to a server and assumes that the server will handle them in the order they were sent, this non-determinism can be problematic. Furthermore, messages that arrive out of order can be rare, and therefore problems can be hard to reproduce. On old modem connections, packets were sequenced over a slow PPP connection that made out of order messages almost non-existent. With modern broadband connections, the race becomes more interesting. HTTP pipelining adds another mechanism that can lead to messages arriving out of order and with browsers beginning to support and use pipelining, messages arriving out of order will become even more likely in the future.

(more…)

The Distinction Between Application and Framework February 23rd, 2009 at 1:01 am by Kris Zyp

There are fundamental differences between the roles of application code and framework library modules within an application. Framework libraries provide reusable services that encapsulate lower-level functionality in an abstraction that offers functionality with an easy to use API for higher level code within a variety of different applications. Libraries generally stay static within the development of an application (besides the occasional upgrade). On the other hand, application code utilizes the functionality provided by library modules to create a specific behavior for the logical interaction between users and a domain of data in a generally tighter-defined environment. Application code is completely dynamic within the application development process, it is constantly changing as the application evolves and develops. Recognizing and facilitating these differences is key to intelligently structuring a framework, and is a key principle behind the structure of Persevere.

(more…)

Some RPC With Your JsonRestStore January 29th, 2009 at 3:53 pm by Kris Zyp

REST is a powerful architecture because of its loose coupling design that facilitates a high level of interoperability. However, even the dissertation that defines REST states that one of the trade-offs of REST is that it “degrades efficiency, since information is transferred in a standardized form rather than one which is specific to an application’s needs”. That is, you might be able to achieve more efficient operation using a mechanism that goes beyond REST’s uniform interface, that is more specific to your application. This comes at the price of a loss of interoperability and should only be used if necessary, but with this in mind, let’s look at a good way to use RPCs that integrate with Dojo’s REST module, the JsonRestStore. This approach builds on the REST architecture, while allowing exceptions as needed.

(more…)

New in JsonRestStore 1.3: Dates, Deleting, Conflict Handling, and more January 26th, 2009 at 12:02 am by Kris Zyp

The JsonRestStore is a Dojo Data store that provides a JSON-based RESTful interface to servers and implements the Dojo Data read, write, notification, and identity APIs. Since its addition in Dojo 1.2, it has been a popular Data Store because of its numerous features and its standards-based implementation of the HTTP specification (RFC 2616) for communications with servers. For Dojo 1.3, JsonRestStore includes a few extra features and some of the features in version 1.2 deserve a more elaborate explanation.

(more…)

Managing Server Structures in Persevere January 15th, 2009 at 12:54 pm by Kris Zyp

Persevere’s latest release includes new functionality for creating clean, organized application directory structures, complete with a testing framework. Persevere now has an improved set of command-line options including a server generator, which makes it easy to build an application server directory that can be version controlled separately from the Persevere core files. The new server structure also includes a mechanism for building unit tests for Persevere.

(more…)