Live data from Hacker News

JQuery » jQuery UI v1.5 Released, Focus on Consistent API and Effects

jquery.com

1–10 of 16 posts

Re: JQuery » jQuery UI v1.5 Released, Focus on Consistent API and Effects

#3

I haven't had the chance to use jQuery, how does it compare to other JavaScript libraries such as MooTools or Prototype?

Having had the chance to use MooTool and Prototype. I find jQuery the most expressive and matches my way of thinking. Granted it has it's roots in Prototype. But Prototype was never this fun to use and develop in. You just grab something from the DOM and manipulate all you like. A very lovely API.

Re: JQuery » jQuery UI v1.5 Released, Focus on Consistent API and Effects

#4

I haven't had the chance to use jQuery, how does it compare to other JavaScript libraries such as MooTools or Prototype?

I've used prototype and ExtJS extensively and am now giving jquery a try. From what I can see so far the structuring around the jQuery object makes it much easier for developers to do progressive enhancement as default rather than creating functionality that works only with JS enabled.

Re: JQuery » jQuery UI v1.5 Released, Focus on Consistent API and Effects

#6
post #5

# $(”div”).draggable() creates a draggable # $(”div”).draggable(”destroy”) destroys it Am I missing something here, or is that an extremely ugly design choice? Passing strings into functions to specify what function you want? eugh

It's called message passing. It used to be part of the commonly accepted definition of OO.

Re: JQuery » jQuery UI v1.5 Released, Focus on Consistent API and Effects

#8
post #5

# $(”div”).draggable() creates a draggable # $(”div”).draggable(”destroy”) destroys it Am I missing something here, or is that an extremely ugly design choice? Passing strings into functions to specify what function you want? eugh

I think they ended up having to do that because of jQuery's chaining support. Most of jQuery's functionality lives in a single namespace (jQuery.fn) which means you can chain method calls together like this:

jQuery('div:first').addClass('hello').text('Hello World').draggable().css('color', 'red');

If a plugin needs three or four methods, that's three or four extra functions on the one object - which ends up looking quite ugly:

jQuery('blah').draggable({options}).destroyDraggable()

The message passing idiom lets them add just one method to the jQuery.fn namespace that can cover a full range of different actions. I think it's a pretty clever pragmatic solution.

Re: JQuery » jQuery UI v1.5 Released, Focus on Consistent API and Effects

#9

I haven't had the chance to use jQuery, how does it compare to other JavaScript libraries such as MooTools or Prototype?

One big difference is that both Prototype and mooTools make modifications to the built-in types (extra Array methods etc). jQuery (and Dojo and YUI) explicitly avoids doing this for compatibility reasons. It's no coincidence that mooTools and Prototype are the only two big libraries that can't co-exist on a single page.

The interesting thing about jQuery is its focus - it almost exclusively works to improve the interaction between JavaScript and HTML. DOM manipulation is more convenient in jQuery than any other library, and the other library features build on top of that core ideal.

mooTools and Prototype attempt to make improvements to the JavaScript language. jQuery tends to play along with the language - it supports a functional style of programming using lots of closures (while you can avoid them if you really want to I find jQuery code with closures flows really well).

Re: JQuery » jQuery UI v1.5 Released, Focus on Consistent API and Effects

#10
post #5

# $(”div”).draggable() creates a draggable # $(”div”).draggable(”destroy”) destroys it Am I missing something here, or is that an extremely ugly design choice? Passing strings into functions to specify what function you want? eugh

The "sortables" have been using these arguments, I was a bit confused by them when I read the documentation, but now it seems okay.
Post reply on HN