Java and JavaScript – What's the Difference?

Author Topic: Java and JavaScript – What's the Difference?  (Read 4323 times)

Offline kazi shahin

  • Hero Member
  • *****
  • Posts: 607
  • Fear is not real
    • View Profile
    • Personal website of kazi shahin
Java and JavaScript – What's the Difference?
« on: August 24, 2010, 01:53:54 AM »
A web search shows hundreds of thousands of articles discussing the difference between Java and JavaScript. Most of these read much like my first set of notes for this article and talk about things like "object-oriented versus object-based" and "compiled versus interpreted." While factually correct, these classifications aren't that useful unless you are already familiar with programming language theory. If you are interested in learning to program, thinking about ways to add interactivity to your website, or otherwise just interested in results, then none of this is particularly useful.

So, what is important for beginners and non-technical people? The most important thing is knowing that Java and JavaScript are different languages. Both JavaScript and Java can run in a web browser. Both can be used to make more interactive web pages. JavaScript runs in in the browser itself and can affect how the entire web page, other web pages, and even the browser itself is displayed. Java runs as an something called an applet in a set portion of the web page. JavaScript pretty much only runs in a browser. A Java program can run pretty much anywhere – in your web browser, on your computer without using the web browser, on a cell phone, and maybe even on your refrigerator! In Java you need to write an entire syntactically correct (grammatical) program. In JavaScript, you can insert a line or two into a web page and if is is correct, it will run. This can make learning the language and debugging (finding and fixing problems) easier for a beginner. On the other hand, for the advanced programmer, Java has tools that make debugging easier. A web designer or web programmer probably should know JavaScript. (The web programmer might also want to know Java and some other languages.) A general purpose programmer is probably better off learning Java, along with several other languages – possibly including JavaScript.

If you are interested in learning to program, either language can be a good start and each programming language you learn makes it easier to learn further programming languages. If your interest is mainly in programming for the web, JavaScript is probably a better place to start but if you are more interested in Java or have better learning opportunities, go for it. If you are hiring someone to program for you, either language can be appropriate for a web application but the programmer should be able to tell you why they are using one language or the other.
Kazi Shahin                   
092-15-795
Department of CSE   
Cell : 01718 699 590
Blood Group: O+
Google + :  https://plus.google.com/u/0/101741817431143727344/about?hl=en
Facebook : http://www.facebook.com/kazishahin.rahman
Web : http://www.kazishahin.com/

Offline kazi shahin

  • Hero Member
  • *****
  • Posts: 607
  • Fear is not real
    • View Profile
    • Personal website of kazi shahin
Re: Java and JavaScript – What's the Difference?
« Reply #1 on: August 25, 2010, 11:53:35 PM »
Let's talk about how Java and JavaScript differ. They are both similar and quite different depending on how you look at them. First their lineage:
Java is an Object Oriented Programming (OOP) language created by James Gosling of Sun Microsystems. JavaScript was created by the fine people at Netscape. JavaScript is a distant cousin of Java. It is also an OOP language. Many of their programming structures are similar. However, JavaScript contains a much smaller and simpler set of commands than does Java. It is easier for the average weekend warrior to understand.

 The main difference is that Java can stand on its own while JavaScript must be placed inside an HTML document to function. Java is a much larger and more complicated language that creates "standalone" applications. A Java "applet" (so-called because it is a little application) is a fully contained program. JavaScript is text that is fed into a browser that can read it and then is enacted by the browser.

      Another major difference is how the language is presented to the end user (that's you when you're surfing). Java must be compiled into what is known as a "machine language" before it can be run on the Web. Basically what happens is after the programmer writes the Java program and checks it for errors, he or she hands the text over to another computer program that changes the text code into a smaller language. That smaller language is formatted so that it is seen by the computer as a set program with definite beginning and ending points. Nothing can be added to it and nothing can be subtracted without destroying the program.

      JavaScript is text-based. You write it to an HTML document and it is run through a browser. You can alter it after it runs and run it again and again. Once the Java is compiled, it is set. Sure, you can go back to the original text and alter it, but then you need to compile again.
Kazi Shahin                   
092-15-795
Department of CSE   
Cell : 01718 699 590
Blood Group: O+
Google + :  https://plus.google.com/u/0/101741817431143727344/about?hl=en
Facebook : http://www.facebook.com/kazishahin.rahman
Web : http://www.kazishahin.com/

Offline kazi shahin

  • Hero Member
  • *****
  • Posts: 607
  • Fear is not real
    • View Profile
    • Personal website of kazi shahin
Re: Java and JavaScript – What's the Difference?
« Reply #2 on: August 25, 2010, 11:55:03 PM »
Summary:

1. Java is an OOP programming language while Java Script is an OOP scripting language.
2. Java creates applications that run in a virtual machine or browser while JavaScript code is run on a browser only.
3. Java code needs to be compiled while JavaScript code are all in text.
4. They require different plug-ins.
Kazi Shahin                   
092-15-795
Department of CSE   
Cell : 01718 699 590
Blood Group: O+
Google + :  https://plus.google.com/u/0/101741817431143727344/about?hl=en
Facebook : http://www.facebook.com/kazishahin.rahman
Web : http://www.kazishahin.com/