Introduction to JavaScript

Ah, JavaScript. Goofy, demanding, delightful, JavaScript.

What other language offers the kind of instant gratification that causes newbies to gush with excitement? What other language seems to incite grave annoyance1 in some of those devoted to server side languages? What other language brandishes such enduring popularity while its hidden powers go unnoticed?2

I'll explain this phenomenon and the language itself by examining some misguided stereotypes pertaining to JavaScript, as well as recent implementations that are sure to prove its greatest ever potential.

"JavaScript is easy."

Allow me to complete the first part of that statement: JavaScript is easy to implement. A compiler is not needed for execution (this single characteristic is what differentiates scripting and programming) and scripts require only an interpreter, as is the case for Perl and Python.

It is true that the web's bountiful, prefabricated JavaScripts are easily copied and pasted into HTML documents, making JavaScript a perfect choice for beginners. Furthermore, since many of JavaScript's established uses - mostly pertaining to Web UI - require only short and sweet snippets, a person lacking programming experience can speedily acquire enough skill to put into practice many of its simple applications.

While this is great news for many of you, it is (understandably) the reason for the "it's easy" stereotype. It is also true that many people lacking traditional training have successfully used the language. So what? That is the case with nearly every web language. Besides, new and different styles spun off from "the old way" of doing things3 have historically permeated the usefulness of those things.

A Loosely Typed Language

Loosely typed, also known as dynamic, means that the type of data contained by a variable does not have to be declared. NOTE: If that sounds like Greek to you, don't worry - by the time you get through Tutorial 2's lessons, it'll be crystal clear!

Experienced programmers generally view loosely typed languages as being easier to use. But this characteristic can actually be detrimental to the inexperienced. This is because it can cause them to overlook the very important concept of data types. Can you imagine how difficult your life would be if you didn't understand the difference between a chair and a tomato? Nonetheless, I don't agree that because a language promotes ease of use, it is sub-par. On the contrary, it contributes to the language's prowess.

Forget Easy or Difficult - Think Useful!

Finally, in the context of script writing, it is a mistake to view simplicity as a negative. Even though my food processor is a powerful and complex machine with many parts, it will never replace my favorite knife. Likewise, although my DHTML form validation script is about 700 lines long (and really cool), it hasn't been nearly as useful to me as my 3 line fill-in-my-email-address-for-me script. If you can write a useful script, you can write a brilliant script.

"JavaScript isn't really object oriented."

JavaScript is object oriented. One reason for this misconception is that JavaScript is too often associated only with its Document Object Model objects (objects associated with HTML elements), leaving its core objects and, most importantly, its custom made objects4 often ignored.

"JavaScript is only a client side language for the Web."

JavaScript has historically been used almost exclusively as a Web client side language. "Client side" means that along with an HTML document, a script is downloaded from a web server, then executed on a visitor's machine. The result is a much faster programmatic reaction to a user's action than could be accomplished with a server side language5.

Although this client side benefit is one of JavaScript's greatest strengths, to a client side scripter's advantage, JavaScript can also be implemented server side. Did you know it can even used to write ASP pages? Or that Windows Scripting Host supports batch file-like JavaScripts? But the most exciting use yet is its recent implementation as a personal use utility language.

JavaScript for Personal Use

With the introduction of Firefox Extensions (see this great how-to tutorial), and Mac OS' Widgets, the possibilities for personal usefulness of JavaScript are not just expanding, they're endless! *See the View Rendered Source extension on this site for a great example. I expect this to take JavaScript from a know-just-enough language to a must-master-it language. There is no longer any excuse to put off learning JavaScript - what are you waiting for?

Must-Have JavaScript Book

For a physical supplement to this site, I recommend Danny Goodman's JavaScript Bible. You can also purchase this site in PDF format by clicking the following button:

>>Introduction To JavaScript
>>Troubleshooting JavaScript



Home | Contact