views:

2115

answers:

22

I manage a group of programmers. I do value my employees opinion but lately we've been divided as to which framework to use on web projects.

I personally favor MooTools, but some of my team seems to want to migrate to jQuery because it is more widely adopted. That by itself is not enough for me to allow a migration.

I have used both jQuery and MooTools. This particular essay tends to reflect how I feel about both frameworks. jQuery is great for DOM Manipulation, but seem to be limited to helping you do that.

Feature wise, both jQuery and MooTools allow for easy DOM Selection and Manipulation:

// jQuery
$('#someContainer div[class~=dialog]')
    .css('border', '2px solid red')
    .addClass('critical');

// MooTools
$('#someContainer div[class~=dialog]')
    .setStyle('border', '2px solid red')
    .addClass('critical');

Both jQuery and MooTools allow for easy AJAX:

// jQuery
$('#someContainer div[class~=dialog]')
     .load('/DialogContent.html');

// MooTools (Using shorthand notation, you can also use Request.HTML)
$('#someContainer div[class~=dialog]')
     .load('/DialogContent.html');

Both jQuery and MooTools allow for easy DOM Animation:

// jQuery
$('#someContainer div[class~=dialog]')
    .animate({opacity: 1}, 500);

// MooTools (Using shorthand notation, you can also use Fx.Tween).
$('#someContainer div[class~=dialog]')
    .set('tween', {duration: 500}) 
    .tween('opacity', 1);

jQuery offers the following extras:

  • Large community of supporters
  • Plugin Repository
  • Integration with Microsoft's ASP.NET and VisualStudio
  • Used by Microsoft, Google and others

MooTools offers the following extras:

  • Object Oriented Framework with Classic OOP emulation for JS
  • Extended native objects
  • Higher consistency between browsers for native functions support.
  • More easy code reuse
  • Used by The World Wide Web Consortium, Palm and others.

Given that, it seems that MooTools does everything jQuery does and more (some things I cannot do in jQuery and I can in MooTools) but jQuery has a smaller learning curve.

So the question is, why did you or your team choose jQuery over another JavaScript framework?

Note: While I know and admit jQuery is a great framework, there are other options around and I'm trying to take a decision as to why jQuery should be our choice versus what we use right now (MooTools)?

+8  A: 

jQuery gives you access to crisp and concise functional programming methods. Since the release of method chaining in (LINQ) in C# 3.0 this works very well for .NET programmers. So the flow from one language to the next is easy. To be able to query the DOM for an object, or a list of objects, works much better for us. It is jQuery's selection power first that makes it so attractive, then the extendability of it, and of course all the built in features that come with it are nice. Also, the community behind is wonderful in that I first look to see if someone else did something and then attempt to do it myself if a solution was not found. And last...but certainly not least...the fact that Microsoft is going to include in in Visual Studio 10 and support it is great. Moo Tools, Prototype, etc. just can't compete with all of the above.

Andrew Siemer
The community behind jQuery is great (and the fact that it is integrated in VS too), I admit, but MooTools has the same selection capabilities as jQuery.
Andrew Moore
A: 

For one thing, that's not all it does. There are quite a few other features as well. For another, not everyone uses it. But I don't want to interrupt a good rant.

Matthew Flaschen
It's not a rant, I've used both, seen the power of jQuery. But there is nothing I can do in jQuery that I can't do in MooTools, while the opposite isn't true. I don't dislike jQuery, I just don't exactly understand why it is so widely adopted.
Andrew Moore
+5  A: 

jQuery, like any framework, does what it does and if it doesn't fit your needs you should use something else. I don't use jQuery to do complicated programming in javascript, I use it because it makes DOM manipulation and CSS3 style stuff simple and 95% of the time that is what I need.

jarrett
+43  A: 

Personally, jQuery does exactly what I need.

