ReviewEssays.com - Term Papers, Book Reports, Research Papers and College Essays
Search

Javavsjavascript

Essay by   •  February 20, 2011  •  Research Paper  •  2,433 Words (10 Pages)  •  1,006 Views

Essay Preview: Javavsjavascript

Report this essay
Page 1 of 10

Abstract

The following research paper is written with the intent to give the reader information on the differences between JavaScript, Java and Java Applet and the usage of multi-media for web sites.

Research Results

Java and JavaScript Compare and Contrast

JavaScript at first glance looks like Java. The major difference is that JavaScript does not have Java's static typing and strong type checking. The basic control flow and syntax of Java are supported by JavaScript. JavaScript supports a run-time system based on a small number of data types representing numeric, Boolean, and string values, unlike Java's compile-time system of classes built by declarations. JavaScript supports functions so those 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 byte codes.

Java programs consist of classes and their methods and 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. JavaScript on the other hand, descends in spirit from a line of smaller, dynamically typed languages like HyperTalk and dBASE. The other languages offer programming tools for a much wider audience because of easier syntax, specialized built-in functionality, and minimal requirements for object creation.

The following table compares and contrasts JavaScript and Java (Java Script Resources 1999).

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. Object references checked at run-time. Static binding. Object references must exist at compile-time.

Cannot automatically write to hard disk. Cannot automatically write to hard disk.

Uses of Java and JavaScript

As stated above, Java can be a stand-alone program compiled and executed directly on the users’ computer. JavaScript is used in web pages and is embedded into the direct HTML coding of a particular page. This difference may seem insignificant but in reality is very noteworthy. The main uses of Java and JavaScript may seem similar in many fashions but the implementations, and complexity, play a major role in the decision to use one over the other.

When designing a web page, Java applets can be called and executed but this method is not ideal. With the use of Java needing compilation on the client’s machine, this procedure is inefficient in the majority of web applications. Conversely, the use of JavaScript requires no compilation on the client machine and is more efficient. JavaScript is much less complex than Java and can be more easily used in fluid applications that are used on the web pages today. While JavaScript is simpler in design and more efficient for web page creation, JavaScript has limitations to consider.

Java is a much more complex language that requires more coding accuracy and technical experience in the language. With this added complexity comes much more robust capability. Java can be used to create much more complex and powerful applications that are not possible using JavaScript. While they both can be used to create very nice web features and tools, Java can be used to create powerful and robust stand-alone applications such as databases, browsers, and fully-functioning programs (Burns, 2007). The complexity of the language doesn’t necessarily create this added capability for Java, instead the added complexity and structure make the language more capable of performing complex operations across systems and provide the desired results.

The decision on when to use each language mainly lies in the programmer’s abilities, desired functions and interface of the application. Java can be used to perform nearly any task created in JavaScript but is more code intensive and much more complex to understand and program. JavaScript can be used to create some of the items Java can create, but is much more user-friendly and can function without total perfection or full understanding of the language. If a person has a full understanding of Java programming, they may be inclined to program an application in Java, and this may be necessary dependent on the function of the application. If the application is a small web based function, that function is more efficient to program the application in JavaScript because of the less-burdening requirements on the browser. Conversely, if the desired application is complex, stand-alone and performs major functions the application must be programmed in Java, assuming the programmer is capable.

Open Source Nature of Java Applets and JavaScript

Open source programming is the technique and ideology of providing the actual source code of a program to anyone who wants it. Open source programming is normally a collaborative effort and has successful examples in major programming challenges such as operating systems, productivity suites and internet browsers. While the code and language is available for all to view, few advantages and disadvantages are present in both open-source and private programming.

As with any computer programming language, the ability to code and design a program effectively directly affects the success or failure of that program. Some programs are kept close to the vest in an attempt to secure a business advantage while other code is available to the world allowing for reuse and modification. Java and JavaScript fall into the latter category

...

...

Download as:   txt (15.7 Kb)   pdf (177.3 Kb)   docx (15.1 Kb)  
Continue for 9 more pages »
Only available on ReviewEssays.com