relation between prototype and Prototype.js

Discussion in 'Javascript' started by shypen42@yahoo.fr, May 23, 2006.

  1. Guest

    Hi all,

    I'm very confused by the relation between "prototype" and
    that "Prototype.js" library that seems to be used quite a lot
    (not by knowledgeable people from this group if I understood
    correctly).

    For example, when I do this, I use the keyword (?) "prototype":

    function Example() {
    ...
    }

    Example.prototype.val = undefined;


    What is the relation between that and the "Prototype.js" library?

    Is that name just plain confusing or am I just plain confused?
    (both ? :)



    P.S : I'm just beginning with Javascript...
     
    , May 23, 2006
    #1
    1. Advertising

  2. Ian Collins Guest

    wrote:
    > Hi all,
    >
    > I'm very confused by the relation between "prototype" and
    > that "Prototype.js" library that seems to be used quite a lot
    > (not by knowledgeable people from this group if I understood
    > correctly).
    >
    > For example, when I do this, I use the keyword (?) "prototype":
    >
    > function Example() {
    > ...
    > }
    >
    > Example.prototype.val = undefined;
    >
    >
    > What is the relation between that and the "Prototype.js" library?
    >
    > Is that name just plain confusing or am I just plain confused?
    > (both ? :)
    >

    Just plain confused!

    Forget about Prototype.js and learn how to work with core JavaScript.
    Once you are up to speed with the language, you will be in a better
    position to evaluate toolkits.

    --
    Ian Collins.
     
    Ian Collins, May 23, 2006
    #2
    1. Advertising

  3. wrote:
    > I'm very confused by the relation between "prototype"
    > and that "Prototype.js" library that seems to be used
    > quite a lot (not by knowledgeable people from this
    > group if I understood correctly).
    >

    The people who wrote Prototype.js were not very familiar with javascript
    (and apparently did not like what they did now about it, so tried to
    make it 'like' another language more to their liking). Most of the
    people writing here like javascript (and many understand it, more or
    less, as well) so they (we) don't have much use for that library.

    > For example, when I do this, I use the keyword (?)
    > "prototype":


    It is not a keyword. Javascript's keywords are defined in ECMA 262 3rd
    Ed. Section 7.5. "prototype" is a property name that is emplyed as the
    name of a proeprty of function objects that is used when a fucntion is
    used as a constructor as the source of the vlaue for the internal
    [[Prototype]] property of the constructed object. The internal
    [[Prototye]] property of objects is how javascript objects inherit
    proerties from other objects.

    > function Example() {
    > ...
    > }
    >
    > Example.prototype.val = undefined;


    So, if an object is constructed with:-

    var obj = new Example();

    - the resulting object does not have a - val - property itself, but it
    does inherit one through its internal [[Prototype]] property, which is
    assigned its value from the - Example - function's (public) prototype
    property.

    > What is the relation between that and the "Prototype.js"
    > library?


    The name of the "Prototype.js" library is arbitrary and has no clear
    relationship with the prototype inheritance used in javascript (except
    by coincidence).

    > Is that name just plain confusing


    The name certainly is confusing.

    > or am I just plain confused?
    > (both ? :)


    You may be confused as well ;-)

    Richard.
     
    Richard Cornford, May 23, 2006
    #3
  4. Andy Baxter wrote:
    > shypen42 said:
    >> I'm very confused by the relation between "prototype"
    >> and that "Prototype.js" library that seems to be used
    >> quite a lot (not by knowledgeable people from this
    >> group if I understood correctly).

    <snip>
    > 'Prototype.js' is a library of prewritten javascript code
    > that you can use to make it easier to design cross-platform
    > js applications.


    More likely to avoid addressing the issues of designing cross-platform
    js applications.

    > Among other things, the designers of the toolkit will have
    > worked out all the tricky bugs that stop code running the
    > same on all browsers,


    That is rather optimistic, and patently not true. It is not a couple of
    weeks since someone posted a question here asking how to detect
    environments where the prototype.js library did not work (which includes
    all IE versions prior to 6, for example, and I have seen it behaving
    inconsistently in recent Opera browsers when attempting AJAX). Which
    means that not only have its authors failed to work out those issues but
    they have also failed to provide some clear indication in the library of
    when it is trying to operate in an environment that does not support it.

    > and encapsulated this in a simple api that just works the
    > way you want.


    Where it 'works', the rest of the time it just errors out and denies any
    possibility of clean degradation.

    > I.e. you write code to do what you want regardless of the
    > browser, and their code sorts out the nitty gritty details
    > of how to implement this on Internet Explorer compared to
    > Firefox, etc.


    Where "Internet Explorer" means 'a sub-set of possible configurations of
    IE 6' and "etc" is not a very long list at all.

    > This might be worth learning about, but probably not until
    > you've got some practice writing simple stuff first.


    Once some experience has been gained addressing the issues of
    cross-browser design Prototype.js probably won't look like a good idea
    at all.

    Richard.
     
    Richard Cornford, May 23, 2006
    #4
  5. Andy Baxter wrote:
    > Richard Cornford said:
    >> Once some experience has been gained addressing the issues of
    >> cross-browser design Prototype.js probably won't look like a
    >> good idea at all.

    >
    > OK, sorry. Do you know of any toolkits that are worth using in
    > this respect? I'm using dojo (dojotoolkit.org) at the moment.
    > Do you think it's better to use a toolkit or just work through
    > all the problems yourself??


    It is crazy not to re-use code in some form or another. The precise
    level at which you pitch code re-use is (certainly has been) the subject
    of quite heated debate, and I don't have time to do the subject justice
    tonight. You might be well advised to do an archive search for the
    threads where the subject has been debated (the threads where more than
    just a couple of the regulars contributing would probably be most
    useful). I think the keyword 'library' would make a reasonable starting
    point for an archive search.

    To date I have not seen a single publicly available general
    library/toolkit/framework that I would consider appropriate for general
    Internet use.

    Richard.
     
    Richard Cornford, May 24, 2006
    #5
  6. Guest

    Andy Baxter wrote:
    > Richard Cornford said:
    >
    > OK, sorry. Do you know of any toolkits that are worth using in this
    > respect? I'm using dojo (dojotoolkit.org) at the moment. Do you think it's
    > better to use a toolkit or just work through all the problems yourself??


    Andy Baxter wrote:
    > Richard Cornford said:
    >
    > > Once some experience has been gained addressing the issues of
    > > cross-browser design Prototype.js probably won't look like a good idea
    > > at all.

    >
    > OK, sorry. Do you know of any toolkits that are worth using in this
    > respect? I'm using dojo (dojotoolkit.org) at the moment. Do you think it's
    > better to use a toolkit or just work through all the problems yourself??


    I'm no expert but these are my impressions so far...

    I like Ruby a lot but don't want JavaScript to look like Ruby. It's an
    extra layer. I was avoiding Prototype.js for a while; however, now with
    the very cool .rjs templates in Rails, Prototype.js is becoming more
    tightly integrated into Rails. I think this dependence is unfortunate
    but the .rjs templates are very cool and big timesavers. As Rails
    becomes more popular, it is inevitable that Prototype.js will also
    become more popular. Hopefully Prototype.js will continue to improve.

    I tried a bit of Dojo. It is a big library and seems like it might be
    hard to understand it. Also the demo sites all seemed very slow. The
    dynamic loading of libraries (or some such fanciness) could have been a
    problem for speed? All this could be wrong but I only found things I
    didn't like and never went "Wow this is cool!". Also the markup for
    Dojo widgets seems like a nightmare. They are able to claim
    non-intrusive JavaScript but the HTML tags have many attributes to get
    info to the JavaScript. Seems like a complicated way to avoid a tiny
    bit of easily understandable JavaScript.

    The ajax toolbox looks good http://www.ajaxtoolbox.com but the license
    may cause you trouble.

    I've been enjoying the connection.js and event.js libraries from Yahoo!
    UI

    http://developer.yahoo.com/yui/

    The Yahoo! dragdrop.js library seems reasonably good too. However I
    don't like how it is necessary for every draggable element to have an
    id. I'll live with making up dummy id's for elements for now. I hope
    they eliminate this requirement soon. Also I don't know if you can set
    the scope for the interesting moment functions. I haven't found any
    docs indicating yes.

    Wading thorough all these libraries is a lot of work. You'll have to
    experiment. Certainly the Yahoo! UI core libraries are worth a look.

    - Peter
     
    , May 24, 2006
    #6
  7. Jim Ley Guest

    On Tue, 23 May 2006 23:48:53 +0100, Andy Baxter
    <-online.co.uk> wrote:

    >Richard Cornford said:
    >
    >> Once some experience has been gained addressing the issues of
    >> cross-browser design Prototype.js probably won't look like a good idea
    >> at all.

    >
    >OK, sorry. Do you know of any toolkits that are worth using in this
    >respect? I'm using dojo (dojotoolkit.org) at the moment.


    I use a very recently installed IE6, it's basically standard, very few
    changes (a few tweaks to settings nothing particularly strange) but
    when I click on the demo mail application on their sample
    applications, most of the time it completely locks up the browser - I
    think that is cache related - if I enable aggressive caching, then I
    get to see the application, complete with javascript errors as it
    builds - of course it's quite difficult to test as F5 completely
    resets state.

    Now, for me, that level of quality in a flagship application is
    suggestive of poor quality. Of course it's a complicated
    functionality, and certainly impressive what you can do with it, but
    it's a question of how much work you have to do to get it to release
    quality.

    Libraries are great for prototypes, but I've never seen a release
    quality product come from a library, the compromises of being general
    and not quite targetted at exactly what you want create too many bugs
    in what is very disperate execution environment.

    Jim.
     
    Jim Ley, May 24, 2006
    #7
  8. Matt Kruse Guest

    wrote:
    > The ajax toolbox looks good http://www.ajaxtoolbox.com but the license
    > may cause you trouble.


    Why so?

    The only thing my "license" tries to prohibit is someone taking my code and
    publishing it on their site for everyone to download. And this is mainly
    because it's a huge pain for me when people submit bug reports, change
    requests, and other comments based on outdated code that was obtained from
    some other source than my site.

    --
    Matt Kruse
    http://www.JavascriptToolbox.com
    http://www.AjaxToolbox.com
     
    Matt Kruse, May 24, 2006
    #8
  9. Guest

    Matt Kruse wrote:
    > wrote:
    > > The ajax toolbox looks good http://www.ajaxtoolbox.com but the license
    > > may cause you trouble.

    >
    > Why so?
    >
    > The only thing my "license" tries to prohibit is someone taking my code and
    > publishing it on their site for everyone to download. And this is mainly
    > because it's a huge pain for me when people submit bug reports, change
    > requests, and other comments based on outdated code that was obtained from
    > some other source than my site.


    I understand the reasoning and it is good. Since your library is a
    utility-type library, the license makes it difficult for people to
    encorporate your library in an open source project with a more liberal
    distribution license like MIT or BSD or even GNU. It is true that you
    gave me permission to do this for one project; however, what if someone
    want's to redistribute my project on their site? It is fine with me but
    do they need to ask your permission? It either gets a little
    restrictive or at least a little confusing.

    For someone who wants to use your library in a contract job there would
    be no problem.

    Peter
     
    , May 24, 2006
    #9
  10. Andy Baxter wrote:

    > 'prototype' is to do with the object-based side of javascript - you don't
    > need to know about this unless you want to build your own custom objects.
    > You're probably best off just learning the basics of the language first.


    Non sequitur. That JavaScript, or ECMAScript implementations for that
    matter, are object-based, if not object-oriented, programming languages,
    even if it is not obvious due to implicit scope chain resolution of
    identifiers, is one important part of the "basics of the language".


    PointedEars
    --
    A man who works with his hands is a laborer; a man who works with his
    hands and his brain is a craftsman; but a man who works with his hands
    and his brain and his heart is an artist.
    -- Louis Nizer, lawyer (1902-1994)
     
    Thomas 'PointedEars' Lahn, May 26, 2006
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Naresh Agarwal
    Replies:
    1
    Views:
    1,092
    ExGuardianReader
    May 29, 2004
  2. Ganesh
    Replies:
    3
    Views:
    509
    Rolf Magnus
    May 10, 2005
  3. Satya
    Replies:
    1
    Views:
    1,267
    jmcgill
    May 16, 2006
  4. giodo
    Replies:
    0
    Views:
    453
    giodo
    Oct 10, 2007
  5. tenxian
    Replies:
    4
    Views:
    284
    Mark Space
    Apr 27, 2008
Loading...

Share This Page