I try to do most of my stuff in my server-side code, which is well structured: it has proper OOP, layers, and an MVC architecture. When I need to do something with Javascript, I have found (so far) that jQuery has what I need. Frankly, that falls into three categories:

  • Simple DOM manipulation, usually showing/hiding stuff without hitting the server.
  • Ajax calls, nuff said.
  • UI perks, including modal popups, animations, fading transitions from/to hidden/shown. I am a hardcore backend coding guy, and I suck at UI stuff. I really like that jQuery lets me programmatically make stuff that looks appealing.

On top of that, the jQuery plugin library is huge, and I've found quite a few libraries that simplify my client-side work. Good stuff.

MooTools introduces OO thinking, which is nice, but not what I need. I want to keep my structuredness all on the backend, and not have to introduce that thinking to my client-side code. To me, client-side code is a very small piece of the emphasis and thinking about it from a Class-point-of-view is way overkill, and way more work. I feel like I'd be building two applications instead of one if I were to use what I'd think would be best practices for MooToools.

I think that sums up why its so popular, especially around here. By and large, we're backend code-y type people, and jQuery lets us make an appealing UI programmatically, and lets us focus on our backend core.

JoshJordan
+1 on the simple UI perks point -- I hate UI programming, and being able to include a plugin or two, add a few lines of JS, and turn a simple div with a form into a modal popup is just *awesome*
Jonathan
A quick question: what does showing/hiding elements have to do with the server (see "Simple DOM manipulation")?
Steve Harrison
@Steve: In ye olde days, if you wanted to change the page (add/remove/modify elements), you had to request a whole new page from the server, telling it "that or that element has changed". That was cumbersome, as you had to keep additional state of the page on the server. Later, starting with IE4 (shudder), you could manipulate the DOM - that eliminated the need to go to server for every change, but it was cumbersome. Then came jQuery, which made it really simple.
Piskvor
Note to self: constructive answers in opinionated threads still get you downvotes :/
JoshJordan
I am not the one who downvoted you. Actually, I upvoted. I'm looking for the most opinions possible.
Andrew Moore
@Andrew Moore: Appreciated :) I'm surprised to have gotten 3 downvotes here - I wish people would post their reasoning so I could better flesh out the answer. I hope this helped, and I would definitely be interested in reading your thoughts on what I posted. Criticism of a dominant (or even not dominant) paradigm is a good thing!
JoshJordan
My most upvoted answer is also by far my most downvoted. It still stands at 14 votes on the balance. Some people just hate when you praise a technology they don't like or mention flaws in one they do, and they let that hate out by voting.
Chuck
+1 for UI Perks explanation... I´m exactly like you in this matter
Luiz Damim
Good point, if your app is not very interactive, jquery is ok, because you can keep complicated logic on the server and the structured approach on the client is good enough and easy to follow. However, any large client side project quickly becomes unbearable without a proper OO/MVC structure. If you want widgets like trees, grids, menus, I say hire real client side devs and separate your coding so that client and server code can be agnostic of each other. A great benefit of this is that your client will talk to the server through web services, that could be made available to customers!
Juan Mendes
+1  A: 

What I DON'T need in JavaScript is definetely OOP and some ugly object emulation.

Last time I checked MooTools (maybe 1,5 years ago :-), it had browser incompatibilities with manipulating multiple select.

So jQuery is completely looks OK to me.

Sergei
+5  A: 

I have not looked at MooTools in a while either. But here are my points for JQuery:

  1. Consistent programming model (there is a JQuery way that works)
  2. Excellent documentation. When I started JQuery had the best documentation out there.
  3. Extensive 3rd party plugings
  4. Microsoft support -- I am an asp.net developer, this helps ease clients minds. Plus it ships with my tools now.
  5. Lots of getting started guides.
  6. JQuery's website looks nicer than MooTool's web site. I'm sorry that matters, but it does. Remember, many of these tools need to appeal to designers as well as developers.
Chris Brandsma
+10  A: 

