Net-informations.com
SiteMap  | About    

Java and JavaScript

While the two have similar in names , both are two totally different programming languages. Java is a full featured, all purpose, programming language that is mainly used in server side, mobile development and also run in browsers. To compile java based programs you need JDK+JRE set up in your computer. Since java is pure object oriented programming language everything you do is under a class. It follows very strict typing and enforces casting of references.

JavaScript, which was developed to work in client side scripting but today its most widely used language. It is a scripting language that works in web browsers and is used in combination with CSS and HTML for modern, dynamic web development . It resides inside HTML documents, and can provide levels of interactivity to web pages that are not achievable with simple HTML. Javascript has extremely dynamic typing. It has only a single type of variable that can hold the values of any supported type of object, so no concept of casting . Although it was traditionally used mainly on the client-side, projects such as NodeJS and PhoneGap have expanded its use-cases to server-side and mobile development as well.

Differences:

  1. Java is a statically typed language while JavaScript is dynamic.
  2. Java is an OOP programming language while Java Script is an OOP scripting language.
  3. Java is class-based; JavaScript is prototype-based.
  4. Java runs in a virtual machine or browser while JavaScript runs solely in a browser
  5. Java code needs to be compiled while JavaScript code are all in text. They require different plug-ins.
  6. Java constructors are special functions that can only be called at object creation; JavaScript "constructors" are just standard functions.
  7. Java requires all non-block statements to end with a semicolon; JavaScript inserts semicolons at the ends of certain lines.
  8. Java uses block-based scoping; JavaScript uses function-based scoping.
  9. Java has an implicit "this" scope for non-static methods, and implicit class scope; JavaScript has implicit global scope.

Similarities:

Both share the same syntax which is based on C. On top of that, JavaScript follows the same naming convention and its Date and Math libraries were purely based on Java 1.0. Moreover, both have a strong web development community built around them.









net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.