JavaScript and Java are alike in
some ways but fundamentally unlike in some others. The JavaScript language
looks like Java but does not have Java's static typing and strong type
checking. JavaScript follows most Java appearance syntax, naming conventions
and basic control-flow constructs which was the reason why it was renamed from Live
Script to JavaScript. 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 string values.
JavaScript has a prototype-based object model instead of the more common class-based
object model. The prototype-based model provides dynamic inheritance; that is,
what is genetic can vary for individual objects. JavaScript also supports
functions without any special declarative necessities. Functions can be
properties of objects, executing as loosely typed methods. JavaScript is a very
free-form language compared to Java. You do not have to declare all variables,
classes, and methods. You do not have to be concerned with whether methods are
public, private, or protected, and you do not have to implement interfaces.
Variables, limitations, and function return types are not explicitly typed.
Java is a class-based programming language designed for fast execution and type
safety. Type safety means, for instance, that you can't cast a Java integer
into an object reference or access private memory by demeaning Java byte codes.
Java's class-based model means that programs consist exclusively of classes and
their methods. Java's class tradition and strong typing generally require
tightly coupled object hierarchies. These requirements make Java software
design more complex than JavaScript programming. In contrast, JavaScript
descends in spirit from a line of smaller, dynamically typed languages such as Hyper
Talk and dBase. These scripting languages offer programming tools to a much
wider audience because of their easier syntax, specialized built-in
functionality, and minimal necessities for object creation.
No comments:
Post a Comment