|
|
|
Java is Not Javascript
What's the difference between Java and Javascript in web design, you ask?
- Javascript is good.
- Java is bad.
Allow me to elaborate.
Java broke ground because of its ability to run executable code on different platforms. Before Java, a Windows program needed to be written in Windows-friendly code, and its Macintosh counterpart needed to be written in Mac-friendly code, and its Unix counterpart... well, nobody ever bothered writing Unix versions of programs. But if they did, they'd need to do so in Unix-friendly code.
Along came Java and its two forms of existence: the Applet and the Application. The Application still required some operating system-based tweaking, but the applet.... AH, the applet! You could now write an applet, or mini-application, that would run on any system.
Provided the user had a Java engine installed on their machine. These Java engines come standard with web browsers, so it wasn't much of a problem, since applets were meant to be embedded in web pages anyhow.
And oh! what you could do with the applet! You could make an interactive program, running complex graphics and mathematical functions, and every machine would run it!
But like all things good, there was a catch.
The Java engine in a user's browser takes a long time to load. Which means visitors to Java-enhanced pages saw drastic slow-down times. And when it comes to web-surfing, if it's not fast, we're furious.
Couple that with the rise of Flash -- the wondrous vector-based graphics plug-in that gives such beautiful animations and movies -- and Java's epitaph was set in stone.
(To be fair, Java is still used for lots of networking applications, and although I still say it's too slow and incompatible with many Windows features - *cough* mouse scroll wheel *cough* - my programming friends swear by Java. Rather than at it.)
On the Other Hand, Javascript
Javascript is a scripting language based on the Java programming language. The difference? You can't compile code with a scripting language. You can only feed your script into an interpreter to have it then run your code.
Let me explain it another way. A compiled program is like a machine a programmer has built to accomplish certain tasks. Word processors, spreadsheets, instant messengers, and video games are all compiled programs. A script is a set of instructions that you pass to one of those machines, rather than being a machine itself.
A program can be built to do whatever you want. A script can only do what the programs in which it runs allow it.
In terms of web programming, the browser (Netscape, Internet Explorer) is the program that runs the script.
Javascript is embedded in a <SCRIPT> tag. You can see it just like you can see the HTML that makes a page, by right-clicking on the page and selecting "View Source". (Sometimes Javascript is somewhat hidden by a tag that reads something like "<SCRIPT src=somefilename.js>" If you want to see that file, you just type the name into the address bar like you would any other web page -- you will then be able to download the file, save it to your computer, and open it in Notepad or the text editor of your choice.)
Javascript gives us alerts, mouseovers events, heirarchal menus, and much more. It is fast, small, and powerful. Almost every professional page on the web uses Javascript in one place or another.
The catch? Well, you need to watch for different browsers, as they interpret your script in different ways. Some things may work in Internet Explorer that would cause a little error in Netscape, and vice-versa. (The error shows up as a small exclamation point/warning sign in the status bar at the bottom of the browser.) But if you've coded well, your script can detect which browser it is running in, and execute accordingly so that nobody receives an error. Pretty cool.
Also, Javascript is a language. It's harder to learn than just HTML. (Although HTML claims to be a language, too.) If you decide to start teaching yourself Javascript, note that you're opening a door to all sorts of wonderful new roads, some of which lead into the lava-pits of code bugs, debugging headaches, and frustration. Other roads lead to success, excitement, and the thrill of prograsm.
|
All content ©2005-2009 Randy Tayler
| | | | |
| | |
|