Thursday 12 July 2012

Why JavaScript is a good thing


Why JavaScript is a good thing

If you’re reading this book, you presumably have an interest in learning JavaScript,but I’d be remiss if I didn’t also present my thoughts as to why JavaScript is a GoodThing. The most important and obvious reason is that JavaScript is useful. A largeswath of the dynamic functionality that’s normal in today’s Web sites is accomplishedusing JavaScript.

In fact, much of this functionality is so expected by users,that not using JavaScript would be a noticeable omission. Moreover JavaScript

  • Can improve a site’s performance (e.g., thanks to Ajax)
  • Can be used to fix browser deficiencies, such as support for newer CSSfeatures
  • Can be used in mobile devices (depending upon the device)
  • Is entirely reliable, when done right
  • Pushes some of the processing onto the client and off of the server, easingthe server’s load

One of the great things about JavaScript is that the language itself is counterintuitivelyresponsible for undermining its own reputation. Or more simply put: youcan use JavaScript without really knowing it. While it’s true that using JavaScript wellrequires sound knowledge, using it some is quite easy. Moreover, because JavaScriptruns in the Web browser, anyone’s JavaScript code is readily viewable: When youencounter a feature or an effect on a page that you like, you can just copy the HTML,JavaScript, and CSS for your own purposes (I’m setting aside the moral and legalissues here).

By comparison, Java and C++ code are not easy to use piecemeal: Youreally have to know these languages to do much in them. Secondarily, compiledapplications make seeing the underlying code anywhere from hard to impossible.Finally, JavaScript is a Good Thing because someone else has almost certainlyalready figured out how to accomplish what you’re trying to do. This is true for allestablished languages, of course, but with JavaScript, perhaps because the code willalways be public anyway, smart programmers are inclined to share. Often, smartprogrammers create a public library or framework out of the snazzy code, too.

No comments:

Post a Comment