Jon Aquino's Mental Garden

Engineering beautiful software jon aquino labs | personal blog

Friday, April 21, 2006

Comparison of Dojo and Prototype (javascript toolkits)

flashbang on the Dojo IRC channel suggested I do a quick write-up of my experiences working with Prototype and Dojo. I've used Prototype for a couple of AJAX-heavy applications (for Cute Overload and American Idol) and am using Dojo for my current project.

Two things I really like about Prototype are the (you guessed it) $() function (shortcut for document.getElementById()) as well as the many iterators (including faves from the Smalltalk world like collect and inject).

Dojo has fairly good approximations of the above, plus some heavy-duty features. I love the scarily super-powerful event toolkit (*every* function call is an event), which is the first use of Aspect-Oriented Programming that I've found useful. And the Widget framework is a fantastic way to organize/modularize huge JavaScript projects (a Widget is simply a javascript file + an html file, with some niceties for restricting the scope of events).

Overall, I like both. Prototype is more of a Porsche, whereas Dojo is more like a Hummer. Prototype is pure programming bliss (feels very much like Ruby), whereas Dojo is very much engineered (feels like Java) -- possibly a little overengineered in some places (IFrame-based workarounds) in order to offer what no other toolkit offers (asynchronous file uploads; AJAX back-button handling; javascript "include" mechanism).