I'm not a fan of imposing classical object orientation onto JavaScript. There are so many ways to do it that one JavaScript Programmer might be using Base2 for OO, while another uses Prototype or Moo or JS.Class or Joose. Resig deliberately decided not to add classes to jQuery, and that has encouraged people to find more native JavaScript ways to solve problems.

As a result, it's easier for me to read JavaScript other jQuery writers write, and to write jQuery code that's easier for others to read. I typically don't try to emulate class OOP in JavaScript. Instead, I create objects on the fly and pass them around, and I have lots of arrays of objects. It's so easy to understand that I've even found myself carrying that thinking over to OOP languages!

For all I know Moo may very well have caught up with jQuery or surpassed it. But I can't spend my time tracking the 6 or 7 great JavaScript libraries to see which horse is ahead.

I think it's was largely a matter of timing. When masses of programmers jumped into AJAX, jQuery was the hot new cool thing that solved their problems.

Other libraries have largely caught up. YUI, ExtJS, Dojo, Moo--they're all great. But I can't use them all.

I work hard enough trying to figure out the ramifications of the new features of the library I do use. For instance. jQuery added Live events as of 1.3. This actually let me cut code from many pages. Does Moo offer that now too, and how am I supposed to know it happened, if it did?

I'm sure Moo is awesome. I'd love to have the time to learn it. But have you looked at Dojo? I had to use it on one project and found that it had pulled in most of the great ideas from jQuery as well. And it has pubsub and good support for Comet.

I sympathize with you. But your programmers are talking sense. Learning jQuery is good for their careers, and there are more books, examples, and fellow programmers to ask for help if they use jQuery.

If you decide to go jQuery after all, think hard before deciding whether to tack on an OO library. There are some cool ones (like JS.Class or Joose), but taking that step means isolating yourself from how most JavaScript programmers code.

Nosredna
My priority is not my employees careers but customer satisfaction. We are currently using jQuery on three (3) projects right now and it seems that the javascript on those projects are harder to maintain compared to MooTools projects of same complexity.
Andrew Moore
Also, MooTools doesn't impose classical OO onto JavaScript. It is a feature you may use or completely dismiss. Actually, MooTools OO implementation brings the best of prototypial inheritence and classical inheritence together!
Andrew Moore
If you have in-house experience that shows that your MooTools projects go better than your jQuery projects, then you have a great way to make your case. Can you tell why the jQuery projects go sour? Is the the lack of the OOP model?
Nosredna
@Andrew, I'm not doubting that. Just saying that when I see classes in JavaScript, it trips me up because there are so many subtle variations in the implementations. If you stick to ONE, I'm sure you're fine. But what percentage of JavaScript projects use MOO OOP? It's a small percentage, I'd bet. I'm not saying there's anything wrong with it. I just steer clear of it because it's no part of the language--it's another thing to learn that's only going to be in some small percentage of the JS projects I encounter.
Nosredna
Actually, jQuery projects went sour because of the way everything is done through the jQuery object (or $ if you are running without noConflict). We also ended up with chains of about 75 functions [but I need to blame that on my programmers].
Andrew Moore
Wow! They got chain happy!
Nosredna
Yes they did! Had to impose a limit of no more than 10 chained elements. But now, they could do the exact same thing with MooTools so I don't blame jQuery for that.
Andrew Moore
I'm going to give MooTools a try. But I'm waiting for 2.0. Doing without event delegation would be a backwards step for me, and MooTools has event delegation coming in 2.0..
Nosredna
Mootools 1.2.X has event delegation: http://www.mootorial.com/wiki/mootorial/04-element/01-element.event
Andrew Moore
According to this http://www.clientcide.com/code-releases/clientcide-202-event-delegation-updated-for-mootools-20-compatibility/ it's not built into MooTools until 2.0.
Nosredna
+4  A: 

I choose to use jQuery as our default UI library precisely because it does not extend or otherwise monkeypatch native objects, unlike prototype.js or mootools. Kick in the documentation angle and there really is no question as to which framework to use.

