The Artima Developer Community
Sponsored Link

Java Community News
Scott Raymond on What's New in Prototype 1.5

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Scott Raymond on What's New in Prototype 1.5 Posted: Jan 26, 2007 3:30 PM
Reply to this message Reply
Summary
The Prototype JavaScript library reached its 1.5 release. A new Web site and long-awaited documentation are among the attractions of this release, as are dozens of new features. The most important new Prototype features are explained in a recent XML.com article by Scott Raymond.
Advertisement

Over the past two years, the open-source Prototype library has become a popular tool for building Ajax applications. Prototype reached its 1.5 release this week, celebrating the occasion with the arrival of long-missing documentation and a manual, as well as a new Web site.

To note the new release, Scott Raymond penned an article in O'Reilly's XML.com zine, What's New in Prototype 1.5. Raymond puts prototype in the context of Web application development, and then shows the library's new features:

The Prototype library is fairly compact (about 15K), and decidedly not a kitchen-sink library. It doesn't provide custom widgets or elaborate visual effects. Instead, it just strives to make JavaScript more pleasant to work with. In many ways, Prototype acts like the missing standard library for JavaScript—it provides the functionality that arguably ought to be part of the core language.

Despite the minor version number bump, the 1.5 release is a major one. It's been over a year since 1.4 was released, and the library has made significant strides in that time, while retaining complete backward compatibility.

Raymond's article looks at four sets of new Prototype 1.5 features: Ajax support, String extensions, Array/Enumerable extensions, and DOM access. About Ajax features, Raymond points out that:

Prototype is perhaps best known for its top-notch Ajax support. Of course, Ajax-style interactions can be created without a JavaScript library, but the process can be fairly verbose and error-prone. Prototype makes Ajax development more accessible by accounting for the varieties of browser implementations and providing a clear, natural API.

The 1.5 release adds even more power, especially as relates to creating RESTful, HTTP-embracing requests. Prototype now has the ability to easily access HTTP request and response headers and simulate HTTP methods other than GET and POST by tunneling those requests over POST.

Prototype has already provided numerous String processing methods, to which several new ones were added in 1.5:

A thorough set of string-processing methods are an invaluable weapon in the web developer's arsenal. With version 1.5, Prototype's suite of extensions to the standard String class (or more accurately, the String prototype) has roughly doubled...

In addition to Prototype's new extensions to the String prototype, it also defines an entirely new class for string manipulation: Template, which provides simple templating functionality with JavaScript strings. Using the Template class is simple: just instantiate a new template with the constructor, and then call evaluate on the instance, providing the data to be interpolated.

In addition to String manipulation, new APIs were added to the Array prototype as well:

[Prototype] also extends JavaScript's Array prototype with over a dozen methods, including four in the latest release.

Raymond then explains use of the size(), clone(), reduce(), and uniq() methods. The bulk of Raymond's article is dedicated new features related to DOM access:

The area that has gotten the most attention in the 1.5 release is Prototype's DOM access and manipulation methods.

A new Selector class has been added for matching elements by CSS selector tokens. The new $$() function provides easy access to the feature, returning DOM elements that match simple CSS selector strings.

In addition to the plethora of new features, Prototype is also among the most-tested JavaScript libraries. It comes with a testing infrastructure that can be used in any Ajax project as well:

The Prototype developers maintain a suite of unit tests alongside the library itself, verifying that the code works—and keeps working—across a range of browsers. The test coverage in this release has skyrocketed, with an incredible 20-fold increase in the number of assertions. The testing infrastructure has matured remarkably as well: with one shell command (rake test, which requires Ruby and the Rake library), Prototype's tests are automatically run in every browser found on your system, and the results are displayed. You take advantage of the same infrastructure to test your own JavaScript, thanks to unittest.js, part of the script.aculo.us library. The status of the JavaScript test run can even be automatically integrated with the other unit tests in your system. If you are building a JavaScript-heavy web application, that safety net can be a life-saver (or more likely, a job-saver.)

What are your favorite JavaScript libraries? And what do you think of the various emerging frameworks for unit testing JavaScript code?

Topic: Doug Crockford: The JavaScript Programming Language Video Previous Topic   Next Topic Topic: Go Ahead. Break the Build

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use