Prototype VS jQuery - Strengths and Weaknesses?

JqueryPrototypejsRia

Jquery Problem Overview


I don't want to open another "Yet Another Js VS Js" thread.

I guess, in the end Prototype and jQuery are both JS and have almost the same methods and functions and need almost the same lines of code for identical tasks.

For a real Rich Internet Application, what are the real strengths and what the weaknesses in Prototype vs. jQuery?

Jquery Solutions


Solution 1 - Jquery

I initially liked the idea of Prototype's extending elements with new or modified methods.

However, I've discovered a number of reasons this is a bad thing (TM)

Do some googling and you'll probably find some other reasons, but the primary reason is that Prototype cannot be guaranteed to "play nice" with other frameworks or libraries, as other libraries expect the behaviour of elements and methods to be "standard", and due to the things Prototype does, you may find a number of things that are broken by it.

The most recent example I discovered was Prototype screwing with JSON and stringify. I was using EasyXDM, and it simply did not work in some cases where the prototype.js library was loaded. As I was writing a framework to be used by others, and thus did not have control over the content of the page, I needed to create and do everything in an IFRAME in order to ensure things such as prototype.js did not play havoc with what I was trying to do.

...so jQuery wins hands-down for me, because I just don't think its right for a framework to automatically screw with the standard behaviour of the DOM and javascript. YOU should be in control of these things, Prototype takes some of this control away from you....

Solution 2 - Jquery

I use jQuery over prototype as well, just look at the top of this page for why:

jquery tagged questions : 531,752
prototype tagged question : 2,465
Updated 9/22/2014, on 12/14/2011 jQuery - 135,641 / prototype - 2,327

jQuery is very terse, concise code. Prototype I find much more verbose, though often equivalent in many areas for functionality. However if you need help getting started, you want the larger community. More support, more of the same questions you'll have already out there answered and easy to google, and more plug-ins, code you're probably looking for to do something...already written.

For the same reasons, the larger the community, the more code, the more complex code, meaning that the simple stuff has been written and many complicated situations solved as well, chances are if you're writing a very rich application you're going to run into some pretty complicated questions or situations...there are more resources out there to help you handle this.

Again...for the same community size reason, more deficiencies in the framework have been found and the gaps filled, because a larger community was scrutinizing it. This means that when you come across a problem, chances are someone else did too, and some method or option was added to keep you moving, not jammed up because you hit something the framework couldn't do.

Solution 3 - Jquery

I'm currently rewriting large blocks off an application to move from Prototype to jQuery. Why? Plugins, plugins, plugins, particularly UI widgets. Prototype UI elements are rather fragmented and very piecemeal, while jQuery has a very rich set of "standard" elements.

Solution 4 - Jquery

JQuery was built to make adding fancy effects to pages easy. It has achieved a 100% success.

Since adding animations and occasional ajax calls is what people usually need and demand from a Javascript library, JQuery has a large community. The JQuery motto is "I'll add some sparkle, and get out of the way", which is exactly what we, developers, often need.

Nevertheless Prototype excels at most other use-cases. It has a stable framework for class-based OOP (uniformly solving problems like inheriting constructors), and a good set of general use abstractions to deal with data.

Solution 5 - Jquery

I chose jQuery over Prototype because:

  • the "do more, write less..."
  • the jQuery community is bigger (hence, more plugins and resources)

Solution 6 - Jquery

I have used both and like both. It really depends on your project's requirements. To me, it seems like both platforms came from 2 different directions because of 2 different requirements. They were both created out of the need to solve programming issues to help build websites/applications faster and better.

When making websites quickly, with a standard tool box of tricks, jquery and its library is great. No sense in reinventing the wheel. I do, however, run into the odd browser version issue when my tool/trick is not working and it always happens that it is the client who has that specific version. Usually happens when a browser version is released/updated. So, I then have to go fetch the new release of that jquery library file to update all my sites, that is if the community has already noticed and resolved said issue. This is my only peeve because I do not have the time to figure it out myself. It does not happen often but does happen.

When working on more complex web projects, maybe a network of sites supported with back-end APIs, then I find prototype is great. I take full advantage of server side OO coding and was very pleased that I can do the same with Prototype. I feel like I have more "control" over my applications and can fix things quickly as I am the author. I do hear what people are saying about overhead, DOMs extended, etc. but I have not run into any majors issues (knock on wood). Also, the whole issue to not having a 'for each' statement is not much of an problem when I can just as easily iterate the same variable with .each(function(){},..) and with a little more control.

So, each one has its place and you have to pick your own drug.

Like,

Solution 7 - Jquery

Neither is the "best". It's all depends. Try them both and see which one you like more. I personally use JQuery due to ease-of-use over prototype which is rather advanced and has longer learning curve.

Have a look at:

Prototype vs JQuery (at Ajaxian)

Solution 8 - Jquery

This is another interesting article about jQuery and MooTools (MooTools and Prototype are mostly interchangeable, at least within the context of this debate) : http://jqueryvsmootools.com/

Solution 9 - Jquery

