Home » Technology » Java and JavaScript

Java and JavaScript

I have been doing a lot with JavaScript lately at my work and wanted to explore the differences between Java and JavaScript here.  I have gotten the question about what the difference is between the two a couple of times and decided I needed to really know the answer, instead of blundering around the answer.

I found this website, HTML Goodies, which had a very helpful article about the similarities and differences between the two.  And after poking around the whole website, I decided to bookmark it for future reference.  They’ve got lots of great information about all things HTML, CSS, JavaScript, and more.  I also found some good information in this book, Beginning JavaScript 4th Edition, by Paul Wilton and Jeremy McPeak.  Another great article is Java vs. JavaScript:  What’s the Difference? from Segue Technologies.

Let’s dig in.

Java JavaScript
  • Object-Oriented Programming language (OOP)
  • Created by James Gosling of Sun Microsystems
  • Creates great web page events
  • Can provide interaction between user and Web page
  • Object-Oriented Programming language (OOP)
  • Created at Netscape, originally known as LiveScript
  • Structures are similar to Java
  • Creates great web page events
  • Can provide interaction between user and Web page
  • Java can stand on its own
  • Larger and more complex, can be used to create ‘standalone’ applications
  • Strict
  • Need all items spelled out clearly
  • Must be compiled into ‘machine language’
  • Once compiled, it is set and can be run multiple times
  • Can change original code, but will need to re-compile before running
  • Java applets (small applications) run independent of the HTML document that is calling for them
  • Delivery of Java applet is done through a download to the user’s cache
  • Compiled usually just one time and then can be referred to multiple times.
  • Spanish to English translation example:
    • Restaurant menu written on paper – it doesn’t need to be re-translated each time you look at the menu
  • Much simpler, fewer commands
  • Must be placed inside HTML
  • Text-based, interpreted by the browser, not compiled (computer does not understand JavaScript until it is converted/translated into machine code, binary 1’s and 0’s)
  • Must be re-interpreted each time the code is run
  • You can alter it after it runs and run it again and again.
  • JavaScript relies on the browser to understand it and make it come to life
  • Some commands are known as Event Handlers
  • Spanish to English translation example:
    • Live conversation = What did he say?
      • “Buenas Dias.”
    • What did he say now?
      • “Buenas Dias.”

There are lots of JavaScript scripts (one example)  and Java Applets too (one example) available on the internet.

* A note about OOP – it’s short for Object Oriented Programming.  The program contains objects.  A very good example that I have run across multiple times is the car.  A car contains an engine, which is an object.  The engine can be an engine all by itself, so it is it’s own object.  The seats are objects too.  The transmission is an object.  The steering wheel is an object, and so on.  All of these objects exist on their own, but it is not a total and complete car until all of the ‘objects’ are put together to make up the car.  Another key point is that the different objects are made up of certain classes of parts.  Engine parts don’t belong in the interior and leather trim and lug nuts don’t belong in the engine.  The object called Engine is made up of the class of parts called EngineParts.  The object called Interior is made up of the class of parts called InteriorParts.

Thoughts?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s