-
Notifications
You must be signed in to change notification settings - Fork 20
Java ≠ JavaScript
Java and JavaScript are not related at all. The name may suggest that JavaScript is based on Java, but it is not. There are much more differences than similarities.
They are about as much related as German and English. Those are both West Germanic Languages and are both influenced by Latin. But someone who only knows English won’t understand something written in German and vice versa.
Java and JavaScript are both influenced by C++ (about as much as German/English are influenced by Latin). Still they are completely different languages.
Android uses a language that is actually based on Java, but it has to be compiled to special byte code. Oracle sued Google and now they will replace Java with Kotlin.
All these statement are true:
- English: English is not German.
- German: Deutsch ist nicht Englisch.
- Java:
!"Java".equals("JavaScript");
- JavaScript:
'JavaScript' !== 'Java';
- Name of a Programming Language
- Name of a Software Platform
- Was developed by Sun Microsystems, now owned by Oracle
- Runs in a Java Virtual Machine (JVM)
- Is class-based object-oriented
- Is also the name of an Island of Indonesia
- Name of a Programming Language
- Is formalized in the ECMAScript standard
- Runs in a JavaScript-Engine, often inside a Web Browser
- Is prototype-based object-oriented
- Supports classes since ECMAScript 6 released in 2015
- Was originally called Mocha, then shipped as LiveScript, and later as JavaScript.
Most web applications use JavaScript. Those that use Java usually also use JavaScript. In most cases Java is used on the servers (to run business logic) and JavaScript in the web browser. If a template system is used then the servers need to create HTML documents from templates. This is often done with Java frameworks. Then the document is sent to the user and JavaScript may dynamically modify that document in the browser. So both work with HTML documents but can also do many other things that are not directly related to HTML. However, Java can run in a web browser (using a plugin, which is now disabled by default) and JavaScript can run on a server (node.js).
Instead of a combination it is possible to use a JavaScript framework and a thin server-side interface to the backend (e.g. REST). Then most of the code of a project is JavaScript.
Or the frontend and backend are implemented in Java (Swing or JavaFX) and do not use any JavaScript.
Java code can be translated to JavaScript. This is the job of a compiler (a compiler is a translator). In this case you could use GWT or another cross-compiler. But many things won’t work. The languages are simply too different to be able to just translate code from one to the other language.
To run JavaScript in a JVM you would probably just run it in Nashorn. That is a JavaScript engine inside a JVM.
For additional information about JavaScript, visit ecmascript.org and mozilla.org/js/.
For additional information about Java, visit openjdk.org or java.oracle.com.
Our Group on Facebook: https://www.facebook.com/groups/Javagroup123/
The Rules (read them!): https://github.com/Javagroup123/group/wiki/Rules
Frequently Asked Questions: https://github.com/Javagroup123/group/wiki/FAQ
Recommended Books: https://github.com/Javagroup123/group/wiki/Recommended-Books