File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes jQuery inspired by prototype? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "jQuery inspired by prototype?" Watch "jQuery inspired by prototype?" New topic

jQuery inspired by prototype?

Sapna Grover
Ranch Hand

Joined: Sep 27, 2002
Posts: 54
It looks similar to prototype. How would one compare the two?

Sapna Grover
Daesung Park
Ranch Hand

Joined: Mar 22, 2007
Posts: 68
The "$" is used to query element in both of them, that makes me think like you. But I don't know which one inspired which one. Anyway, I was little surprised at the fact that "$" can be used as a function name in JavaScipt. It is rare case in other programming languages as far as I know.

Daesung Park

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Everything is inspired by something. There are no unique ideas. Protoype an JQuery pretty much try and solve the same problem which is how you make JavaScript pleasant to use. And they both try and make it simpler to do mundane and often times complex things with less typing. Of course, they do much more than that we well.

The largest difference I see between Prototype and Ajax is Prototype feels more like an Object Oriented approach where JQuery feels more like an expression language. Consider this...

new Ajax.Updater(...)


Both do the exact same thing, more or less. They take the response from an AJAX request and shove it on the page.

GenRocket - Experts at Building Test Data
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63852

Aside from the fact that the both use $ as a core function name, and are both JavaScript libraries, they are about as different in approach as you can get.

Prototype took the invasive path of modifying the core objects in JavaScript to make them look more like Ruby. As Gregg pointed out, it uses, and expects its users to use, an object-oriented approach to JavaScript. In addition to modifying the core JavaScript objects, it also adds a lot of names and objects to the global namespace.

jQuery is non-invasive in that it does not modify any JavaScript object. Rather it uses a wrapper to wrap new functionality around elements rather than directly modifying them. It adds only two names to the global namespace: jQuery and $, and the latter can be undefined if you want to use jQuery on the same page as Prototype. jQuery can be used with object-oriented JavaScript or plain functional style JavaScript.

I think both are strong and well-written libraries, and choosing either depends upon which approach you prefer. Personally, I have adopted jQuery for use in all my personal projects as I like its lighter, non-invasive style (and there are tons and tons of jQuery plugins to do just about anything one might need). In my day job, we use both.
[ January 16, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
Yehuda Katz

Joined: Jan 14, 2008
Posts: 21
jQuery was inspired by a number of things, including Dean Edwards' Base and the original Behaviours library that was written on top of Prototype. John is also friendly

Prototype's primary mission is to make JS more like Ruby; jQuery's primary mission is to make it easier to do DOM Scripting. See other threads from this week for more details.

There's a lot of jQuery's approach that has been adopted by Prototype. Most notably their revamped event system looks a lot like jQuery's event system. Then again, pretty much everyone has come on board with things like full CSS3 selectors and simplified events.

For an interesting historical perspective, check out John's initial post where he talked about the ideas that would eventually become jQuery:
I agree. Here's the link:
subject: jQuery inspired by prototype?
It's not a secret anymore!