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 brandishes such enduring popularity while its hidden powers go unnoticed?1

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 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 things 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. 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 Document Object Model objects (objects associated with HTML elements), forgetting its core objects and custom made objects4.

"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 refers to a script that is downloaded from a web server and 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, and Mac OS' Widgets, the possibilities for personal usefulness of JavaScript are not just expanding, they're endless! *See the View Source Chart extension on this site for a great example. I expect this to take JavaScript from a know-just-enough language to a must-master language. There is no longer any excuse to put off learning JavaScript - what are you waiting for?

Final Point

Someone once asked me why you would use JavaScript when you can accomplish the same thing with a server-side language. My answer: Why strain your server when you can strain someone else's client? While that may seem flippant, consider this: if you don't have to burden yourself with network overhead, why would you?

"Change the world. Hack and learn things. Hacking makes you fun."

This is a quote from http://harikt.com/. I couldn't agree more.



>>Introduction To JavaScript
>>Troubleshooting JavaScript

Home | Contact