views:

719

answers:

7

I'm confused about jQuery.

On one hand it is shipped with the Microsoft MVC library, which I respect as a well thought-out library that I enjoy using.

On the other hand, I was recently pointed in the direction of this post in comp.lang.javascript in which the author has very few kind words to say of jQuery (and, apparently several other similar libraries), and is kind/brave enough to provide his own library.

What's your take on the current state of jQuery, and other such JS libraries?

+3  A: 

Well, in my opinion jQuery is a very good an well thought out library, that has very few namespace collisions and generally is within the spirit of JavaScript as a language.

Ramuns Usovs
+14  A: 

I'm not a JS developer, but put it like this:

Someone is critical of a widely used library and at the same time promoting their own library?

Call me cynical, but given the inherent conflict of interest I'd look for another opinion or 2 before taking their word as the definitive answer.

Glen
*especially* when said opinion is a bunch of coding style quibbles interspersed with "so and so is the stupidest stupid that ever did stupid" type statements.
ceejayoz
*especially* when the thread rapidly devolves into "learn to speak english" and other insults
annakata
+1  A: 

jQuery is a real timesaver, and has some great features. I wouldn't let this guy put you off too much. Have a go, and draw your own conclusions.

James L
Well, I am fairly thoroughly "having a go". jQuery serves us very well, but we have run into issues with Konqueror that make me worry about the graceful degradation side of things.
spender
/smack, `progressive enhancement`
garrow
Yes. Konqueror is not a supported browser, and I've seen jQuery fail in that browser. That's really something to think about with jQuery--can you live with the list of supported browsers? I've noticed trouble with various mobile browsers as well. IIRC, the click down event does not happen until click up (when both are fired) in Mobile Safari on the iPhone. That may be mobile Safari's "fault," but jQuery isn't cleaning up after any but the supported browsers. I have to use touch events rather than click events in one case on the iPhone.
Nosredna
+11  A: 

My $.02:

jQuery has won the library wars. It just has: inclusion in MVC seals this.

And it's not the worst thing that could happen. Personally I find it's feature set and implementation superior to any of it's competitors, the animation suite of mootools withstanding, but what is most important is that it's become the lingua franca. We needed a standard to emerge.

I haven't much time for anyone who complains about the quality of an open source library - don't like it? Get involved and fix it.

Where I do have a problem with jQuery is that waaaaay too many devs for my liking are not learning JS as deeply they should. I suppose this is a similar argument to those who insist everyone should learn C++, and maybe I begin to see the point of that argument. JS by itself is an enormously powerful language, which has for years been capable of solving problems without adding a multi-K library. In my experience there's a definite jQuery effect (hallmark: "Why not use jQuery?") of invoking a sledgehammer to crack a nut.

annakata
`MVC` is just a concept that don't include jquery.The think you're referring to is `ASP.Net MVC`.Please don't mix them up.
alamar
@alamar - He isn't mixing them up. The context of this thread clearly dictates that he IS referring to Microsoft's incarnation of MVC. Pointless comment.
alex
yes I'm well aware of that, it's just shorthand given the OP - no need to be quite so literal
annakata
thanks alex, nice to know I'm not shouting from mountains :)
annakata
Oh, i see.On the other hand, it's not $.02 but rather $(.02) :)
alamar
actually, it's only $(.02) if it's negative. strike two.
Jason
+7  A: 

Hmm, I'd rather trust my years of using JQuery and the thousands of happy campers using it over some nitpicking twit who thinks he knows better. From what I could see a lot of his criticism is quite specific (like the use of Match, for example, which is totally lame) about effecincy and optimizing code, but is completely lacking the shere amount of magic needed to support the amount of browser quirks and bugs to even do a fraction of what JQuery offers. Oh, and Jquery has got years of baggage, so yes there will be some warts.

Let's look at this alternative JavaScript library. The initial page says, literary, "I hate libraries, so I created a library." Further it whinces about browser sniffing, and claims itself to only do feature sniffing. Mate, that's how a lot of them in fact do the browser sniffing. It goes on to say that getting tangled in APIs are stupid, and goes on to present its, um, API. Yeah, it's a bit silly, but I'm sure it's all for a good cause?

