Introduction to JavaScript

Ah, JavaScript. Delightful, dynamic, powerful JavaScript.

What other language offers the kind of instant gratification that causes newbies to gush with excitement? What other language has secretly been taking over the world, both because of its hidden powers and ease-of-use? JavaScript. Yup.

Lets examine this phenomenon and the language itself by discussing its stereotypes, as well as some 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.

The web is full of prefabricated scripts that are easily copied and pasted, making JavaScript a perfect choice for beginners. Since JavaScript has almost exclusively been used for Web UI, and many useful implementations are but short and sweet snippets, a person lacking programming experience can speedily acquire enough skill to put it into practice.

So what? While this is (understandably) the reason for this stereotype, I have a hard time seeing this as negative. New and different styles spun off from "the old way" of doing things have historically permeated the usefulness of those things. 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.

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 scripter. 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 calculator and a book?

Forget Easy or Difficult - Think Useful!

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.

"Change the world. Hack and learn things. Hacking makes you fun." This is a quote from I love it!

"JavaScript isn't really object oriented."

Douglas Crockford has an excellent article on this subject. See also my Objects, Properties and Methods lesson, and my Homemade Objects lesson.

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

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 language2.

Although this client side benefit is one of JavaScript's greatest strengths, it 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?

Why strain your server when you can strain someone else's client?

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 your network with unnecsesary overhead, why would you?

Great Read

World's Most Misunderstood is now World's Most Popular

>>Introduction To JavaScript
>>Troubleshooting JavaScript


View Source | Home | Contact