jQuery uses CSS-style selectors and filters which are based on CSS syntax. From a design standpoint, this has a lot of benefits. I'm very fond of and proficient at CSS, so jQuery feels right at home for me personally. If you are looking for a syntax so your all-around coding experience is more pleasant, and you're a big fan of/proficient at CSS, it's safe to say you will prefer jQuery over the alternatives. I took a basic course in Prototype and I was bored to tears. I've just completed "The Essentials of jQuery" over at Lynda's and I absolutely love it, because of it's close relationship with CSS. I've been programming in vanilla JavaScript for about 10 years and I have always found it to be extremely dry; and to me it's code overkill (not much bang for the buck). Though it's been very useful to me over the years. From what I've seen so far, jQuery is what JavaScript SHOULD HAVE been from day one. But then again, it takes a lot of time, testing, and effort to improve things. So jQuery wins for me.

Solution 10 - Jquery

I'm not experienced in jQuery or Prototype, yet. About to start learning one of them to add to my toolbox as a Senior ColdFusion Developer & project manager. My take on this is initially which one a new comer will decide on as this reflects industry adoptation, which IMHO is key.

Based on a quick look around and a few tutorial reads on both, it seems they each offer the same core abilities. However, looking at job boards and other projects, jQuery seems to be in much more "demand" as opposed to just a skill one can use. To me, jQuery wins here with adoption and demand, community support and documentation is a plus. Nothing against Prototype, it's good to know if a project requires it due to pre existence because some developer picked it as the first one he looked into.

Solution 11 - Jquery

i've used prototype framework and jquery , and as for me, i personally like jquery cuz of its noConflict(); i prefer to use the jq noConflict like this in my js files

(function($){

}(jQuery));

this manner will make you use the $ as you jquery selector per js file

Solution 12 - Jquery

Subscribing the already signed marked correct answer i wan't also to share a lib that allow you to use most of the utilities that you would expect to find on a framework like prototype but with the advantage of don't extend native objects. As consequence it provides you with more control and flexibility over complementary frameworks that you would like to use along your project.

> Underscore is a utility-belt library for JavaScript that provides a > lot of the functional programming support that you would expect in > Prototype.js (or Ruby), but without extending any of the built-in > JavaScript objects. It's the tie to go along with jQuery's tux, and > Backbone.js's suspenders.

Solution 13 - Jquery

Could I also offer the argument that using one or the other is a bit of a false dilemma? Having lots of experience with jQuery I know how beneficial it can be and how much faster application development could become.

It's important to note, however, that it may perhaps be more beneficial for end users in some cases to use no library at all, especially in the instances where it's not required. While it's certainly helpful for large applications, it may be counter-intuitive for use on the common website on account of the impact to performance.

An extra HTTP request is made to download the library and, although usually small when minified, more bandwidth is required as a result. This has the potential of slowing down page load time which may be realized by mobile users.

Additionally, on load a library will immediately execute code to create globally-accessible functions and objects, thereby consuming more memory even if you never use them. Some libraries will also add functions and objects to built-in object prototypes, which also increases memory usage.

Finally, while jQuery and many other libraries are often extensively tested to ensure the least amount of impact to performance, the code you write, though reduced in quantity, will often be slower than otherwise. Keep in mind that everything you can do with a library you can do with raw JavaScript, since fundamentally they're the same.

Solution 14 - Jquery

Succinct concise code using abbreviate style operators tends towards being cryptic as well so it is not necessarily better. It can take away from the readability and make understanding what is going on less clear. In my many years of programming I have come across some very clever cryptic code that was the devil to figure out when it had problems. Personally I like code that self documents and that is optimized for the particulars of a situation. If your goal is to do the most in the least lines of code then using DOM extension libraries like prototype and jQuery may be for you. I personally think it is better to fully understand the capabilities of the JavaScript language itself and the DOM implementation of the browsers and leverage it for the task at hand, whether that be building UI widgets or whatever. I do use the script.aculo.us library on occasion for animation effects so I do find myself loading the prototype library code since scriptaculous depends on it. My suggestion for anyone using either of the libraries would be to learn how to write OO style JavaScript before completely depending on either of these libraries, then incorporate the one that seems to best fit your needs. Excellent book for learning OO style JavaScript is 'Java Design Patterns'.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLuca FilosofiView Question on Stackoverflow
Solution 1 - JqueryGrazaView Answer on Stackoverflow
Solution 2 - JqueryNick CraverView Answer on Stackoverflow
Solution 3 - JqueryMarkView Answer on Stackoverflow
Solution 4 - JqueryfdregerView Answer on Stackoverflow
Solution 5 - JqueryMickelView Answer on Stackoverflow
Solution 6 - JqueryChrisView Answer on Stackoverflow
Solution 7 - JquerySarfrazView Answer on Stackoverflow
Solution 8 - JqueryAlsciendeView Answer on Stackoverflow
Solution 9 - JqueryIlluinView Answer on Stackoverflow
Solution 10 - JqueryClintView Answer on Stackoverflow
Solution 11 - JqueryjanbeeView Answer on Stackoverflow
Solution 12 - JqueryLothre1View Answer on Stackoverflow
Solution 13 - JqueryMicah HenningView Answer on Stackoverflow
Solution 14 - JqueryJmyronsView Answer on Stackoverflow