JavaScript: The 10-Day Prototype at Netscape
It’s late 1995, and the "Browser Wars" between Netscape and Microsoft are heating up. Netscape needed a way to make the Web more interactive-something simpler than Java for "regular" developers. Brendan Eich was tasked with creating it, and he supposedly knocked it out in just ten days. Originally called Mocha, then LiveScript, and now "JavaScript" (thanks to a marketing deal with Sun), it's finally shipping in Netscape Navigator 2.0.
A Mix of Ideas
JavaScript is a strange beast. It takes the syntax of Java (to please the marketing department), the first-class functions of Scheme, and the prototypal inheritance of Self. It doesn't have classes, it has "objects that inherit from other objects." It’s loosely typed, which is already making some of my C++ colleagues cringe, but the flexibility is perfect for small scripts on a webpage.
// A simple script in the browser
function greet(name) {
alert("Hello, " + name + "!");
}
// Interacting with the document
document.write("<p>The current time is: " + new Date() + "</p>");
greet("Web Developer");
The "Glitchy" Reality
Because it was built so quickly, there are some... interesting design choices. The global scope is a mess, and the way it handles this can be confusing. But the ability to manipulate the Document Object Model (DOM) on the fly is powerful. We can finally do form validation without a round-trip to the server!
Looking Ahead
Some people are dismissing JavaScript as a "toy language" for making things blink or scroll in the status bar. But I think they're missing the point. By putting a scripting engine in every browser, Netscape has turned the Web into a programmable platform. As the engines get faster and the DOM matures, we're going to see applications we can't even imagine yet. It might be messy, but it’s going to be everywhere.