Skip to Content
Supercharged JavaScript Graphics
book

Supercharged JavaScript Graphics

by Raffaele Cecco
July 2011
Intermediate to advanced content levelIntermediate to advanced
278 pages
7h 20m
English
O'Reilly Media, Inc.
Content preview from Supercharged JavaScript Graphics

Chapter 1. Code Reuse and Optimization

JavaScript has an undeservedly dubious reputation. Many people have written about its limitations as an object-oriented programming (OOP) language, even questioning whether JavaScript is an OOP language at all (it is). Despite JavaScript’s apparent syntactic resemblance to class-based OOP languages like C++ and Java, there is no Class statement (or equivalent) in JavaScript, nor any obvious way to implement popular OOP methodologies such as inheritance (code reuse) and encapsulation. JavaScript is also very loosely typed, with no compiler, and hence offers very few errors or warnings when things are likely to go wrong. The language is too forgiving in almost all instances, a trait that gives unsuspecting programmers a huge amount of freedom on one hand, and a mile of rope with which to hang themselves on the other.

Programmers coming from more classic and strictly defined languages can be frustrated by JavaScript’s blissful ignorance of virtually every programming faux pas imaginable: global functions and variables are the default behavior, and missing semicolons are perfectly acceptable (remember the rope mentioned in the previous paragraph?). Of course, any frustration is probably due to a misunderstanding of what JavaScript is and how it works. Writing JavaScript applications is much easier if programmers first accept a couple of foundational truths:

  • JavaScript is not a class-based language.

  • Class-based OOP is not a prerequisite for writing ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Graphics, Games, and Sound with JavaScript

Graphics, Games, and Sound with JavaScript

O'Reilly Media, Inc.
Third-Party JavaScript

Third-Party JavaScript

Anton Kovalyov, Ben Vinegar

Publisher Resources

ISBN: 9781449311162Errata Page