Tuesday, April 11th, 2006

Prototype: Easing Ajax’s Pain

Category: Programming, Prototype

If you’re just starting off in the vast world of Ajax, you might be wondering why so many people are using something as difficult as a manual XMLHttpRequest connection. Of course, Ajax wouldn’t be as wide-spread as it is if everyone had to write all of that code out by hand each time. Enter one of the most popular Javascript libraries out there, complete with Ajax support – Prototype. Never used it? Well, here’s a handy article to help get you up to speed.

From O’Reilly’s XML.com site:

This article describes Prototype, an open source JavaScript library to create an object for an AJAX application. I explain how to use Prototype by describing an environmentally oriented web application that displays an annual atmospheric carbon dioxide (CO2) level. First, I will discuss Prototype’s benefits and describe how to set up Prototype in your application. Second, I will delve into the nitty-gritty of how this application puts the library to good practical use.

When learning a new langauage or coding style, it’s always easier to have a goal to work towards. In the article they start from the very beginning (including a brief setup portion) and introduce you to Prototype and its functionality. You’ll need to have a bit of a Javascript background on this one, but it’s not too hard for most to pick up on.

Posted by Chris Cornutt at 7:08 am
17 Comments

++++-
4 rating from 34 votes

17 Comments »

Comments feed TrackBack URI

Isn’t this incredibly old news? Who doesn’t know about prototype??

Comment by Jimmy — April 11, 2006

Jimmy, thats quite narrow minded isn’t it?

The fact that Prototype comes up a lot is testament to how popular and good it generally is.

Also, for those people who are just discovering AJAX, and come across this site – being pointed in the direction of Prototype is a good thing imo.

Comment by Ryan G — April 11, 2006

I kind of agree with Jimmy on this, overall onLamp.com has always been one step behind the community.

Its still a good idea to introduce people to prototype but I think they would have already seen that even if they were just born today.

Comment by pplante — April 11, 2006

Awaiting Alex Russell throwing chairs at how it is Prototype again and not Dojo in 3..2..1.. ;-)

Comment by Mark — April 11, 2006

The thing about Prototype vs. Dojo is that Prototype is just a bit easier to wrap my head arround. I think the reason for this is that there are lots of little articles like this one starting from the beginning and introducing people to Prototype. Where are the articles like this about Dojo?

I keep hearing that Dojo is very powerful and Pythonic and I believe it. I just would like a well written “intro to Dojo”. And I am not just talking about how to make a simple AJAX call. Everyone has seen that. The community needs a more general introduction to Dojo and how to use it.

We all here that these frameworks are severely underdocumented and I think this is a huge problem for Dojo.

The Wiki looks like it is 1/2 complete
The Wiki needs example code for the methods
The “Getting started with Dojo” page only shows me how to include the js file and “require” one of the toolkits

Comment by Jay — April 11, 2006

I just started working with AJAX about a month ago and I peruse a ton of AJAX related sites (mostly starting with google and then clicking on the links within blogs and from the user comments) and I have heard of project maybe a half-dozen times. I’m going to check it out now.

Comment by acedanger — April 11, 2006

I’ve been keeping my eye on Ajax and Prototype for a while now, but due to other obligations (ie: school, job), I havnt had a chance to dive into it yet. I find articles like this to be very helpful to help wrap my head around.

Sure, for some people – it may be all old-news and nothing interesting, but there are still scores of ‘newer’ developers who havnt had a chance to get their feet wet with this stuff.

Comment by kaniz — April 11, 2006

In response to…
“and who doesn’t know about prototype?”

In the narrow statistical subset I am aware of:
– No one else in my development team.
– 4/5ths of a crowd from a local general developer user group.
– My mother… (shes not big into the net…)

Comment by Michael — April 11, 2006

I’d like to see some tutorials on how to use any of these frameworks to more easily write OO Javascript. :/

Comment by Stephen Clay — April 11, 2006

Oops, this one apparently delivers the goods in that respect. So this isn’t just another AJAX with Prototype article.

Comment by Stephen Clay — April 11, 2006

I think too that speaking about prototype is a good thing, if you already know and use it (like me) just pass your way, but if you don’t know it yet it will catch your attention. It is always good to speak about good things.

I don’t really understand how you can compare Dojo to prototype, prototype is a library located at the base level, it helps you write browser independant javascript quickly and better, Dojo on the other hand is more a framework and have support for animations, special effects, components.
I may compare it more to scriptaculous but never to prototype…

Comment by schmurfy — April 11, 2006

Nice article. Whether *you* think people should know about a subject doesnt make it true. Documentation, in almost any form, is always cool.

Comment by Noone — April 11, 2006

[…] ajaxian.com/archives/prototype-easing-ajaxs-pain […]

Pingback by AlbanyWiFi.com » Blog Archive » Prototype: Easing Ajax’s Pain — April 11, 2006

I agree with schmurfy who says : “I don’t really understand how you can compare Dojo to prototype, prototype is a library located at the base level, it helps you write browser independant javascript quickly and better, Dojo on the other hand is more a framework and have support for animations, special effects, components.
I may compare it more to scriptaculous but never to prototype…”
Just one correction probably is that dojo is not a framework but only a library (Well actually you can consider the Widgets part to be a framework but this represents only a small portion of it).
If i was to learn a new library to help doing developement in javascript, i wouldn’t think about it more than a sec and go for Dojo. Dojo helps make really great apps and there is an excellent community behind it .. (Actually, i have to admit that the documentation could be really better, but to my knowledge the team is working on a “Dojo Book” that could be released asap)

Comment by Javanaute — April 12, 2006

overall onLamp.com has always been one step behind the community.
This article is a nice introduction, and I think exposure for any utility as high-quality as Prototype is good. However, it’s not really very comprehensive, it literally is just an introduction to some basic Prototype features. Actually, it’s more of an example of usage. In fact there are some issues with the code examples (such as the name “getYear” which actually takes a year and returns the level for that year, would probably make more sense to call it “getLevel” or “getLevelForYear”). But the one thing that kind of bugs me is the fact that it’s titled “Easing Ajax’s Pain”, when there’s really nothing to do with Ajax in the article. I suspect this was an ORA editor’s idea. You know, if it has anything at all to do with JavaScript, slap “Ajax” on it and it’ll get more hits.

Comment by Erik — April 12, 2006

I love this quote from the article regarding the $() method:

“That sort of concision alone is probably worth the cost of setting up Prototype.”

Yeah, I’d use a 50K library just for that shortcut….

Comment by sup — April 12, 2006

I find articals like this exstremely usfull. the one thing I know I hate when I look at the syntax diferances, and am trying to brige information (ajax, php… so forth) the last thing i wanna do is go through page after page of crap info… Nuf said.

Comment by Scosak — June 23, 2006

Leave a comment

You must be logged in to post a comment.