Digging into the actual API I'm struck by a somewhat lacking set of semantics that goes with a framework approach to the browser jungle, and it is missing the crucial part that made JQuery such a success; good selectors into the DOM. It may do the job (of which there is no documentation; what does it actually help me with? Just cross-browser DOM access, what? What else?) but I need consistancy and elegance (although this latter is somewhat subjective, of course). It's glaringly lacking of examples, demos or anything, has no obvious plugin architecture.

It may be a purists library, but unfortunately the real world is beckoning me out of the elite cloud. I'd take the whole thing with a pinch of salt (what version did he test? Did he approach the developer(s) first to ask why some things were the way they were?), and I'm remembering some wise words by none other than StackOverflow firestarter Joel, that all those little pieces of seemingly crazy or obtruse code in fact is what your system has gained of knowledge about browsers, platforms, OSes, compilers, versions, code, etc. What may look like a purists worst nightmare might, in fact, just be working code.

Oh, and reading through the comments to his initial post reveals that he is an arrogant prick who tells anybody not agreeing with him that they are useless, know nothing, incompetent and a whole lot more niceties. Classy.

Anyway, back to hacking my own Topic Maps engine instead of using someone else's. :)

AlexanderJohannesen
I don't understand what plug-ins you would want to create with David Mark's MyLibrary. I am guessing you are comparing this library with JQuery's $ object and function chaining, and the ability to add new functions that can take the current set of elements operated on by the $ object as an argument. MyLibrary has "Object Wrappers". Further, API.areFeatures allows you to check for what "plug-ins" are installed.
+2  A: 

comp.lang.javascript is full of hardcore zealots.

That's not all bad. I think the libraries have gotten better as a result of all the sniping. For example, this is from the jQuery 1.3 release notes: "No More Browser Sniffing. The final major feature of this release is one that you probably won't ever see or deal directly with but it's an important change that'll help to make jQuery last longer and with less bugs: As of 1.3, jQuery no longer uses any form of browser/userAgent sniffing internally - and is the first major JavaScript library to do so."

I'd argue that the major libraries, and especially jQuery, are now so entrenched that developers of browsers actually have to adapt to jQuery, rather than the other way around. If you release a browser that fails in common jQuery operations, people will think your browser is broken.

Nosredna
+1  A: 

That discussion had been making rounds a while back and the folks on clj have strong opinions.

Most of those criticisms are regarding the approaches taken by jQuery but as it turns out they are oblivious to the reasons why jQuery does what it does. For example Matt Kruse responded on the list

> Five seconds in, this line sticks out like a sore thumb:
> if ( typeof text !== "object" && text != null )

I mentioned this line in a recent thread on a jquery group...

> The first comparison does not need to be strict.  

The argument is that in some browsers, making it strict is actually
faster, and doesn't hurt anything. Supposing this is true, then it
makes sense to leave it as-is.

> The second comparison is obviously a waste of time.

Not true. The intent is to also catch cases where text is undefined,
and would then ==null.

and then again quite aptly on his blog:

All libraries come with a trade-off. I’ve only used jQuery extensively, but I have some knowledge and experience with others.

YUI is robust, if not verbose. It has some very smart people on it, but it hasn’t seemed to catch on as much as jQuery. When I looked at it, it felt “heavy” to me. And there are some dubious coding practices in it as well. Prototype is a beast that has been around for a long time and not one I would recommend. But it does have a lot of OO support, if that’s what you’re looking for. IMO, javascript is not OO, so I have never liked trying to force it to be. ExtJS is very slick and fancy, but it’s HUGE bloat. I don’t know what the code looks like. I do know it was going to be ported to use jQuery, but I don’t know if that happened. MooTools is a hacker’s library, and IMO it just doesn’t offer anything that jQuery doesn’t. Dojo is dead, AFAIK. I never liked it.

So, my favorite is jQuery. It has problems, and it’s far from perfect. Plugins can be hit-or-miss. The UI framework seems to be starting to come out of its infancy, but it’s still a bit too bloated for my use. I use parts of jQuery and avoid some other parts. I write most of my own plugins, and I still write a lot of “pure” non-jQuery javascript. I find that as I being to optimize a chunk of jQuery code for performance and to generalize it, the process slowly starts to filter out the jQuery! So I use jQuery to get quick things done and for convenience when I know it will work as expected, and for complex things I end up writing pure js (and saving it for reuse). In the most difficult situations, no framework will work well, IMO.

aleemb