Web Development

Difference between JavaScript and Java

Although JavaScript’s name appears to connote a close relationship with Java, JavaScript and Java are actually very different. One important difference is support for object-oriented programming. Although JavaScript is sometimes said to be an object-oriented language, its object model is quite different from that of Java and C++.

In fact, JavaScript does not support the object-oriented software development paradigm. Java is a strongly typed language. Types are all known at compile time, and operand types are checked for compatibility. Variables in JavaScript need not be declared and are dynamically typed, making compile-time type checking impossible. One more important difference between Java and JavaScript is that objects in Java are static in the sense that their collection of data members and methods is fixed at compile time. JavaScript objects are dynamic—the number of data members and methods of an object can change during execution. The main similarity between Java and JavaScript is the syntax of their expressions, assignment statements, and control statements.

Use of JavaScript

The original goal of JavaScript was to provide programming capability at both the server and the client ends of a Web connection. Since then, JavaScript has grown into a full-fledged programming language that can be used for a variety of application areas. This book focuses on client-side JavaScript.

Client-side JavaScript can serve as an alternative for some of what is done with server-side programming, in which computational capability resides on the server and is requested by the client.

Client-side JavaScript, on the other hand, is embedded in HTML documents (either physically or logically) and is interpreted by the browser. This transfer of load from the often-overloaded server to the normally underloaded client can obviously benefit all other clients.

Client-side JavaScript cannot replace all server-side computing. In particular, while server-side software supports file operations, database access, and networking, client-side JavaScript supports none of these.

Facebook Comments

Show More

Leave a Reply

Back to top button