How to declare global variables when use strict; JavaScript mode

Incase you’re building a cross-environment (browser vs. node) api or framework and cannot rely on ‘window’ for setting global variables. Here’s the way I find that works best. The solution was offered in this stackoverflow post:

  "use strict";
  global.someVariable = "123";

Ask Question

Content, Structure, and Presentation

You’ve often heard this term but rarely ever seen the conceptual idea behind it. Well here it is, right from the W3C Web Accessibility Guidelines 1.0:

The content of a document refers to what it says to the user through natural language, images, sounds, movies, animations, etc. The structure of a document is how it is organized logically (e.g., by chapter, with an introduction and table of contents, etc.). An element (e.g., P, STRONG, BLOCKQUOTE in HTML) that specifies document structure is called a structural element. The presentation of a document is how the document is rendered (e.g., as print, as a two-dimensional graphical presentation, as an text-only presentation, as synthesized speech, as braille, etc.) An element that specifies document presentation (e.g., B, FONT, CENTER) is called a presentation element.

To clarify, the content conveys the message. The structure is the way the content is built or organized. Presentation is one of various ways to send the message (audio, speech, print, visual apps etc).

W3C follows up with an example:

Consider a document header, for example. The content of the header is what the header says (e.g., “Sailboats”). In HTML, the header is a structural element marked up with, for example, an H2 element. Finally, the presentation of the header might be a bold block text in the margin, a centered line of text, a title spoken with a certain voice style (like an aural font), etc.

JavaScript: Activation Scope and named functions

Are you able to spot the Error in this piece of code?

function hello(name){
    var sayHello = function(str){



Javascript’s Activation Object is an object which holds:

  • function arguments
  • any variables and (named) functions inside this function

It is my understanding that, — basically, it’s a container for all the local variables you can access by name inside a function, except for this.

Since Javascript is dynamically executed and not pre-compiled into a static execution tree, it explains why invoking sayHello() would cause an undefined error, it is because code execution has not reached the next line of processing yet. Variables are declared but not defined until execution reaches that line.

A workaround is to move the variable functions above the line that calls it Or, redeclare it as a named function which becomes defined and available to the execution context immediately:

function hello(name){
    function sayHello(str){


SELF Inspiration

My early career in software at IBM was rooted visually, graphically. I did interface design and worked with Photoshop extensively,  in-between slicing and coding my own UI’s. I hung with the big dogs and was awe inspired by the idea of ASP a back-end language and SQL. I was a brute “hacker”, stitching code together just to get buttons to work. Later in my career, I wrote SQL simply to query what i needed, ajax to pull it down and some awkward three-some to get HTML to represent my Photoshop designs.

Well, i ran into SELF accidentally and it transformed my thinking about programming. I use to think code. After SELF, I thought of the real world, computer language was just a way for us to convey thought at a high-level. Suddenly, my whole career took a spin and I left design to architect and build software in a quite different way as compared to most individuals. I guess I had an advantage over other developers who were still “scripting” and hacking, knew little about OO patterns and if they did, it was a robotic response to a problem. SELF is rooted in real world analogies, leverages directness and liveliness — it molds a different programmer all together. I highly recommend anyone needing inspiration look at the SELF Movie.

70-Year-Old Programmer Is Preserving an Ancient Coding Language on GitHub

Dave Shields, a 70 years old and retired programmer, is mainly interested in just one thing these days: preserving an obscure programming language called SPITBOL that he worked on in the 1970s and then abandoned for 30 years.

Pretty interesting, check out the full article:

SELF: Ancient Programming from 86′

Look to the real world to combine simplicity with power. – Randy B. Smith

Uniformity. Directness. Liveliness. – 3 core principals of the SELF environment that we don’t normally see in the throng of modern era programming languages. There is Material Design Principals when considering  User Interface design, but what if I told you that there was an ancient language which modeled the real world we live in?

Have a look at SELF. Since then, nothing like it has seen the light. It was ahead of it’s time.

Mixins in ECMAScript 6 – Akward, inconvenient, powerful.

So you’ve heard that ECMAScript 6 will sport “Mixins”. Some languages implement this feature as “Traits” or Shared Modules. The origin of the concept, I feel, was born in the language called SELF (a Sun Microsystems experiment, see:

In a simple explanation, traits, or mixins, is a language feature allowing classes of objects to share a common set of behaviors we call methods — or functions, perhaps even data properties. It is NOT inheritance, but some think of it as multiple inheritance. It is an arbitrary implementation for simple code reuse when inheritance does not make sense.

For example:
In building a game, the Character, Level or Weapon classes might all posses the ability to log messages to a console for debugging purposes, so a mixin called Loggable could be used to package up a few methods to be shared across the class hierarchy. This way, classes even though not related, might share this common trait. As you see, inheritance does not make sense logically or semantically. A Person is-not a Loggable. It does not sound right, it does not read right, it conflicts with the beauty of code and clarity.

here is the Ruby representation. It’s a beauty.

module Loggable
   def log (msg)
      puts msg

class Character include Loggable
   def jump

class Sword < Weapon  include Loggable
   def animate_blade
      log("do sword animation");


In Scala, It’s a beauty:

class Sword extends Weapon with Loggable {
   def animate_blade() { 
      log("do sword animation")

In ECMAScript 6:

var Loggable = Base => class extends Base {
  log(s) { }
class Weapon { }
class Sword extends Loggable(Weapon) { }

It gets ugly if you wanted 2 or more mix-ins:

class Weapon { }
class Sword extends Loggable(Localizable(Weapon)) { }

I don’t know. It’s powerful. Definitely not a beauty eh!