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.
Prototype 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.
Atlas 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!