Skip navigation.

How to Name Event Handlers in Global.asaxAll recent postsMore Workflow Goodies

Prototype vs. Atlas

Prototype is an extremely helpful JavaScript library by Sam Stephenson. The amazing thing about Prototype is that, while most folks use JavaScript to write procedural code, Sam not only pushes it beyond mere DOM manipulation, but also heavily capitalizes on the object-orientedness of this language. I’ve spent hours digging through Prototype, and was surprised how poorly the OO nature of JavaScript was described in books and how well it was captured in Prototype.

I think JavaScript is an underrated language, which people turned their backs on because it wasn’t good enough with the bling-bling effects Flash could produce, and because browsers implemented the DOM differently. It used to be popular to write “code forks” and serve different scripts to different browsers, but I believe we’ve grown out of it and embraced better techniques, such as object detection. Prototype is a showcase of what JavaScript can do.

I’ve also gone through Atlas Quickstarts to get a hang of it, and I figured I’d run a quick comparison of the two. One may argue comparing Prototype with Atlas is like comparing apples and oranges. I think it’s more like comparing one apple with a bucket full of apples.

ProtypePrototype is not so much a framework. It’s a rather light-weight library that captures the lion’s share of boring, routine tasks of manipulating DOM; placing Ajax calls and processing their responses; wiring event listeners; creating class hierarchies, and other grunt stuff. It exists to simplify client-side development. With Prototype you’re focused on the interaction with the client. You’re still talking to DOM, you’re still setting up event listeners, but you do it via a slim API, so all the best practices are already captured and wrapped for you.

AtlasAtlas goes well beyond that. Atlas has you focused on the server-side development. I feel like Atlas gets me to write C# code on the client. If you look through Atlas samples, they are very verbose because you code like a sever-side developer where you are supposed to create namespaces and name your classes and methods in unambiguous ways. On the server, everything is compiled into a binary, so who cares about the length of method names. In this sense Atlas code looks like client-side C# on meth.

This is where Atlas and Prototype are different: Atlas is built for a server-side developer, Prototype—for a client-side developer.

It’s worth remembering Atlas is designed specifically to work with ASP.NET so it has some heavy-weight features, such as registering namespaces and interfaces, talking to web services, performing data binding, etc. Prototype will probably never have any of this, and it doesn’t need to.

Another thing that bothers me about Atlas is the heavy-handed way of “orchestrating” interactions among controls on a page. You have to define pretty verbose XML which will inevitably create unhealthy reliance on tools to manage it. MS_POSITIONING="GridLayout" comes to mind. This is a classic example of a feature add-on which was tool-managed and badly misunderstood. I wish it was never introduced in the first place (see Remastering Web Forms).

Documentation

Atlas has pretty good documentation, although some samples don’t work, and in several places documentation “is coming soon…” Prototype docs are scattered all over the place. To better understand this library I dug through source code. I intend to post some samples here in the upcoming weeks.

Choose Your Tool

Atlas and Prototype each has its own groove. I expect server-side developers to gravitate more toward Atlas although the sheer payload of it will be punishing to the end user. I anticipate UI, usability and accessibility craftsmen to choose Prototype to build on.

Prototype, currently in ver. 1.3.1, is stable and good for production use.

It’s too early to talk about the quality of Atlas code. I sure hope we won’t need to have 5 script includes to cater to various browsers in the future. If I understand it correctly, you’re not allowed to plug Atlas code in a commercial product just yet.

Prototype-Based Projects

Check out the following projects for inspiration:

Happy coding!

Comments

Comment permalink 1 David O'Hara |
Might I recommend this article for a great explanation of the Prototype.js.
Comment permalink 2 Kigorw |
Look to the most ambitious Atlas project www.live.com


Ajaxline - Ajax programming community
Comment permalink 3 Armand DAtema |
Hi

You might also wanna check out http://www.jquery.com. This is a great library for even more OO. Best part of it is that you can program using chainable methods and will make your script very easy to understand and realy clean in code.
Comment permalink 4 Milan Negovan |
JQuery looks good, although it has a feel of several projects (Prototype, Moo.fx, etc) pasted together.
Comment permalink 5 Dylan Thomas |
Milan - Any more thoughts on this now that ASP.NET AJAX is getting close(r)? I've been using prototype.js in combination with general handlers to spit out JSON snippets and it seems to work well. I have been following ScottGu's articles and how-to's but have not really messed with the Microsoft stuff yet. I'd be interested to hear if your opinion has changed.

Dylan
Comment permalink 6 Milan Negovan |
Both Atlas and Prototype have made great strides since this post. I still need to catch up on their latest releases, so I don't have an opinion yet.
Comment permalink 7 uuu |
5656

Emails and Notifications

Would you like to be notified when somebody responds to this post?  Would you like to have these comments emailed to you?

Submit your comment

Please enter only text since all HTML tags except hyperlinks will be stripped. Hyperlinks will become live links. Any comments with flaming or offensive language will be deleted. Be courteous to other posters. Thank you.

Your name (required):
Your email (optional):
Your site's URL (optional):
Enter this number
Type in the number above:
Comment (required):