Chapter 1. Introduction and First Looks


JavaScript is one of the most widely used programming languages; it is also one of the most misunderstood. Its growth has exploded in the last few years, and most web sites use it in some form. Its component-based capabilities simplify the creation of increasingly complicated librariesmost providing effects in web pages that previously required the installation of an external application. It can also be tightly integrated with server-side applications that are created with a variety of languages and interface with any number of databases. Yet for all of this, JavaScript is often considered lightweight and unsophisticatednot like a "real" programming language.

In some ways, JavaScript is too easy to use. To its detractors, it lacks discipline; its object-oriented capabilities aren't really OO; it exists within a simplified environment with only a subset of functionality; it isn't secure; it's loosely typed; it doesn't compile into bytes or bits. I remember reading in a JavaScript introduction years ago that you shouldn't let the name fool you: JavaScript has little to do with Java. After all, Java is hard to learn.

So what's the reality? Is JavaScript a fun little scripting languagelightweight, helpful, but not to be taken seriously? Or is it a powerful programming language you can trust with some of your site's most important functionality? The reality of JavaScript, and hence the confusion, is that it's two languages in one.

The first is a friendly, easy-to-use scripting language built into web browsers and other applications, offering functions such as form validation and cool stuff like drop-down menus, color fades during data updates, and in-place page edits. Because it's implemented within a specific environmentusually a web browser of some formand within a protected environment, JavaScript doesn't need to have functionality to manage files, memory, or many of the other programming language basic components, making it leaner and simpler. You can begin programming in JS with little or no background, training, or even prior programming experience.

The second language, however, is a mature, full-featured, carefully constrained, object-based language, which does require more in-depth understanding. Used correctly, it can help web applications scale (increase their number of users) with little or no change to the application on the server. It can simplify web-site development and add a level of sophistication, making a good site appear even better to its visitors.

Used incorrectly, JavaScript can also open security holes to your site, especially when used in combination with other functionality, such as a web service or database form. It can also make a page unusable, unreadable, and less accessible.

In Learning JavaScript, I'm going to introduce you to both languages just described: the fun scripting language, as well as the powerful object-oriented programming language. More importantly, I'm going to show you how to use JavaScript correctly.




Learning JavaScript
Learning JavaScript, 2nd Edition
ISBN: 0596521871
EAN: 2147483647
Year: 2006
Pages: 151

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net