Free Games Forum
Free Games Games Forums Music Forums TV Forums

  Free Games Forum Home FORUM
HOME
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN
Rules & FAQ RULES / FAQ
REPORT SPAM

Free Games Forum: Game Technology: Javascript Coding:
The Difference Between Java and Javascript.

 

 


Iluvata
Enthusiast


Nov 12, 2006, 4:57 PM

Post #1 of 17 (708 views)
Shortcut
The Difference Between Java and Javascript. Can't Post

Well, Ive been noticing people think that Java and Javascript are really similar, when they actually arent that similar. For instance, Javascript is mainly incorporated into someone's web page. While Java is an actual programming language where you can create programs.

The cut and dry of it is:



Quote
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)..



Here they are in action for the hands on learner



Heres a little "demo" of a Javascript.


Code
table.clock {  
text-align: center;
border: thin dotted blue;
padding: 5px;
margin: auto;
}

td, input.clock2 {
text-align: center;
border: none;
font: bold .9em verdana, helvetica, arial, sans-serif;
padding-bottom: .5em;
}

Note, thats just a "Demo" of some Javascript.

Demo of Java


Code
Runtime  
runtime = Runtime.getRuntime();

long maxMemory
= runtime.maxMemory();

long allocatedMemory =
runtime.totalMemory();

long freeMemory
= runtime.freeMemory();

System.out.println("free
memory: "
+
freeMemory / 1024);


System.out.println("allocated
memory: "
+
allocatedMemory / 1024);


System.out.println("max
memory: "
+
maxMemory / 1024);

System.out.println("total free memory: " +
(freeMemory + (maxMemory - allocatedMemory)) / 1024);

As you can see, they actually have VERY FEW similarities.

Also, if your creating a RuneScape Bot in Java, you would use a De-ob. I could discuss them or go into greater detail, but this is just something I "whipped" up.



Hope this helpsTongue




(20:20:29) <+Varenagan> I love farting with an itchy anus. It helps.

(This post was edited by Peach Pit on Jan 2, 2007, 7:55 AM)



Sami_Taker
Senior Member

Nov 13, 2006, 6:29 AM

Post #2 of 17 (700 views)
Shortcut
Re: [Iluvata] The Difference Between Java and Javascript. [In reply to] Can't Post


In Reply To
table.clock {
text-align: center;
border: thin dotted blue;
padding: 5px;
margin: auto;
}

td, input.clock2 {
text-align: center;
border: none;
font: bold .9em verdana, helvetica, arial, sans-serif;
padding-bottom: .5em;
}


I believe that's CSS, not Java.


oh and

SAGE


wakka
Enthusiast

Nov 14, 2006, 1:12 AM

Post #3 of 17 (693 views)
Shortcut
Re: [Sami_Taker] The Difference Between Java and Javascript. [In reply to] Can't Post

