Difference between Java and JavaScript
Results 1 to 5 of 5

Thread: Difference between Java and JavaScript

  1. #1

    Talking Difference between Java and JavaScript

    I've had quite a few people ask me this and I've decided to post an answer to this question. Most of you already know the difference between the two. For those of you who don't,
    read on. This article was taken from Here.
    It's a better explanation that what I could come up with..

    So... what is the difference between Java and JavaScript anyway?

    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.

    You may be wondering what OOP means by now. Object Oriented Programming is a relatively new concept, whereas the sum of the parts of a program make up the whole. Think of it this way: you are building a model car. You build the engine first. It can stand alone. It is an engine and everyone can see it's an engine. Next you build the body. It can also stand alone. Finally, you build the interior including the seats, steering wheel, and whatnot. Each, by itself is a object. But it is not a fully functioning car until all the pieces are put together. The sum of the objects (parts) make up the whole.

    Continuing with the model car example, when you built the engine, you didn't use any of the parts that would later build the seats (a 350 four-barrel engine with a seat belt sticking out if the piston would look pretty silly). The point is that all the parts that made up the engine were of a certain class of parts. They all went together. Ditto with the body and then the interior.

    The point is that in these languages, you build objects out of classes of commands to create the whole. Understand the terminology? Good. Moving along...

    Now let's talk about how Java and JavaScript differ. 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.

    Java applets run independent of the HTML document that is calling for them. Sure, they appear on the page, but the HTML document did little more than call for the application and place it. If the programmer allows it, oftentimes parameters can be set by the HTML document. This includes the background color of the applet of the type of text it displays, etc. The delivery of the applet is done through a download. The HTML document calls for the application, it downloads to the user's cache, and waits to run. JavaScript is wholly reliant on the browser to understand it and make it come to life.

    So, what are the benefits of using one over the other? There are several. If you can understand Java, it is amazingly versatile. Because of the size and structure of the language, it can be used to create anything from small Web page events to entire databases to full browsers. The program I use to track my advertising banners is Java.

    In my opinion, JavaScript's main benefit is that it can be understood by the common human. It is much easier and more robust than Java. It allows for fast creation of Web page events. Many JavaScript commands are what are known as Event Handlers: They can be embedded right into existing HTML commands. JavaScript is a little more forgiving than Java. It allows more freedom in the creation of objects. Java is very rigid and requires all items to be denoted and spelled out. JavaScript allows you to call on an item that already exists, like the status bar or the browser itself, and play with just that part. JavaScript is geared to Web pages. Java is geared toward where it is needed most at the time.

    Both will create great Web page events. Both can offer interaction between the user and your Web page. But they are not created equally by any means.

    So to answer the question of which to use where... use whichever fits your needs. That sounds like a cop-out answer, but remember that the applets and JavaScript are most often offered on the Net as fully functioning items. You simply grab them from the Net and use them on your page (provided you are given permission). There are many, many sites out there that do nothing more than hand out applets or JavaScript. Gamelan.com is a good one for applets. Take a look at javascripts.com for over 2300 free JavaScript scripts. The HTML Goodies Applet and JavaScript Tutorials will teach you how to implement these items on your pages. They will not teach you to write the languages, but rather instruct you on placing functioning applets and JavaScript scripts on your Web pages. It is a good introduction to the formats. Once you know how to get these pups on your pages, you'll understand more about their structures and can then more easily attempt to learn the language and create functioning JavaScripts or applets yourself.

    Hope this helps,
    Remote_Access_
    Share on Google+

  2. #2
    Member
    Join Date
    Nov 2001
    Posts
    65

    Talking

    Pretty good Remote_Access_ . I actually never knew how to explain to people the difference without getting into much technical detail.

    BTW, console1 on Novell 5 is made on Java. It is very, very slow. Do you think it is the language, it is bad written or it might be compatibility????.
    Todo lo que no me mata me hace mas fuerte...
    Share on Google+

  3. #3

    Re: Console1

    BTW, console1 on Novell 5 is made on Java. It is very, very slow. Do you think it is the language, it is bad written or it might be compatibility????.

    Well.. to be honest I don't know. It could be both. If I had to guess I would say that compatability is the problem.. but I'm not 100% sure on that. If you want to know for sure, try looking it up on that site or just go to Google and search for your answer there.

    Latr,
    Remote_Access_
    Share on Google+

  4. #4
    Senior Member
    Join Date
    Oct 2001
    Posts
    101
    How bout this as a difference:
    javac JavaClassName.java
    java JavaClassName

    compared to:
    http://www.somepage.com/myscript.htm

    BTW, console1 on Novell 5 is made on Java. It is very, very slow. Do you think it is the language, it is bad written or it might be compatibility????
    Probably a combination of the writing and the language, but most likely the language. Java is inherently slow. If you compared Java to C++ it would be like comparing the turtle and the hare.
    Share on Google+

  5. #5
    Token drunken Irish guy
    Join Date
    Sep 2001
    Posts
    2,813
    Sorry this dosent help but I love JavaScript and Im pretty nifty [not that good] at it.

    A shout out to all the JavaScriptors!
    Share on Google+

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

 Security News

     Patches

       Security Trends

         How-To

           Buying Guides