Wyatt Barnett
I just looked at MooTools's site. The augmentation of native types makes me nervous, but I like how they did hashes. http://mootools.net/docs/core/Native/Hash
Nosredna
A: 

I have to second a lot of the answers...great documentation and community support is crucial. I used to hate js programming and would avoid it like the plauge, but now I've completely embraced it because of jquery and the quick learning curve.

It's not always about who has the best technology!

ScottE
A: 

You are gimping your team. They should be managing you.

We compared both so far, and I'm sorry to say, but "it's more widely adopted" has never been a good argument to justify a framework choice. Plus, we did try it, and it's been a mess so far.
Andrew Moore
@Andre Moore: Yes, it is. Widely more adopted means more tested, more documentation, more tutorials, more help, more plugins, etc. Not saying that is the case for jQuery nor denying it. Just saying widely adopted IS a good reason.
luiscubal
+4  A: 

JS frameworks are so much alike, anyway. If you've been working with mootools for some time, stick to it. Knowing your framework is much more important than choosing one because of this or that.

In my opinion, mootools is better for advanced javascript programmers, while jquery is better for non-javascript programmers. That's what I think after reading both documentations, mind you, I didn't use any of them. jQuery lacks support for the core of javascript, function binding, object cloning, thread stacking, to name a few.

Alsciende
+1  A: 

Not only is jQuery a nice library, but its creator, John Resig, also has some street cred as the author of Pro Javascript Techniques.

We have 2-3 copies of this book around our office.

jQuery is small (intentionally so) but can have functionality added to it through plugins.

R. Bemrose
+1  A: 

The thing that made my experience with mootools a rather unpleasant one was the documentation and the stability of the API: I simply wasn't able to find a documentation that related to the mootools-Version in use. Won't be that much of a problem if the API defined was stable. But due to some functions that disappeared in the newer Version (a ChangeLog was found after hours of searching) a migration wasn't possible either. After that, mootools was out of the race for me.

Like many others, I don't want to introduce class-based OOP into simple user-interface manipulations. Thats what I use jQuery for: not so complicated user-interface stuff. When I have to build rich browser-side applications, I'd always switch to the big solutions (ExtJS, YUI, qooxdoo) that offer a variety of ready to use widgets.

marvesmith
+1  A: 

Larger User Community and more wide-spread adoption makes a big difference when comparing tools/libraries that offer similar functionality and concepts. Larger community means more support, more examples, more good ideas, and more reusable code snippets, which is especially important when you're working on a rare scenario -- more likely someone else has encountered it before.

Secondly, in benchmarks I've seen, jQuery is faster than MooTools.

I also really like their emphasis on keeping a small core and adding functionality through plugins. Prevents the core library from getting really big and unwieldy.

I've never used MooTools personally but I have no doubt that its a fantastic library that offers some acceptable equivalent to most any jQuery feature or concept, but point #1 takes the cake for me.

Brian Lacy
About the speed claim: http://www.domassistant.com/slickspeed/
Andrew Moore
I tested in Chrome and Firefox and MooTools did much worse than jQuery.
Nosredna
Over multiple tests in all 5 major browsers on several machines, my average result tends to be that jQuery and MooTools perform comparably, but with a noticeable edge in jQuery's favor. Prototype lags quite significantly, while YUI is a clear and tragic loser in ALL tests.At any rate, these tests seem to indicate that performance should NOT be your primary concern when choosing between the jQuery and MooTools, as MooTools holds its own well enough.Thanks for the nifty link Andrew!
Brian Lacy
+24  A: 

That's an odd question... I get the impression that...

  1. you are very familiar with mootools and take full advantage of its OOP model, making your code easier to manage and support already.
  2. you realise that jQuery's purpose is somewhat different and tweaked towards DOM manipulation and AJAX and that mootools does do everything jQuery does AND then some.
  3. sounds as if you do not need to be using much in the way of 3-rd party plugins which makes the points of jQuery's popularity and support a bit less important.

