Tapestry Training -- From The Source

Let me help you get your team up to speed in Tapestry ... fast. Visit howardlewisship.com for details on training, mentoring and support!

Monday, January 12, 2009

Comparing Prototype and jQuery

Glenn Vanderburg has written a careful treatise on why he prefers Prototype to jQuery. The thing about Glenn is that he doesn't write (or talk, or think) in terms of "feelings" or "impressions"; his thoughts are clear, and organized, and fact based, and detailed.

I looked at jQuery about two years ago; to me it seemed a little iffy, a little skewed towards web developers doing bespoke web page development, rather than the dynamic generation Tapestry is all about. That impression may or may not be accurate, but Glenn has nailed some significant differences in the design and implementation of the two frameworks, which is why Prototype comes out on top.

5 comments:

Unknown said...

I already knew JQuery when I started using Tapestry 5. And I had to learn Prototype in order to be able to write more complex components in Tapestry 5. I know I could have used JQuery, but having two Javascript libraries included in the project seemed like a bit of overkill.

In my opinion JQuery is easier to learn, requires less code to get something done, performs much better and has a huge number of useful plugins available.

It also looks like most of the world is moving towards JQuery, including huge players like Microsoft (http://www.microsoft.com/web/content.aspx?id=microsoft-adopts-open-source-jQuery-JavaScript-library).

For me, having to use Prototype is the one little annoyance I have with Tapestry 5. Pretty much everything in Tapestry is configurable, except for this.

Of course everyone has their own preference. Therefore I think it would have made sense to implement the Tapestry Javascript dependencies in plain Javascript. Then each developer could pick the framework he or she prefers or knows for their own work. That would have been a lot of extra work though.

regards,

Onno

Unknown said...

"implementing in plain JavaScript" is effectively saying "creating a Tapestry JavaScript library from scratch". I looked at jQuery and there is the possibility of moving to it in the future. I'm also going to be looking at the YUI libraries.

Unknown said...

> "implementing in plain JavaScript" is effectively saying "creating a Tapestry JavaScript library from scratch".

Hi Howard,

you're right and I fully understand that would be a lot of extra work.

But if you depend on an existing framework, pretty soon 3rd party libraries (like Chenillekit) will depend on the chosen framework as well.

This will make it harder to stay backward-compatible in the future.

If Tapestry doesn't include Prototype, then a third party library can still depend on it. The developer can choose to either use it or don't. You know beforehand that you're locking yourself into a specific framework then.

But if Tapestry includes the framework and wants to move to another framework, all 3rd party components may suddenly break because they depend on Tapestry providing Prototype. If you stick to plain Javascript, then the framework-builders cannot put the blame on Tapestry, their choice is their responsibility.

Now don't get me wrong. Tapestry 5 rocks and Prototype is still a great library. It just seems that every cool new Javascript component I see popping up on the internet is based on JQuery these days and I've seen quite a few that I would have loved to convert into a JQuery-specific Tapestry component-Library.

regards,

Onno

Unknown said...

I would propose looking at the Ext javascript library, which is written in such a way that you can swap out jQuery, prototype, or yui at will. There's a compatibility layer, which might be a little more work, but these rich libraries are not some passing fad.

fritz the cat said...

The thing about Glenn is that his thoughts are clear, and organized, and fact based, and detailed, ....
and wrong. As you can see by most of the comments to his blog post.

"I looked at jQuery about two years ago; to me it seemed a little iffy, a little skewed towards web developers doing bespoke web page development, rather than the dynamic generation Tapestry is all about. That impression may or may not be accurate,"
No, it's not accurate at all. I suspect it is all based on the fact Prototype uses the word 'Class' which make Java developers feel at home.

Javascript is not a class based language, but a prototype based one, and JQuery makes the best use
of that.

As a front end developers working on a Tapestry project I absolute hate the ideas of Java developers thinking they know best and dictating what frameworks we should or shouldn't use.