Frustrating User Experiences: Remember what I say Wordpress! The genius behind the Google 20% time; It isn’t the time
Jan 20

Why I often prefer Prototype too

Ajax, Tech, Web Frameworks with tags: Add comments

protofun

Picture via Dunechaser

I still get asked “what Ajax framework should I use?” frequently indeed. I think that people feel that with my Ajaxian postings I have seen every framework in the world and will have a magic feel for things.

I dread these questions, as context is king for making the decision, and “feel” is a major part of it too. The various frameworks have in many ways come closer together over the years, so making the choice is harder, but also maybe not as big a deal as it once was.

That being said, I really enjoyed Glenn Vanderburg talk about why he prefers Prototype to jQuery. This is the kind of subject that is asking for trouble and foaming at the mouth from people on various camps. Glenn has the kind of nature, wisdom, and touch that makes it hard to think that way. He gives thoughtful points and isn’t trying to cause a stir.

These days, without any real context (e.g. skills on the team, what the project does) I kinda think:

  • jQuery is fantastic for taking a website and making it dynamic. Easy. elegant. Beautiful. If I was a designer doing a rich site I would stop here.
  • Dojo is fantastic for building a large scale application that will do a lot, and end up with a ton of JavaScript. Everything you need will be found there. This isn’t to say that Dojo can’t be used on the small anymore. The new core is small and fast and good.

Prototype, for me, fits in between these worlds. It is small enough to feel small (not a huge library to learn) yet large enough that I don’t jump out into creating a lot of my own code.

On a recent jQuery project that grew fairly big and I found myself surprised that the core didn’t have certain methods and features. Much of it was small things (one example I remember is array utilities). I would find myself looking around for plugins, wondering which ones are good, and generally having a little bit of a tough time. Then there is a the type system. For something that isn’t strapping on a bit of code to the web site, I actually like Class.extend and the like. With jQuery I would use Traits or Base or something which is fine…. but not just there in the same way.

I get used to myArray.last() and having the convenience methods available to me directly on the objects, even if the puritan in me feels a little strange. Just as Ruby “felt right” to me. Prototype does too (duh, since its heritage). A blend of purity and pragmatism. More often than not Prototype surprises me “oh, wow, it has that function already!” On another recent project that got converted to Prototype, I was able to delete a LOT of code. Utility classes went away. Libraries went away. There is nothing better than the feeling of deleting code. Am I right? :)

So, I agree with Glenn. For me, Prototype is the right balance for many of my projects. I still enjoy playing and using others when the project calls for them, and I am ignoring the huge number of other great frameworks (YUI, GWT, MooTools, Ext, SproutCore, Cappucino, man I could go on forever here).

9 Responses to “Why I often prefer Prototype too”

  1. Adam Says:

    If Prototype didn’t try to impose Ruby programming paradigms on JavaScript, it would be fine. To me it does the same thing as if I had something that let me write my ruby programs using ObjectiveC.

  2. James MacFarlane Says:

    I agree with Dion’s path of discovery regarding Prototype. There are a lot of handy tools packed in there and there are always more tidbits to find. It has saved me countless hours of work.

    Sadly, I think Prototype is losing the popularity battle. For example, over at StackOverflow.com, there are over 1000 jQuery posts, and under 100 for Prototype. While I, and others, continue with our efforts to nurture the Prototype user community, having someone like MS jump on the jQuery bandwagon sways a lot of developers in that direction.

    Prototype’s early success really helped move the technology forward. What is needed now is someone big to bolster Prototype’s position in the marketplace.

  3. Nicolas Says:

    Sometimes a big community isn’t that good.
    In a big community you’ll have the advantage of beeing able to find more plugins and extensions and stuff like that, that’s for sure, but I doubt that the quality of those extensions will always be that good.
    I like small communities of “clever” people.
    For example, the Mootools community isn’t very big, but the Core and More builds of their framework are very carefully coded, with elegant and readable code.
    They have an excelent balance between imperative, OO and functional programming paradigms.
    They have a well thought Class object, that allows extension and implementation (something like multiple-inheritance).
    A good OO design (Fx.Base, Fx.CSS, etc).
    Very handy utility functions ($extend, $H, $merge, $empty, $lambda, etc).
    And a modular code (you can make your own build).

    Anyway, that’s the library I feel most comfortable with.

  4. jamieorc Says:

    I was thinking recently about Prototype and jQuery. My impression is this: Prototype is heavily object-centric, so when you’re dealing with objects themselves, it has wonderful methods available. jQuery is DOM-centric, so dealing with the DOM is a breeze in jQuery. Now, let’s get Prototype’s methods into jQuery and we’ll have a perfect world. ;-)

  5. sean green Says:

    Well summed up, I totally agree. But with the support and momentum behind jQuery how can you recommend Prototype for a new project?

  6. Rey Bango Says:

    @Nicolas: In some cases you’re right. Luckily, we’ve had a ton of success in attracting extremely sharp people to the jQuery community. In addition to that, we have one of the most supportive and accepting communities around. We’re more than willing to work with people that may just be starting out in their client-side experience and help them through many of the hurdles found in JS development. The same can’t be said for all frameworks, which adds to the attraction of the jQuery project.

    @sean: The fact that there are lib choices is a good thing as it allows developers to use the best tools for their specific needs. One of the things that we’ve really pushed within the jQuery project is ensuring that we play nice with other libs and we’ve worked closely with the Prototype team to make sure of this. We realize that jQuery doesn’t fit the bill for all developers and it’s important for us to not impede a developer’s need to use another lib.

    Rey – jQuery Project

  7. Patrick Wallace Says:

    I am shocked and surprised that anyone would care what Microsoft is supporting. In fact, from my perspective, that means that JQuery has to be difficult to use because the underlying Microsoftian philosophy is that you are an idiot and we have to hold your hands every step of the way lest you fall and bump your nose. When I hear Microsoft, I turn and go the other way.

  8. Joe Chung Says:

    Try being open-minded, Patrick. Lots of people are using jQuery, not just Microsoft.

  9. Bryan J Swift Says:

    @Patrick it’s a little weird for me to defend jQuery but not only is Microsoft’s association with jQuery recent but they are not the controlling interest in the project.

    Regarding the content of the actual post, I’ve arrived at a pretty similar conclusion except with MooTools substituted for Prototype. Maybe it has something to do with my Java and classical inheritance background but writing MooTools code just feels right. However, I have definitely learned to apply JavaScript libraries as required by the task at hand and not just to have them.

    Also, thanks for the cauldron of awesome that is Ajaxian.

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: Type in the word 'ajax'