JavaScript vs.

This is just a small page to compare Java, the new language developed by Sun Microsystems and JavaScript, the scripting language that comes from Java.

The following text was taken from JAVAScript version 2.8, a 208 page JavaScript book in PDF format I found online, that was taken from Netscape Corporation's World Wide Web Site. For those who don't like reading, a table near the end of the document compares the two languages, click HERE to go straight to it.
NOTE: I did not write the following text.


First of all, JavaScripts resemble Java applets, but without Java's static typing and strong type checking. JavaScript supports most of Java's expression syntax and basic control flow. In contrast to Java's compile-time system of classes built by declarations, JavaScript supports a run-time system based on a small number of data types representing numeric, Boolean, and sting values. JavaScript has a simple instance-based object model that still provides significant capabilities.

JavaScript also supports functions, again without any special declarative requirements. Functions can be properties of objects, executing as loosely typed methods.

JavaScript complements Java by exposing useful properties of Java applets to script authors. JavaScript statements can get and set exposed properties to query the state or alter the performance of an applet or plug-in.

Java is an extension language designed, in particular, for fast execution and type safety. Type safety is reflected by being unable to cast a Java int into an object reference or to get at private memory by corrupting Java bytecodes.

Java programs consist exclusively of classes and their methods. Java's requirements for declaring classes, writing methods, and ensuring type safety make programming more complex than JavaScript authoring. Java's inheritance and strong typing also tend to require tightly coupled object hierarchies.

In contrast, JavaScript descends in spirit from a line of smaller, dynamically typed languages like HyperTalk and dBASE. These scripting languages offer programming tools to a much wider audience because of their easier syntax, specialized built-in functionality, and minimal requirements for object creation.

The following table compares and contrasts JavaScript and Java.

JavaScript

Java

Interpreted (not compiled) by client

Compiled on server before execution on client

Object-Based. Code uses built-in, extensible objects, but no classes or inheritance

Object-oriented. Applets consist of object classes with inheritance.

Code Integrated with, and embedded in, HTML.

Applets distinct from HTML (accessed from HTML pages)

Variable data types not declared (loose typing)

Variable data types must be declared (strong typing)

Dynamic binding; objects references checked at run-time

Static binding; object references must exist at compile-time

Secure, cannot write to hard disk

Secure, cannot write to hard disk


I hope that you now catch a little better the differences. I much prefer JavaScripts to Java, for I find that it is much less complicated. But I must agree that Java looks better and is more complex then a simple JavaScript.

Back to the AnatoleNET Home Page

This page is being hosted by GEOCITIES