|
|
|
|
|
|
|
|
Java: Is it an island? Is it coffee? Is it the same thing as JavaScript?
|
|
|
|
|
Key Industries:
|
|
Business
|
|
Entertainment & Leisure
|
|
Gaming
|
|
Internet
|
|
Retail
|
|
|
Key Sectors:
|
|
Content Management
|
|
Design & Build
|
|
e-commerce
|
|
Games
|
|
Usability
|
|
|
04.06.2010
|
Java and JavaScript, the confusion is completely forgivable; they are both programming languages and the names bear more than a passing resemblance to one another. They’re almost guilty by association – surely they must be similar or at least derivatives of one another? Actually, no.
Technically, JavaScript isn’t quite a programming language, but a scripting language. That subtle difference does give an early indicator as to why the languages are in fact so different. Scripting languages usually sit on top of a core application (written in another programming language – like C++, Python or, err, Java) and allow limited manipulation of the core application’s functionality. The underlying application might expose several objects which the scripting language can access and manipulate.
Applying these principles to JavaScript, the underlying application is usually your web browser, and the objects it exposes are things like the current document (web page) and window (the browser frame containing the document). JavaScript can then manipulate these objects to produce effects such as animations, pop-ups / dialogues, or simply showing and hiding content amongst a huge variety of other abilities. The document object which your browser exposes to JavaScript contains all the HTML of the current web page, and JavaScript is free to add, remove, or change this content as directed by the appropriate script.
So then, what about Java? Java is a fully blown programming language – it does not sit on top of any other core application; in fact it can be used to create those core applications. It’s flexible too – it can be used to build Desktop applications, Server Side Web applications (via JSP) and – just for a bit of extra confusion – Client Side Web applications (via Java Applets, seldom seen in the wild). Java’s coup de grace when it stormed to prominence was platform independence – the same source code could be compiled on any machine which had a JVM installed – whereas more traditional programming languages of the time had to be compiled separately for different platforms such as Windows and Linux machines.
However, Java’s popularity, particularly in the web arena, has been declining steadily for a while now. Java Applets are slow, bug ridden and lack the power of Adobe’s Flash, and JSP’s popularity has long been eclipsed by easier alternatives such as PHP and more enterprising solutions like Microsoft’s .NET platform. This gives us an immediate head start when trying to determine if a piece of web page functionality is driven by Java or JavaScript – you can pretty much take a stab at it being JavaScript and you’ll probably be right. A Java applet signals its presence like a bull in a china shop; they can be slow to load, may prompt you to install Java on your computer, and are self contained within a web page.
The yardstick really is this: if the dynamic functionality isn’t a self contained element of the page (which would probably be Flash, or a rare-as-hen’s-teeth Java Applet), it’s probably JavaScript. Even if it is self contained, it’s more than likely to be Flash. If you’re sure it isn’t a Flash movie, you can pretty confidently refer to the functionality as JavaScript, and if you do turn out to be wrong for the one in a million times the functionality is powered by a Java Applet, you’ll more than likely be forgiven for the rare sighting of an Applet in the wild. Take a chance and shoot from the hip – just call it JavaScript. If you’re wrong, at least you should be able to understand why.
Nick Payne
Lead Developer, Coolpink
|
|
|
|
|
|
|
|
|