bottom line, is it the hype? jQuery is turning into one of these magical marketing buzzwords like 'AJAX', .NET and web 2.0 - which is great for them but why do you need to justify staying with the framework that works so well for you? there's also the business considerations which I imagine will cover things like:

  • framework longevity, or is mootools likely to go away in the face of the ever growing jQuery--very doubtful, seeing as they just released 1.3 beta 1 and have 2.0 is in the pipelines for release by the end of the year.
  • cost of staff and their training (i imagine finding mootools programmers will be more difficult than these that slap jquery on their C.V / resume).
  • time (and cost) taken to maintain and extend your systems under each framework given your resources.

both frameworks are great but i believe your interests are best served in staying with mootools.

Dimitar Christoff
That's the decision I took too. I ended up saying with Mootools finally. Fact is, I've seen to many developers pass that put jQuery on their resume and had absolutely no idea what document.getElementById() did, and in fact and very little cue of what jQuery was in general other than 'it's the thing with the $ sign'. That's the danger with buzzword technologies. People starts putting it in resumes even if they just have a vague idea of what it is.
Andrew Moore
In light of recent development, you could also have the best of both worlds. Just look what wonderful piece of magic mootools core developer Ryan Florence implemented just a while back: http://ryanflorence.com/object-oriented-jquery-with-mootools-pigs-take-flight/
plouh
+2  A: 

You kinda say it yourself:

Given that, it seems that MooTools does everything jQuery does and more (some things I cannot do in jQuery and I can in MooTools) but jQuery has a smaller learning curve.

Most of the extra stuff that MooTools does is stuff that we just don't need.

As you say yourself jQuery is easier to learn, which is actually more important for most people when choosing a framework.

Keith
+5  A: 

YAGNI.

Yes, it's kinda out of place here, but that's the main reason jQuery has a larger base than MooTools. All those extras MooTools brings to the table are nice, but YAGNI.

It's not about best, it's about satisficing -- finding the adequate solution to the problem at hand. jQuery is easy to use, its primary aim is DOM manipulation. Since 95% of the people picking up javascript are doing so just to manipulate the DOM, there's no point in going through the longer MooTools learning curve. MooTools simply doesn't bring anything to the table for them that jQuery doesn't deliver with less effort.

MooTools demands more from you before you use it, jQuery lets you throw something together quickly. If you start writing large, heavy-duty js apps, you might run into some of the drawbacks of that approach, but again 95% of the folks writing js don't do that, so those things don't matter to them. They use a server-side language for the heavy-lifting and javascript for the DOM.

For that matter, they may not matter to your team, either. To take you through the lists, point by point (jQuery first):

Large community of supporters -- only slightly relevant to the project. Of more relevance to the team personally, because it speaks to life after you. If misfortune strikes (please, God, no) and your firm is gone, jQuery gets them more jobs than MooTools.

Plugin Repository -- very relevant, as it helps keep from reinventing the wheel.

Integration with Microsoft's ASP.NET and VisualStudio -- very relevant if you're a .NET shop. In fact, this alone should be the reason to switch if you do .NET.

Used by Microsoft, Google and others -- who cares?

Now for the MooTools list:

Object Oriented Framework with Classic OOP emulation for JS -- irrelevant, unless the nature of your projects makes that a plus. I don't know what you're building, but for web shops, this is only rarely relevant. Most web shops don't have enough code to make this a plus.

Extended native objects -- again irrelevant for most web shops

Higher consistency between browsers for native functions support. -- Relevant

More easy code reuse -- This conflicts a little with the jQuery advantage of a large repository. A large repository by itself speaks to reusing code. I suspect you're using a narrow definition of code reuse, here, that may not be relevant. I've reused a lot of the jQuery code I've built, as well as MT code.

Used by The World Wide Web Consortium, Palm and others. -- Irrelevant. The only relevance about who else is using what is if you're wanting a job there. There's more relevance in how many shops use it than in any particular shop using it.

