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.

Debugging

These days, I’m doing a lot of debugging and testing.  It doesn’t feel very glamorous, but I know that it is extremely important, not only to the end user’s experience, but also to the integrity of your product.  I found this quote recently: “Debugging is the process of testing, finding, and reducing bugs (errors) in computer programs.  The first known computer bug was a real bug (an insect), stuck in the electronics.”
Cute – I always wondered where that phrase/word came from.

Just recently, I found a misspelled word on the footer of our program.  It’s a pet peeve for me and I have submitted the updated file with the correct spelling.  Your company website, your software product, and everything else projects an image about your company to the world.  If you have an outdated website, but claim to have a really cool/great software product, I’m probably going to be a bit skeptical.  There’s a saying that ‘image is everything.’  The substance of the product is important, but if I can’t get past the outdated website, it doesn’t matter how great the product is.

I’m also learning a lot about JavaScript and have been spending time here reading up on it.  They say that the best way to learn a language is to immerse yourself in it, and I have found that to be true for coding as well.  Taking a class on JavaScript is one thing, but working with JavaScript (and HTML, CSS, SQL, XBasic, etc) everyday takes it to a whole other level.