[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Macintosch

Timothy Lewis wrote:

> Perhaps this is where I'm getting a little confused... just what is the
> difference between the java applets that have to be compiled
> beforehand... and the javascript that is in the HTML?  Wouldn't they both
> in the end have the same results, with just a few minor detailed
> changes?  Either way... what differences are there in the end?

There are alot of differences between Java and Javascript, so I'll try to hit on 
the most important ones here.  

JAVA - Java is a general purpose stand-alone object-oriented programing 
language.  Though it's initial usefulness (and thus it's popularity) is in 
developing dynamic web pages, it is a full-featured (unless you think having 
memory leaks is a feature) language which is well-suited to writing stand-alone 

Javascript - Javascript is a special-purpose scripting language which is 
designed specifically to provide greater control of web browsers for HTML 
authors. It is object-based, but not really object oriented. It CANNOT be used 
to write stand-alone applications.

With those basic definitions out of the way, there is still the question of the 
difference between Java and Javascript within the context of using them in HTML 
pages. The answer to that really lies in how they both are used by the browser.

Javascript is directly embedded in the HTML which the browser interprets. When 
the browser encounters a <SCRIPT language = "javascript"> tag, it begins to 
interpret the Javascript in-line (i.e. as it encounters it). An author can 
define functions, objects, and variables which can be used to do special 
processing and some level of interactive control, including dynamically 
generating HTML, opening new navigator windows, displaying alerts, and so forth. 

A Java applet on the other hand is not contained in the HTML file. A reference 
to it is constrcuted using thr APPLET tag (just as an image is not actually IN 
the HTML, rather an IMG tag points to the image). When the browser encounters 
the APPLET tag, the applet is loaded, and a new THREAD (I'm sure I'll get 
arguments here about the use of that term and how on a single-threaded OS like 
the Mac OS you can *have* a new thread, but I'll deal with that when it happens) 
is created, and the APPLET is executed (interpreted) within the context of that 
thread.  The APPLET cannot "see" anything outside that thread (except for a few 
specific things which are made visible to it by the browser). The applet is 
given a canvas on the page which it can use to interact with the user 
(displaying graphics and receiving input from keyborad and mouse). Within that 
canvas the APPLET has full control.  Try doing animation using Javascript!

The two are not exclusive. In fact the whole point behind Javascript is to 
ultimately be able to communicate easily between applets. Right now, it's 
impossible for an applet on one window to interact with an applet on another 
window. That will change once the ability for Applets and Javascript to 
communicate effectively is available (Netscape 2.1 I hope!).

I hope this has cleared up some of your confusion. If anybody has anything to 
add, please do so!

-- Robert

Robert Thuleen
Sr. Software Engineer
Science Applications International Corp (SAIC)
San Diego, Ca

For help about the list, please send a message to 'majordomo@obscure.org'
with the message body 'help'. To unsubscribe, send a message to
'majordomo@obscure.org' with the message body 'unsubscribe javascript'.
List archives and pointer to FAQ: http://www.obscure.org/javascript/