+ 3
[DUPLICATE] what is the difference between Java and JavaScript?
what are the differences? if i learn java, can i program in JavaScript? is JavaScript harder or easier?
4 Answers
+ 12
Here are some differences between the two languages:
Java is a statically typed language; JavaScript is dynamic.
Java is class-based; JavaScript is prototype-based.
Java constructors are special functions that can only be called at object creation; JavaScript "constructors" are just standard functions.
Java requires all non-block statements to end with a semicolon; JavaScript inserts semicolons at the ends of certain lines.
Java uses block-based scoping; JavaScript uses function-based scoping.
Java has an implicit this scope for non-static methods, and implicit class scope; JavaScript has implicit global scope.
Here are some features that I think are particular strengths of JavaScript:
JavaScript supports closures; Java can simulate sort-of "closures" using anonymous classes. (Real closures may be supported in a future version of Java.)
All JavaScript functions are variadic; Java functions are only variadic if explicitly marked.
JavaScript prototypes can be redefined at runtime, and has immediate effect for all referring objects. Java classes be redefined in a way that affects any existing object instances.
If you want to learn any of the two, I'll suggest that you learn Javascript first. Javascript is somehow easy to learn.
JavaScript allows methods in an object to be redefined independently of its prototype (think eigenclasses in Ruby, but on steroids); methods in a Java object are tied to its class, and cannot be redefined at runtime.
+ 6
The main differences are;
1. Java is an object oriented programming language, Java Script is an object oriented scripting language.
2. Java applications can run in a virtual machine or browser, JavaScript code can only run in a browser.
3. Java code has to be compiled, JavaScript code is all in text.
They are two different languages so learning one does not mean you can program the other but learning any language will make it easier to learn a new one, as most of the concepts are the same.
Its down to the individual but I would say js is easier but less useful unless you are planing to be a web developer.
Hope this helps.
+ 3
Does Java and JavaScript complement one another though?
Like will I be able to do more (in terms of projects) having these two languages under my belt?
0
what prototype?