Most Read Latest News Blog Resources

A Prototype for Browser Compatibility




April 15, 2007 — 
In the 1980s, the variety of operating systems used around the world necessitated reworking, recompiling and rewriting of corporate code for compatibility reasons. Today, the field of competing operating systems has narrowed, but the Web has created new wrinkles of inconsistency and idiosyncrasy for modern coders.

Whereas the problem used to be compatibility with operating systems, the problem for the past decade has been compatibility with the browser. That’s why a group of open source developers is expanding the scope of Prototype.js, a framework for building cross-browser applications in JavaScript.

Despite the original intent for the Web to be a platform-independent method of information exchange, the current state of divergence among Firefox, Internet Explorer, Konquerer, Opera and Safari has created a great deal of work for JavaScript programmers. One such programmer is Tobie Langel, a core member of the Prototype.js team. A musician by trade, he’s originally from Switzerland but is now based in Montreal.

Langel was not a JavaScript programmer when he discovered Prototype. He was building a Web site for his jazz band when he happened upon the project. “I’d say the code is beautiful,” said Langel. “And I’d say I learned about 90 percent of what I know about JavaScript by studying the code that’s inside Prototype and [its sister project] Script.aculo.us. It’s really perfected; it’s really smart. It’s there to ease the pain out of the client-side scripting.”

But it’s the capabilities of Prototype that hold the most beauty, said Langel. Rather than requiring developers to code up browser-specific elements and bug fixes, Prototype extends the

Document Object Model (DOM) and allows for more effective use of the data interchange format JavaScript Object Notation (JSON). That means an application built on top of Prototype should function in the same way regardless of the browser it’s run in.

By contrast, the Google Web Toolkit takes an entirely different approach to cross-browser incompatibilities. While Prototype gives developers a single file of code that works in all browsers, GWT compiles separate versions of an AJAX application and then sends browser-specific code to each client that asks for the page.

ROCKY TERRAIN
“It is a very big problem,” said GWT technical lead Bruce Johnson of browser inconsistencies.

“It’s hard to have it solved in the general case—it’s virtually impossible,” he said. “You really have to pick a set of use cases; then you can create cross-browser compatibility for those cases. Then hopefully it will extend to other use cases. You would be very surprised at how rocky the terrain really is. For a given use case [that] you didn’t plan to support, there is a real chance it won’t work, even when you think it should. [Some functions, such as] Focus can behave in a strange way. The structure of the DOM itself is different [in each browser]. The more complex the application you try to write, the more you realize that the underlying browser designs diverge.”

Langel and his co-coders are currently finishing work on Prototype.js 1.5.1, which should be out around the middle of this month. This edition improves JSON support and adds functional improvements.

“The $$ function is a great function to grab any DOM elements in a Web page by using CSS [Cascading Style Sheets] type selectors,” said Langel, describing the speed and usage improvements to the $$ function in 1.5.1. “You can write a type, and you can grab all the elements that correspond to that. We’ve added all of the CSS 3 selectors to that. That means you can select really easily, with one snippet of code, and get all the elements on the page that are linked [and] pointing to, say, a PDF document, and you can do something to each of those elements.”

Prototype is not alone in its development stable. The team behind Prototype is also working on Script.aculo.us, a library of JavaScript interface functions used to pretty up Web pages. The functionality of Script.aculo.us is built on top of Prototype, and includes many cross-browser interface tricks.


Share this link: http://www.sdtimes.com/link/30486
 

Add comment


Name*
Email*  
Country     


  • Comment
  • Preview
Loading



 
 
 
 
News on Monday
more>>
SharePoint Tech Report
more>>


   

 
 
Download Current Issue
ISSUE 3/15/2010 PDF

Need Back Issues?
DOWNLOAD HERE

Receive the print Edition?


 
blogs tab
Google Code turns 5
Google Code Turns 5, and adds a Paxos Algorithm to make the system more stable and reliable.
03/17/2010 11:16 AM EST

Test your Visual Studio 2010 know-how
Microsoft is offering free beta certification exams for Visual Studio 2010.
03/17/2010 11:08 AM EST

Microsoft lifts the hood on IE9
Microsoft is previewing IE9.
03/16/2010 01:10 PM EST

 

Events calendar tab
3/22/2010 to 3/25/2010
Santa Clara, Calif.
The Eclipse Foundation

4/12/2010 to 4/14/2010
Las Vegas
Penton Media

4/12/2010 to 4/15/2010
Santa Clara, Calif.
O'Reilly Media

4/19/2010
New York City
Flagg Management

4/25/2010 to 4/28/2010
Overland Park, Kans.
IIUG