Javascript building blocks

V

v4vijayakumar

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.
 
G

GArlington

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.

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.
 
H

Henry

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.

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.
I am just looking for portable ajax/
javascript libraries. Thanks in advance.

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?
 
T

The Magpie

v4vijayakumar said:
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.
Java does not "compile into javascript". They are quite different
languages and have no real relationship.
 
M

Matt Kruse

Java does not "compile into javascript". They are quite different
languages and have no real relationship.

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

Matt Kruse
 
M

Matt Kruse

Java does not "compile into javascript". They are quite different
languages and have no real relationship.

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

Matt Kruse
 
P

Peter Michaux

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".

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 come in libraries, but rather in functions.

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

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.

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
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]
legroups.com>, Tue, 16 Oct 2007 16:22:39, Peter Michaux
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.

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.
 
T

The Magpie

Matt said:
You should first understand what the Google Web Toolkit is before
making such a statement.
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.
 
P

Peter Michaux

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.

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
 
P

Peter Michaux

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.

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
 
D

dhtmlkitchen

In comp.lang.javascript message <[email protected]
legroups.com>, Tue, 16 Oct 2007 16:22:39, Peter Michaux
<[email protected]> posted:




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.
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.

 
T

The Magpie

Randy said:
And that is, precisely, why Matt wrote what he wrote.
I believe I made that point, Randy. Please do not presume criticism
where there is none.
And the fact that the languages are unrelated isn't what Matt was
referring to.
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.
 
T

The Magpie

Peter said:
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
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>>>
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top