Javascript building blocks

Discussion in 'Javascript' started by v4vijayakumar, Oct 16, 2007.

  1. Are there any simple javascript building blocks available? Like,
    Google web toolkit. But, I don't want to write code in java and then
    compiled into javascript. I am just looking for portable ajax/
    javascript libraries. Thanks in advance.
     
    v4vijayakumar, Oct 16, 2007
    #1
    1. Advertisements

  2. v4vijayakumar

    GArlington Guest

    Java (a programming language) and Javascript (a client side scripting
    language) have very little (apart from similar syntax in places) in
    common. They are two different things and you will NEVER be able to
    "write code in java and then compiled into javascript".
    Javascript does NOT come in libraries, but rather in functions. You
    can find a lot of functions on Google if you know what you want, but
    do not try to bundle them together for the sake of having "library",
    javascript have to be downloaded by the client in order to be useful
    and the bigger your "library" - the longer it takes to download - the
    more likely your visitor will stop the request and go away.
     
    GArlington, Oct 16, 2007
    #2
    1. Advertisements

  3. v4vijayakumar

    Henry Guest

    That may no be a wise direction to go in regardless. The obvious
    problem would be that no matter how good you may be at Java, and how
    well you wrote the Java code, the javascript that it would be compiled
    into would never be better than what Google is capable of. And you
    don't have to do any more than use 'view source' on a Google groups
    page to see that Google's javascript authoring is so bad as to be
    laughable. An impression that is rapidly re-enforced by hading IE pop
    up its error dialog whenever an error happens and then using Google
    groups for more than a few minutes.
    Do you mean AJAX (the thing involving the handling of multiple
    asynchronous sources of input) or do you just mean an XML HTTP request
    library?
     
    Henry, Oct 16, 2007
    #3
  4. v4vijayakumar

    The Magpie Guest

    Java does not "compile into javascript". They are quite different
    languages and have no real relationship.
     
    The Magpie, Oct 16, 2007
    #4
  5. v4vijayakumar

    Matt Kruse Guest

    You should first understand what the Google Web Toolkit is before
    making such a statement.

    Matt Kruse
     
    Matt Kruse, Oct 16, 2007
    #5
  6. v4vijayakumar

    Matt Kruse Guest

    You should first understand what the Google Web Toolkit is before
    making such a statement.

    Matt Kruse
     
    Matt Kruse, Oct 16, 2007
    #6
  7. Since the introduction of compilers it has been possible to write in
    one language and compile into another.

    Specifically there are two projects for compiling Java into JavaScript

    http://code.google.com/webtoolkit/
    http://j2s.sourceforge.net/

    There are also many other projects for compiling other languages (e.g.
    Sheme, Smalltalk, Python, Ruby, haXe) into JavaScript

    JavaScript does not really come "in functions". JavaScript is a
    language with functions and objects, integers, strings etc.

    If you do not aggregate your JavaScript code into files (aka
    libraries) then you will be asking the client to make many downloads
    for even a moderately complex page. That is far slower than
    downloading a single file with all the functions you need in it. You
    should bundle your functions into libraries even if those libraries
    are specific to a particular page.

    Peter
     
    Peter Michaux, Oct 16, 2007
    #7
  8. In comp.lang.javascript message <
    legroups.com>, Tue, 16 Oct 2007 16:22:39, Peter Michaux
    IMHO a Library (in computing) is something from which the relevant parts
    are extracted at the authoring stage. In Pascal/Delphi, for example,
    one can include many Units in the program source set, but only the
    necessary routines will be included in the distributed EXE (approximate
    statement).

    A Javascript Library should be treated similarly; but the task is not
    normally automated. The author should repackage what is appropriate, so
    that no more than is reasonable is downloaded to each user.

    So an author must neither put all possible routines in one vast file,
    not put each routine in its own file; but must strike a happy mean :
    that is an art.
     
    Dr J R Stockton, Oct 16, 2007
    #8
  9. v4vijayakumar

    The Magpie Guest

    Not really Matt - its simple fact.

    I will give you every credit and presume that you are referring to
    cross-compilation features I understand are in Google Toolkit, but
    even so that is no more relevant than to presume BBC Basic can be
    "compiled" into PL/1 or Fortan into Cobol.

    Maybe they can - its what cross-compilers are for, after all - but it
    does not change the facts that the languages are unrelated.
     
    The Magpie, Oct 17, 2007
    #9
  10. I think your definitions of compiler does not line up with the
    majority of programmers.

    "A compiler is a computer program (or set of programs) that translates
    text written in a computer language (the source language) into another
    computer language (the target language)." - http://en.wikipedia.org/wiki/Compiler

    So GWT is a perfect example of a compiler because it translates Java
    to JavaScript.

    Peter
     
    Peter Michaux, Oct 17, 2007
    #10
  11. I think your definitions of compiler does not line up with the
    majority of programmers.

    "A compiler is a computer program (or set of programs) that translates
    text written in a computer language (the source language) into another
    computer language (the target language)." - http://en.wikipedia.org/wiki/Compiler

    So GWT is a perfect example of a compiler because it translates Java
    to JavaScript.

    Peter
     
    Peter Michaux, Oct 18, 2007
    #11
  12. v4vijayakumar

    dhtmlkitchen Guest

    Bundling up your scripts into a file without too many excess files is
    a perfectly valid way to approach. Scripts that require no extra
    dependencies are attractive because they can be optimized for the
    intended purpose. The result is a small, self-contained script.

    On the other hand...

    Large apps that have the functionality distributed in various ways can
    benefit from reuse of components. Things like DOM utilities, Event
    Registry, Ajax Transport, Data Structures, Plain old Objects (POJSO?)
    like URLBuilder or Color, Widgets, et c. With this approach, code
    maintenance becomes an unavoidable issue. Breaking things down into
    cohesive units makes testing and maintenance easier; you don't have to
    worry about a failure case in one page, then changing the code to
    create another failure case on another page. Instead, you just write
    isolated tests for all uses of the bit of code.

    With the "small objects" approach, an automated task can be used to
    "build" to "compile" the scripts into one. That way, you can maximize
    cohesion and avoid the headaches associated with copy-paste
    maintenance.

     
    dhtmlkitchen, Oct 18, 2007
    #12
  13. v4vijayakumar

    The Magpie Guest

    I believe I made that point, Randy. Please do not presume criticism
    where there is none.
    I know, and as I said I mentioned that. However, my point was to the
    OP who, unlike Matt, did seem to be confused on that point.
     
    The Magpie, Oct 20, 2007
    #13
  14. v4vijayakumar

    The Magpie Guest

    Peter, there are a number of definitions and sub-definitions of
    "compiler" and it is often important to distinguish between them to
    avoid confusion. It was to avoid such possible confusion, if there was
    any, in the mind of the OP that I commented as I did.

    If I may quote - from your own source - a section of the same article
    which makes the same point that I made, but in a rather more
    long-winded way:-

    <<The name "compiler" is primarily used for programs that translate
    source code from a high-level programming language to a lower level
    language (e.g., assembly language or machine language). A program that
    translates from a low level language to a higher level one is a
    decompiler. A program that translates between high-level languages is
    usually called a language translator, source to source translator, or
    language converter. A language rewriter is usually a program that
    translates the form of expressions without a change of language.>>
    <<<http://en.wikipedia.org/wiki/Compiler>>>
     
    The Magpie, Oct 20, 2007
    #14
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.