21
Sat, Dec
3 New Articles

JavaScript Frameworks Compared

Web Languages
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

DHTML is what makes the browser dynamic, and JavaScript frameworks allow mere mortals to make it happen.

 

JavaScript frameworks are the newest weapons in the Web application arsenal, and they're seriously powerful. Comparing something like JQuery to a JavaScript date picker is like comparing a cruise missile to a slingshot. The problem is trying to decide which one is best for you, and that's going to depend a lot on what you want to do. But suffice it to say that if you want a dynamic application, you will need one of these toolkits.

 

The first frameworks came about specifically to allow more powerful JavaScript programming. Other frameworks are designed primarily to make your applications sexy. The Web 2.0 movement spawned these libraries, and they can do spectacular things visually. Still others have been written to interact with server-side logic. Some are commercial, some are open source, and some are a strange mix of the two (the Google toolkit uses services that Google provides for free--well, today they're free).

Where Did All These Wonderful Toys Come From?

The sheer number of frameworks available makes an exhaustive study of the subject...well, exhausting. Just trying to break the frameworks down into categories is a tough job, because a lot of overlap exists between the various packages.

 

For example, let's start with something simple like Prototype. While dynamic HTML (DHTML) has been around for a long time, it wasn't until the popularization of AJAX that people really started to look at it. That's because AJAX changes the rules entirely; instead of having to load an entire page to get new data, the browser can make requests back to the server for small chunks of data. This in turn means that the page can react dynamically to user events as small as individual keystrokes or mouse movements.

 

The driver behind this whole process is the XMLHttpRequest. The function is actually misnamed because it doesn't require XML, but that's not really at issue; the important point is that the code, even for a simple request, quickly gets bogged down into the intricacies of JavaScript and object orientation. Take the simple function below:

 

function ajax(url, vars, callbackFunction) {

  var request =  new XMLHttpRequest();

  request.open("POST", url, true);

  request.setRequestHeader("Content-Type",

      "application/x-www-form-urlencoded");

       

  request.onreadystatechange = function() {

    if (request.readyState == 4 && request.status == 200) {

      if (request.responseText) {

        callbackFunction(request.responseText);

      }

    }

  };

 

  request.send(vars);

}    

 

This is just the tip of the iceberg. The code above doesn't even take into account formatting the URL or the variables to be sent to the URL; nor does it then explain how to apply the result to the document. It's just the plumbing required to send an HTTP POST request to a URL using AJAX. As you can see, this is not exactly code for the faint of heart.

 

But if nothing else, JavaScript is a true OO language (perhaps even more OO than Java itself), and it excels at hiding complexity. The Prototype library reduces the code above to this:

 

new Ajax.Updater(target, url, {method: 'post', parameters: vars});

 

All of the lines of code in the previous snippet are encapsulated in the single invocation above, which actually even updates the Web page (it inserts the returned HTML into the  DIV in your document whose ID is contained in the variable named target).

 

The moral of this part of the story is that JavaScript has incredible power and that the frameworks out there make that power available to the everyday programmer (as opposed to the JavaScript gurus who design these frameworks).

Some Frameworks

I wish I could give you a complete rundown of all of the frameworks, but there are just too many. But I can give you a little background on the different types of frameworks and what they offer and then point you to some of the more popular frameworks (as well as a couple of lesser-known but really cool ones I've found during my research).

 

The Big Four

 

First, the granddaddy of them all is probably Prototype. As noted above, Prototype is really just an enabling package. It's designed by programmers for programmers to allow you to extend the JavaScript language and easily perform some of the basic functions required to provide a rich user experience. However, Prototype doesn't have any native  support for widgets; that is contracted out to something called Scriptaculous, a library built on top of Prototype. Scriptaculous provides core functions such as visual effects (opacity and movement, for example) as well as basic DHTML features such as creating new nodes or enabling drag-and-drop functionality. Scriptaculous is used extensively within the Ruby on Rails community, but it's also quite popular on its own.

 

About the same time as Prototype was being designed, another technology called Dojo was making its debut. Dojo is very powerful and has some real power attributes. It has one of the larger development communities, and the growth of its associated libraries (such as Dijit, the Dojo Widget library) has been impressive. Also, like it or hate it, IBM is very much behind Dojo, and thus it's likely that of all the frameworks, Dojo will get the most attention from the Rational developers. Its glaring weakness today is documentation. Where all the other frameworks have extensive documentation, Dojo's is severely lacking, although they are working hard to fix that and the community also has its own "campus" site, dojocampus.org. On the plus side, Dojo a professionally engineered piece of software, with serious attention paid to things like packaging and distribution.

 

Then there's jQuery. By far the most capable in the area of animations, jQuery allows you to do some fantastic visual effects--things you just don't expect in your browser. Also, jQuery has the best support for XML; it allows you to easily retrieve data from a server in XML format and then parse that for processing into the document. How important this is depends on your focus; when Chris Laffra and I designed the RSDC Scheduler application, we decided to use JavaScript Object Notation (JSON) as our way of communicating data between the layers of the application. I think if your application is a multi-tiered application using primarily internal data, JSON is the way to go, while if you are going to be talking to a lot of outside services, then XML is more appropriate, and that's where jQuery has an advantage. jQuery is also the hands-down leader in documentation, both through example code and online tutorials.

 

Rounding out the top four you have YUI, the Yahoo UI. YUI is one of those toolkits that comes about organically. As the Yahoo developers needed more and more Web capability, they found themselves creating a common library of functions. As the library became more complete, the developers decided to release it to the public. YUI has a lot of great features and is probably the most well-rounded of the frameworks, but it has a huge negative in that it's perhaps the most intrusive, requiring you to adhere tightly to its HTML conventions (particularly the use of DIV tags to define the attributes). Note that this is not necessarily the worst news; other frameworks--Dojo in particular--use customer attributes that can cause problems for HTML editors. So again, a lot depends on your requirements.

 

In fact, even if you were to go with one of the top four, which one is best for you depends to a very large degree upon your software development requirements. For example, if WYSIWYG is your thing, pretty much only Dojo and YUI provide that tooling today. The snazziest widgets today are probably in jQuery, along with the best documentation. As befits its somewhat more professional approach to development, Dojo leads the pack in i18n (internationalization) and a11y (accessibility).

 

Some Others

Quite a few other frameworks exist, although with relatively smaller followings. The big four make up the big percentages, with Prototype pretty comfortably in the lead and the other three jockeying for second place. But other good options do exist.

 

Some frameworks are built on top of others. Since Prototype doesn't have a robust widgets library, other frameworks provide them, with the primary library being Scriptaculous. However, others are available, and one with some impressive capabilities is Rico. You can see a demo here.

 

Some toolkits strive for compactness; the folks who created the MooTools library definitely focused their energies toward that goal. MooTools is one of the smallest libraries, yet it supplies a wide variety of elegant features. Another small and powerful library is Mochikit. While perhaps not as full-featured or even polished as other frameworks, it has the benefit of being really, really small.

 

One of the cooler demos is for Echo3. The transitions and the overall "desktop-like" nature of the user interface are very impressive.

 

Then there's Ext. Ext is a hugely popular framework, but it's really amorphous, so its use is hard to gauge: The ExtJS version can be used either standalone or on top of Prototype, YUI, or jQuery. Ext can work with Google or ASP.NET. There is some concern regarding the licensing, but supposedly the Ext developers have finally decided on a simple GPLv3 license (I won't spend any time on that here; open-source licensing is a subject best left for long leisurely days and flame-retardant suits).

Some Things That Are Not Frameworks

This is a very important point: Rich UI options exist that are not JavaScript frameworks. Instead, they are rich-client plug-ins that run, with varying degrees of success, inside your browser. The originals were probably Macromedia (now Adobe) Shockwave and Apple QuickTime. Flash was also one of the early pioneers in this arena; in some ways it's a sort of "Shockwave lite."

 

The difference between these formats and JavaScript frameworks is that you need to create and compile the presentations into a proprietary format using a proprietary tool and then send the entire thing down to the client, which in turn must have already installed the corresponding proprietary player.

 

The different players have different characteristics. Shockwave, for instance, seems to be pretty friendly and works and plays well with other software, while QuickTime often seems like that horrible weed you just can't get out of your garden no matter how many times you try. And sometimes these players even act as security exposures; QuickTime has had numerous exploits over the years. And really, I'm not picking on QuickTime; other players have issues as well. It's just that QuickTime's bugs are so bad. The last one in November got a U.S.-CERT rating of 10 out of 10.

 

The latest entry in the player plug-in category is Microsoft's Silverlight. I don't think it's terribly surprising that Microsoft would choose a solution that requires lock-in to both a proprietary format and a proprietary development tool, as opposed to a more open framework style of coding.

 

Some might argue that a JavaScript framework is similar in that you have to download the framework and then the actual JavaScript for the page, but typically we're talking about much smaller downloads for a framework. More important, though, is the fact that, especially for the open frameworks, what you are sending is raw JavaScript that can be executed on any browser on any machine without having to install any other software. This zero-footprint approach makes it much more likely that anybody on any machine can run your application.

 

And Then There's Google

 

I haven't even touched on Google and the Google Web Toolkit (GWT). Google is an odd hybrid in which you use JavaScript to call Google services, which in turn provide rich UI features. For example, Google has APIs that will draw beautiful business graphics for you. All you do is send them the data, and they'll create a line graph or bar chart that you include in your Web page as an image. You can also easily incorporate a map onto a page just by presenting Google with the address.

 

And really, it's even odder than that, because to use GWT, you write your code in Java, which GWT then translates to JavaScript, which is what you actually send to the browser. It's a rather Rube Goldberg version of the old applet technology, but it has some really powerful capabilities.

 

My reason for putting Google in the section with the proprietary players is that the Google APIs require that you make a request to the Google servers. Google doesn't charge you anything for this service, and if there's a single Web-based service provider that I'd be willing to trust would always be available, it would be Google. But what if--just what if--Google decided one day to either charge for this service or simply not provide it anymore. That's a business issue that you need to address up front.

Frameworks and EGL

If phrases like "hiding complexity" made you think that a comment or two on EGL would be forthcoming, you would have been correct. One of the foremost goals of EGL is the ability to hide complexity. So the EGL Rich UI tooling and JavaScript frameworks have a natural affinity to one another. That affinity makes EGL very appealing to anybody who wants to get the sizzle of Web 2.0 without having to become an expert on frameworks. That's because EGL will provide wrappers to the more popular frameworks, making it a simple matter of drag and drop to place things on the page.

 

And don't worry about lock-in, either. EGL is very good about allowing you to create your own EGL/JavaScript interfaces, so if you do decide that you need one of the frameworks that isn't directly supported by EGL, you can easily write your own EGL wrapper classes. But to start with, expect to see good support for both the Dojo framework and the Google widgets.

 

I'm looking forward to writing more about EGL Rich UI and its use of JavaScript frameworks in coming articles; I think it's the easiest way for an old green-screener like me to be able to get into the exciting new world of Web 2.0. And even if you don't use EGL, you can certainly dip your toes into the JavaScript framework pool by downloading any of the frameworks I've talked about and using them in your own private sandbox. Remember, the majority of these frameworks are strictly client-side and don't even require a Web application server, so you can test them on your desktop in your browser without any special server-side software. So get out there and get dynamic!

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: