Essays24.com - Term Papers and Free Essays
Search

Mr.S

Essay by   •  November 18, 2010  •  3,141 Words (13 Pages)  •  1,022 Views

Essay Preview: Mr.S

Report this essay
Page 1 of 13

Web Programming II Final Paper

POS 420

University of Phoenix

JavaScript

Java is often confused with JavaScript. This is because the name "JavaScript" seems to suggest that it may somehow contain Java code. Some may think that JavaScript is a descendant of Java - like C++ is to C. The truth is that Java and JavaScript are two different languages altogether. Their programming structures are similar, but the two languages are independent of each other. This article highlights the differences between the two languages. These differences include, but are not limited to:

 "JavaScript is a language used to add interactivity to a web page."(Negrino & Smith, 2001)

 Java is a programming language that can be used to create stand along programs, while JavaScript is used only for web pages.

 Java is object oriented while JavaScript is object based.

 Java was started by Sun Microsystems. Netscape developed JavaScript.

* JavaScript is Not a Full Programming Language

The JavaScript language is used to enhance web pages. A JavaScript script is a program that is included on an HTML page. JavaScript is, of course, not limited to an HTML page. JavaScript can be embedded into just about any scripting or markup page. JavaScript has a vast array of uses. For example, with JavaScript one can create an image link so that when a user moves a mouse over the image, the image changes. A JavaScript programmer can create a rollover menu so that when a user click over the menu first menu item or menu title, the entire menu displays. Another example of JavaScript in action is a prompt. Yahoo Mail uses JavaScript prompts to prompt the user for the name of the folder when he/she clicks on the "add" link under the "folders" section. The number of uses to add interactivity to a web page is almost limitless.

Java

Java, on the other hand is a full-featured programming language (Negrino T & Smith D, 2001, pg 4). Java is used to create stand-alone applications. It does not have to be embedded into a web page in order to work. With the "Java Applet", however, it Java can be used as programs on a web page. Many chat programs that are embedded into a web page are written in Java.

History of Java

Java was started as a computer programming language in 1991. According to Sun Microsystems (n.d.), the language was "created as a computer programming tool in a small, secret effort called "the Green Project" at Sun Microsystems in 1991." Sun Microsystems (n.d.), goes on to say that they were trying to "anticipate and plan for the 'next wave' in computing." Developers from Sun anticipated that the "next wave" would be "convergence of digitally controlled consumer devices and computers." Basically the anticipated that embedded devices would be common place. Therefore, they wanted to develop a language for these devices. The result was a project named "Oak", which used Java. Through the Oak project, developers from Sun proved the usefulness of Java technology through "hand-held home-entertainment device controller targeted at the digital cable television industry. Since then, Java has grown enormously. It is used in mobile phone, car navigation systems, web applications, and as stand-alone games on computers (Sun Microsystems, n.d.).

An example from http://examples.oreilly.com/jenut/FizzBuzz.java shows a simple Java program that is a game called Fizzbuzz:

/**

* This program plays the game "Fizzbuzz". It counts to 100, replacing each

* multiple of 5 with the word "fizz", each multiple of 7 with the word "buzz",

* and each multiple of both with the word "fizzbuzz". It uses the modulo

* operator (%) to determine if a number is divisible by another.

**/

public class FizzBuzz { // Everything in Java is a class

public static void main(String[] args) { // Every program must have main()

for(int i = 1; i

Another main difference between JavaScript and Java is that JavaScript is object based, whereas Java is object oriented. An object oriented language supports inheritance, information hiding, and encapsulation. Inheritance allows a programmer to develop super classes and then inherit the properties of those super classes by using subclasses. Sun Microsystems (2007, What is Inheritance), gives this simple explanation of inheritance:

Different kinds of objects often have a certain amount in common with each other. Mountain bikes, road bikes, and tandem bikes, for example, all share the characteristics of bicycles (current speed, current pedal cadence, and current gear). Yet each also defines additional features that make them different: tandem bicycles have two seats and two sets of handlebars; road bikes have drop handlebars; some mountain bikes have an additional chain ring, giving them a lower gear ratio.

Object-oriented programming allows classes to inherit commonly used state and behavior from other classes. In this example, Bicycle now becomes the super class of MountainBike, RoadBike, and TandemBike.

Information hiding is another aspect of object oriented programming languages that object-based languages do not share. Information hiding, according to Webopedia.com (n.d, Information Hiding), is "the process of hiding details of an object or function."

Encapsulation, according to Webopedia.com (n.d., Encapsulation) is the process of combining elements to create a new entity. According to Sun (2007), What is an object) encapsulation is "hiding internal state [of the function] and requiring all interaction to be performed through an object's methods is known as data encapsulation."

The differences between Java and JavaScript are quite significant. Java is a full programming language and is used on many devices. JavaScript is primarily intended to add interactivity

...

...

Download as:   txt (20.2 Kb)   pdf (211.2 Kb)   docx (17.4 Kb)  
Continue for 12 more pages »
Only available on Essays24.com