i tihnk Sami is right, since it didnt work for me ;(


Wakka: I see that you are from that ******* forum, by the style of your typing.
Mark: It's called a font.



Sami_Taker
Senior Member

Nov 14, 2006, 8:51 AM

Post #4 of 17 (690 views)
Shortcut
Re: The Difference Between Java and Javascript. [In reply to] Can't Post

You are right about them being different though.

Javascript:

Code
<script type="text/javascript"> 
var d=10
if (d == 10)
{
window.location = "http://www.nyuuu.net"
}
</script>


^-^


oh and

SAGE

(This post was edited by Sami_Taker on Nov 14, 2006, 8:51 AM)


wakka
Enthusiast

Nov 15, 2006, 12:40 AM

Post #5 of 17 (683 views)
Shortcut
Re: [Sami_Taker] The Difference Between Java and Javascript. [In reply to] Can't Post

yea

EDIT:Sami i love your avatar
EDITED!


Wakka: I see that you are from that ******* forum, by the style of your typing.
Mark: It's called a font.



(This post was edited by wakka on Nov 16, 2006, 12:48 AM)


Sami_Taker
Senior Member

Nov 15, 2006, 3:32 AM

Post #6 of 17 (681 views)
Shortcut
Re: [wakka] The Difference Between Java and Javascript. [In reply to] Can't Post

Lol 'EDIT:' without the post being edited.
Ilu too ^-^


oh and

SAGE

(This post was edited by Sami_Taker on Nov 15, 2006, 3:32 AM)


Tex
Member


Dec 2, 2006, 3:28 PM

Post #7 of 17 (658 views)
Shortcut
Re: [Iluvata] The Difference Between Java and Javascript. [In reply to] Can't Post

the dif between java and javascript is the script duh lollolol


hewoo


Keyes
Member


Dec 4, 2006, 3:38 PM

Post #8 of 17 (645 views)
Shortcut
Re: [Tex] The Difference Between Java and Javascript. [In reply to] Can't Post

I should beat you for that but I'm too tired.


"98% of the teenage population will try, does, or has tried smoking pot. If you're one of the people that wonder where they get these crackpot statistics copy & paste this into your sig"


wakka
Enthusiast

Dec 28, 2006, 9:23 PM

Post #9 of 17 (611 views)
Shortcut
Re: [Keyes] The Difference Between Java and Javascript. [In reply to] Can't Post


In Reply To
I should beat you for that but I'm too tired.



Wakka: I see that you are from that ******* forum, by the style of your typing.
Mark: It's called a font.



-Pwnt-
Veteran


Dec 29, 2006, 4:39 AM

Post #10 of 17 (609 views)
Shortcut
Re: [wakka] The Difference Between Java and Javascript. [In reply to] Can't Post

I should beat Wakka for spamming. Stop it.


brb eating spaghetti


Jaymzanator
Enthusiast


Jan 1, 2007, 11:52 AM

Post #11 of 17 (599 views)
Shortcut
Re: [-Pwnt-] The Difference Between Java and Javascript. [In reply to] Can't Post

LOL
CSS...

The difference between j and jscript ...

Quote
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)..



(17:20) Taz:
and tazg is lol'in at you all the way from canada
(17:21) James:
lol canadians

(This post was edited by Jaymzanator on Jan 1, 2007, 11:53 AM)


Peach Pit
Veteran / Moderator


Jan 2, 2007, 7:56 AM

Post #12 of 17 (591 views)
Shortcut
Re: [Jaymzanator] The Difference Between Java and Javascript. [In reply to] Can't Post

I put that in his original post, thanks Jay.


bye.


Jaymzanator
Enthusiast


Jan 2, 2007, 11:53 PM

Post #13 of 17 (589 views)
Shortcut
Re: [Peach Pit] The Difference Between Java and Javascript. [In reply to] Can't Post

Tongueyour welcomeWink


(17:20) Taz:
and tazg is lol'in at you all the way from canada
(17:21) James:
lol canadians


roadkillx
Enthusiast


Apr 29, 2007, 9:39 AM

Post #14 of 17 (525 views)
Shortcut
Re: [Iluvata] The Difference Between Java and Javascript. [In reply to] Can't Post

Javascript is better to learn.


DON"T CLICK ME, I"M NOT A LINK


Sami_Taker
Senior Member

May 3, 2007, 12:29 AM

Post #15 of 17 (519 views)
Shortcut
Re: [roadkillx] The Difference Between Java and Javascript. [In reply to] Can't Post


In Reply To
Javascript is better to learn.


They are used for totally different things.


oh and

SAGE


mattyc033444
Member


Jun 7, 2007, 6:02 AM

Post #16 of 17 (468 views)
Shortcut
Re: [roadkillx] The Difference Between Java and Javascript. [In reply to] Can't Post


In Reply To
Javascript is better to learn.


Don't go saying that, that's an opinion, Javascript is more used for websites and fancy interactivity in certain other things, on the other hand Java is more used to create game content, or mathematical functions or calculators or online help or UIs for website panels or chatrooms and my opinion is Java is better to learn, but don't say that because none of them are better. It depends on what your job is.
Though I THINK Java is more complex and has alot more uses.


__________
Join here my new forums! Also, check the games out! Well, when it's finished! forums.biohazardgames.net


luke915
Member


Nov 13, 2007, 12:52 PM

Post #17 of 17 (376 views)
Shortcut
Re: [mattyc033444] The Difference Between Java and Javascript. [In reply to] Can't Post

Java ?


I am a noob.

 
 
 


Search for (options) Web Design by Web Ideas - Page loaded in: 0.24 s on (CGI/1.1)