25 Comments:

  • Dojo has never been my cup of tea, but I respect its developers and the strides they've made. The good thing about having so many open-souce JS frameworks to choose from is that any killer features in one will soon be included by the rest.

    I think the next step for both frameworks is to get some proper documentation and an organized support mechanism. (IRC and listservs are nice, but I'm not sure they count.) I'm going to do all I can for Prototype; I'd love to see Dojo do the same.

    By Anonymous Anonymous, at 5/10/2006 7:03 p.m.  

  • Hi Andrew - right on. Yeah, I do love Prototype and I love Dojo as well, for different reasons. Thanks for the call to action for better documentation!

    By Blogger Jonathan, at 5/10/2006 7:13 p.m.  

  • We have moved from script.aculo.us & TrimPath templates to dojo, but both are brilliant and you need to pick the one that suites your needs.

    We are building a commercial web application that avoids server side page generation -- so we need dojo's packaging, templating, and dynamic widget loading/creation. Dojo has also really helped with code modularisation, and the community is great.

    Good article thanks.

    By Anonymous Anonymous, at 5/10/2006 7:40 p.m.  

  • Anonymous - Fantastic! Great to hear you've benefited from both frameworks.

    By Blogger Jonathan, at 5/10/2006 7:42 p.m.  

  • All the JavaScript frameworks are great! But we need a good framework for those who build enterprise applications and cannot write extensive JavaScript.

    What do you think about the following? This web page teaches how one can build reusable Ajax GUI Widgets:
    http://cbsdf.com/technologies/DHTML-Widgets/Widget-samples.htm

    No serious applications can ever emerge with out a solid set of reusable GUI Widgets, which must offer higher-level abstractions that let developers focus on business logic at hand. Imagine writing desktop GUI, without Windows GUI-API. Are you going to implement all the primitives yourself and include in the same functions that implement business logic?

    I am a Java developer. I request Web designers to give us great GUI Widgets, so that we can also build great GUI applications!

    By Anonymous Anonymous, at 5/10/2006 10:45 p.m.  

  • Hi Anonymous - Yup, reusable javascript components are definitely a great idea. I believe we are moving in that direction, especially with the "Ajax Linking and Embedding" idea floated around earlier this year. Also the Dojo "Widget" mechanism could be a great platform on which to build reusable components.

    By Blogger Jonathan, at 5/10/2006 10:52 p.m.  

  • Has anyone used Mochikit in anger? How does it compare?

    By Blogger Thomas David Baker, at 5/11/2006 12:06 a.m.  

  • I have used both mochikit and dojo in projects and prototype in experiments.

    Prototype and mochikit are similar in scope and feel like ruby and functional python respectively. Mochikit added a qt-like events system in 1.3, which I'm using in my current project. It's not as cool as the dojo system, but it gets the job done and is a bit faster. I use mochikit over prototype because I mix together a lot of javascript libraries and I don't consider prototype code to be javascript.

    In dojo, I don't use the widget system, but I do use the events, io, and behavior parts. I use it for larger scale apps and it's excellent for that.

    To the java developer: I'd counter that no great GUI applications have emerged from the java community despite having a set of common widgets. Every java app that I've run across with a decent UI has opted to build their own widgets.

    By Anonymous Anonymous, at 5/11/2006 10:43 a.m.  

  • Thomas - I've heard some good things about Mochikit - must play around with it sometime.

    Anonymous - thanks for that prototype:mochikit => ruby:python comparison!

    Kevin - Hm! I'll definitely have to check out MochiKit to see what the fuss is about.

    Floydm - Yup, another person told me they feel similarly.

    By Blogger Jonathan, at 5/11/2006 3:01 p.m.  

  • Why compare approaches on technical merit, surely real world usage would be more useful. I'm very glad Plone has devcided to ship prototype, not because I like it (I hate all javascript!) but because I can reuse scriptaculous widgets. It's all about traction dammit! Laurence

    By Anonymous Anonymous, at 5/12/2006 11:51 a.m.  

  • Laurence - yup the degree of adoption is definitely a factor when choosing!

    By Blogger Jonathan, at 5/12/2006 1:06 p.m.  

  • cool dojo function: dojo.style.insertCssRule('#sn_header .sIFR-flash', 'visibility: hidden !important;');

    By Blogger Jonathan, at 5/12/2006 3:35 p.m.  

  • another cool function: dojo.style.getStyle(dojo.byId('sn_name'), 'height')

    By Blogger Jonathan, at 5/12/2006 3:48 p.m.  

  • another cool feature: browser sniffing: dojo.render.html.ie50 || dojo.render.html.ie55 || dojo.render.html.ie60

    By Blogger Jonathan, at 5/12/2006 3:53 p.m.  

  • dojo.lang.hitch() - explicitly sets the "this" object for a given function

    By Blogger Jonathan, at 5/12/2006 9:38 p.m.  

  • "Why compare approaches on technical merit, ... It's all about traction dammit!"

    I do think it's amusing that whenever anyone speaks from ignorance they start sounding like marketing people :D

    By Anonymous Anonymous, at 5/12/2006 11:06 p.m.  

  • looks like Jonathan is trying to change the tone of this thread with his multiple cool Dojo entries :)

    By Anonymous Anonymous, at 5/15/2006 7:12 p.m.  

  • Hi Anon - heh, just needed a place to record the cool Dojo functions I'm finding.

    By Blogger Jonathan, at 5/15/2006 8:06 p.m.  

  • But what about the yahoo user interface library I haven't gotten around to giving it a try, but I am pretty excited from what I have read.

    By Anonymous Anonymous, at 5/16/2006 9:42 a.m.  

  • Hi Jamie - Yeah I've heard good things about the Yahoo UI library. I took a peek and if I remember correctly it doesn't have as much stuff in it as Dojo or as many syntactical niceties of Prototype ... yet!

    By Blogger Jonathan, at 5/20/2006 12:36 a.m.  

  • Who's best at class-like behaviour and doing includes/imports?

    Also: I'm getting so fed up that I'm considering writing an hierarchy of roughed-in Java classes to create javascript stubs by relection---another possible advantage (which you might hate): automatic Magyarisation, if desired:
    String result --> var strResult
    int index --> nIndex
    and so on.

    I gather Google do something like this, but much more elaborately, so I guess my question is: are there any good preprocessing systems to take sweeter syntax and convert it into javascript's, much as C++ was originally preprocessed into C?

    By Anonymous Anonymous, at 6/14/2006 11:42 a.m.  

  • Hi M.Turyn - for class-like behaviour and includes/imports, it's clearly Dojo.

    Also I haven't tried it but Google recently came out with a tool that will let you write Java and it will spit out Javascript code. It has its pros and cons.

    By Blogger Jonathan, at 6/14/2006 8:10 p.m.  

  • How about picking the best of the worlds and making "projo". Both are impressive in their own way.

    It's as per your convinience you like. I think both the teams should collectivly work for the best js framework

    By Blogger Varun Mehta, at 8/01/2006 4:53 a.m.  

  • Hi Varun--heh--actually the two libraries can exist side by side. I've seen it work.

    Jon

    By Blogger Jonathan, at 8/02/2006 1:31 a.m.  

  • Prototype is at best a Civic...

    By Blogger Alexander Fairley, at 4/01/2007 10:25 a.m.  

Post a Comment

<< Home