Why prototype?

JavaScript and client side scripting.

Moderator: General Moderators

User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Why prototype?

Post by JellyFish »

Why do people even use Prototype's API if there's jQuery? Is it ignorance? Do people even know about jQuery, and it's simplicity and power?

So why Prototype, or any other API for that matter?

What's missing in jQuery that it's not the most popular?

PS: I was really trying to get at this in my last client side post, which I deleted.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Variety is good.

Sometimes the choice of library is out of the individual developer's hands.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Also, some people are used to working with the DOM. Prototype provides the user a way to work with the DOM the way they are used to working with it, only with shortcuts and easier access to the things they use most often. jQuery is a total abstraction of the DOM. You don't need to know about all the inner-workings of it. For me, this is good, because at this point, I'm just not interested in messing with all of that.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

I'm having a little bit of a hard time working out which one I want to use.

jQuery is the only one I've used. The only problem I'm having is with the Interface extension. The Demo's easing effects don't work on any of my browsers: Firefox, IE, Opera or Safari.

Will they work when I download it?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Can you define doesn't work?

Why haven't you downloaded it and tested them on your own?
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

I got it now. I forgot to include the easing.js file, thought that easing effects were built into the interface.js file.
the_drizzle
Forum Newbie
Posts: 17
Joined: Fri Jun 01, 2007 11:55 am

Post by the_drizzle »

jQuery is a godsend! Technically it's preference, but even more technically, you should just use jQuery. Can you tell my favourite? ;)
Also check out Interface. If you like GUI, then you should like Interface, which runs on top of jQuery. The obvious contender is Scriptaculous but I find Interface is a larger library and it's easier to use.

But yeah. It's completely up to you.

-----------
Edit
-----------

Sorry, you already knew about interface.... Oops.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

You could also look at the extjs which can also use jquery.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Here's what I've found: jQuery is a bit lacking when it comes to OOP-emulation features that Prototype is quite famous for (it's not called prototype for nothing). While one may argue that OOP is not the paradigm one should follow when coding in such a flexible language like JavaScript, it has certainly been frustrating trying to implement polymorphism and base classes in jQuery.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I hadn't seen Interface before -- pretty cool for javascript.

http://interface.eyecon.ro/demos/carousel.html
(#10850)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Oh nice...that was JavaScript doing that? I always thought it was Flash...heh...cool...

I'm def. gonna use jQuery now for sure 8)
the_drizzle
Forum Newbie
Posts: 17
Joined: Fri Jun 01, 2007 11:55 am

Post by the_drizzle »

Ambush Commander wrote:Here's what I've found: jQuery is a bit lacking when it comes to OOP-emulation features that Prototype is quite famous for (it's not called prototype for nothing). While one may argue that OOP is not the paradigm one should follow when coding in such a flexible language like JavaScript, it has certainly been frustrating trying to implement polymorphism and base classes in jQuery.
Oh yeah. I really agree that there are differences between jQuery and Prototype. They are not to be confused with two different 'products' designed with the same purpose.


It's funny, JavaScript is probably one of the most OO languages around. It's more object oriented than Java. It's just that no one ever really talks about JavaScript's OO side because the context is usually web UI. And I'd definitely say that an OO approach with JavaScript is a great way to go.

As for polymorphism and the like, I think jQuery should - or is supposed to - be used as a library or as a DOM manipulation framework. Prototype is a little bit different in that it strives to be an entire client-side framework. jQuery is to pieces of the PECL as prototype is to the Zend Framework or CakePHP. Personally, assuming I'm going OO in JavaScript, I'd build OO framework that uses jQuery, avoiding integration madness.

But then again, my thoughts may have been invaded by bias.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Well, they do call themselves a "library" and specifically makes accomodations for other libraries. That being said, I don't want to use both Prototype and jQuery and have DOM/Events/AJAX code all duplicated.

Javascript doesn't natively support OO constructs, so I wouldn't call it an OOP language per-say, but its objects are so flexible that you can implement all of them with ease.
the_drizzle
Forum Newbie
Posts: 17
Joined: Fri Jun 01, 2007 11:55 am

Post by the_drizzle »

Ambush Commander wrote:Well, they do call themselves a "library" and specifically makes accomodations for other libraries. That being said, I don't want to use both Prototype and jQuery and have DOM/Events/AJAX code all duplicated.
Oh, you'd certainly not want to use them together. I was suggesting using jQuery and then writing something else - like Prototype - to use it. You could even harvest from Prototype if you're risqu'e.
Ambush Commander wrote: Javascript doesn't natively support OO constructs, so I wouldn't call it an OOP language per-say, but its objects are so flexible that you can implement all of them with ease.
Really sorry about this. Looks like I'm about to rant :| (it's not directed at anyone in particular :)).

JavaScript doesn't natively support Java's OO constructs. Mainstream OOP languages such as Java and C++ are not the definition of OOP but rather a demonstration. A couple of things to consider: it's really easy to make lots of money in software development, we are in the middle of a globalization revolution, and theoretical computer science is still an incredibly young subject. These issues create a pattern of bandwagon hopping and the world ends up with tons of Architecture Astronauts and too much hype about nothing. JavaScript supports all the OO Java does and more, just with a different syntax. You might even call the OO capacity of JavaScript a superset of the OO capacity of Java. The real difference is that most OO structure in Java is defined statically, but with JavaScript, it's defined statically and dynamically. Nearly everything in Java is an object. In JavaScript, nearly everything is an object, including functions. JavaScript doesn't even technically have functions. It simulates functions by cleverly using objects and constructors. How much more OO can you get?
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

I'm using jQuery a lot, it is my first lib I've used. I just don't want to waste any time on a library that's not going to benefit me to the fullest extent.

Which do you recommend and why? Prototype, jQuery or Mootools?
Post Reply