I9u-MgPOaNk
Okay, okay, I’ll try to take this topic seriously…
To be honest, the major difference between these two languages is that Java has to be compiled, and JavaScript doesn’t (dynamically typed).
Java
Incredibly strict and very verbose. This language was created so people do not have to compile code into 3 different OS’s (Windows, Mac, Linux). The power behind that lies in the JVM which, for a small price in memory, allows you to run the same code in any Unix or Windows based system. Java was designed for Object Oriented Programming from the ground up with only a few primitives not being an Object (though there are Objects for all primitives).
Java’s biggest strength lies in its structure and documentation, as the strict syntax also promotes good coding practices. Heavily used by businesses, and had its foothold in mobile devices for a while. Recently has lost its foothold in website applications due to security breaches and strict entry to Applet and Webstart. Main competitors include C, C# and C++.
JavaScript
Very loose typed object oriented language. At its start, JavaScript (LiveScript) was used primarily to give developers the ability to react to user responses in a webpage. As developers wanted more power, JavaScript then grew to include more functionality to allow greater control over the web page with the strongest being AJAX, which allows direct control over any part of a web page in real-time without refreshing the browser.
However, JavaScript is a “browser” language and functions best when within a browser. It is a jack of all trades when it comes to languages, having aspects of imperative (like C), procedural (like Haskell), and Object Oriented (like Java). However, when trying to do any of those techniques outside simple web page edits the language becomes very ungainly and extremely verbose.
Despite this, JavaScript is a very dynamic language with a lot of flexibility. As of HTML5, it has gained a much needed speed boost that allows it to compete very evenly with Flash. It gives access to the WebGL interface which allows some 3D programming within a browser. Since JavaScript is built into every modern browser, it pretty much works right off the bat with anything that has one. (The only flaw is that JavaScript may be disabled on browsers at any time, and that usually breaks a lot of functionality (Google) since it isn’t guaranteed.) JavaScript pretty much owns a monopoly on client based web applications with no real competitors that don’t need a plugin.
What’s Better?
Apples to Oranges. The reason JavaScript was named JavaScript in the first place was because the people at Netscape said “Java” programming language was catchy due to its rising popularity. So they renamed LiveScript to JavaScript. However, I can’t say that is bad because it arises to topics like this so.
Generally, if you are designing for web… JavaScript is going to find its way into your code somewhere. It is pretty hard to design a fluid experience on the web without JavaScript these days. If you are designing for desktop, then Java is the language I choose. It is a lot easier to write code in Java opposed to JavaScript. I would argue that JavaScript really sets you up well for spaghetti code as everything gets so much more verbose as you move along. Java’s OO nature avoids this.
I’ve coded in both quite a lot, and they each have their strengths and weaknesses. But, I enjoy coding in Java a lot more than in JavaScript because it has a self-organizing structure. In JavaScript, I feel like I have to force structure in order for it to have structure. You can tell that even though it is Object Oriented (everything in JavaScript can be quantified to an Object), it is very disjointed and lacks organization.
There, see, something good can come out of this thread… ;D