There is no One True Way to approach javascript coding. Get your bias out of the way, and sit down with your team and get their bias out of the way as well. Talk turkey about the specific types of projects you're undertaking (and want to undertake) and the strengths of each library as applied to those cases. (How they might handle other cases doesn't matter, because those other cases don't exist.) You should arrive at a consensus from that.

(YAGNI = You Ain't Gonna Need It, if I need to explain it.)

Arlen
I don't understand why you say MooTools asks more out of you to produce a result. You don't need to use OOP with MooTools if you don't want to. By code reuse, I don't mean Copy-Paste. I mean building for example a PointedTips Class which can then be applied to elements by doing something like new PointedTips($('#myElement')) [jQuery has plugins instead: $('#myElement').PointedTips()].
Andrew Moore
And MooTools has a third party plugin for integration with VS. I should of said 'Out Of The Box integration'. But we are a PHP box.
Andrew Moore
+1  A: 

Mootools, does not function properly or does not function at all when using jquery prototype etc. Agreed there is absolutely no reason to use them simultaneously, but once in a while they do land up on the same page (ex. plugins, slideshows, widgets etc) and things stop working.

That in itself is unacceptable. So all props for jquery to not create unnecessary headaches!

**@Dheer:** That is no longer true with the newest version, and anyway, there is absolutely no reason why one would use multiple JavaScript framework other than lack of planning.
Andrew Moore
A: 

http://jqueryvsmootools.com/

letronje
I already link to that essay in my question.
Andrew Moore
+1  A: 

Another reason: It's easier to sell jquery to management. Doing internal, asp.net based developement in a corporate environment the magic words are "it's supported by Visual Studio".

chris
For which I don't really care as I'm the management, and we are not developing an ASP.NET.
Andrew Moore
You asked why jQuery was more widely adopted, not why you prefer it.
chris
+6  A: 

I've been asking myself this very same question for a while now, by means of just trying to wrap my head around the argument. And with ever discussion I read, the overwhelming response has been "More widely adopted - therefore better".

I am one who uses both extensively. JQuery at work (adopted because it was "more widely adopted") and Mootools on personal projects. As a result, I constantly find myself feeling crippled when using JQuery; Be it with JSON support, element creation, event handling... and so on. At work, I find myself writing chains 75 events long... and I feel dirty as a result.

My main overall beef with JQuery though, is that there's a lack of consistency or practice where plug-ins and 3rd party developers are concerned. The anecdotal "More plug-ins are available" really doesn't help me when there's no consistency between the plug-ins, structurally or otherwise. It took me several weeks to learn the "accepted" plug-in model, and even then, I've adapted my own pragmatic style into it, as I find error and inefficiency within the current structures. It can be said that it's a 'Pro' that anyone can jump in and start JQuerying it up. However, I am more inclined to call that a 'Con', in that you will see 30 different ways to accomplish something, and it's difficult to pin an accepted standard.

So what does it mean to "Know JQuery", Does it mean you know how to rock a little .hide().show().fadeIn().fadeOut()?

When I have to get gangster on my JS at work, I miss me some Mootools. I mean no Native JSON support? C'mon......

In response to the "Widely adopted" response, we all know OSCommerce is the most "Widely Adopted" shopping cart, and we all know what a pile of shit that is. I'm in no way comparing JQuery to OSCommerce. I'm simply pointing out the faulty of "Widely Adopted" response.

As for plugins, the App store for apple has what... 100k apps? 50,000 are fart apps. Sure there's a lot of plugins to JQuery, but the ratio of trash to worth-while is great.

Chase
A: 

Why did people start using fax machines? At a certain point the benefit increases exponentially.

Scott
It's not a question about whether or not I should use fax machines, I've seen the power of fax machines and understand the need for them. I'm asking why are HP fax machines more popular than Samsung's fax machines when Samsung's has all the features of HP's and them some.
Andrew Moore
@Andrew Moore: Great Analogy.
Chase