brangerbriz / liBB.js

A JavaScript library/framework for creating interactive && generative apps + installations in/out of the browser
http://libb.brangerbriz.com/
GNU General Public License v3.0
1 stars 2 forks source link

Strict Mode #8

Closed brannondorsey closed 8 years ago

brannondorsey commented 9 years ago

We need to determine if we should 'use strict' mode for the modules. Most every new JavaScript resource recommends it.

brannondorsey commented 9 years ago

That MDN reference is a bit dense but it seems that the basics are:

Pros:

  1. Because JavaScript was designed and implemented quickly and with beginner developers in mind a lot of gnarly and bug producing code/syntax fails silently. Strict mode makes these gotchas throw errors instead to notify the developer of a problem or bad usage.
  2. Strict mode allows the JavaScript engine to make optimizations that often result in faster code than non-strict/normal javascript mode.
  3. Strict mode paves the way to start adopting principles and code that will become standard in future versions of ECMAScript.

Cons:

  1. Less relaxed JavaScript that occasionally differs from what you are used to (also a pro, see pro 1).

P5.js also uses strict mode and implementing it for us would basically be the same thing. We add use script as the inside of the first line in the define(...) callback of each module.

brannondorsey commented 8 years ago

"use strict" has now been implemented in the build branch.