coding, graphics, web design, web development

More Coding as Cooking

Four years ago, I published a post on computational thinking entitled, Like to cook? You’ll love JavaScript.

Photo: Chefs at Work by Michael Browning on Unsplash
Chefs at Work (Photo by Michael Browning on Unsplash)

Accordingly, I was tickled to see another web developer (Linton Ye) applying a JavaScript-as-cooking metaphor: What Is Redux: A Designer’s Guide:

Imagine there’s a chef living in each component. Fetching data from servers is like sourcing all the ingredients needed to prepare dishes.

These little chefs are easy to imagine: Ye’s article includes some tasteful illustrations of the little chefs running around. State management in Redux can be pretty dry, and the chef metaphor makes this abstract concept more digestible.

As icing on the cake, Ye also serves up his take on the “real power of Redux,” i.e., the predictability it brings to application development through its rules for data and its use of pure functions.

— Edward

P.S. I was hoping to extend this culinary metaphor even further, having noticed that Redux middleware follows a currying pattern (as illustrated by this code sample from the Udacity Nanodegree Course on React and Redux by Tyler McGinnis):

const logger = (store) => (next) => (action) => {
// ...

Alas, “currying” is named after Haskell Curry, a mathematician, not the curry spice blend.

coding, web design, web development

Pace of Change

Has any other career field seen as much change as web development — especially the kind of open-source front-end web development the cool kids are doing?

Many of the in-demand tools, such as Angular, didn’t even exist a few years ago. (And it’s still changing — in the time it took to type that sentence, Angular was made obsolete by Angular 2.)

So what does this mean for front-end web developers like me?

It means an absolute ****-ton of new stuff to learn.

In this video, at 8’49”, one of the Digital Ocean folks, Joel Califa, presents an abridged list of some of these things:

As he mentions, the list really is much longer — what about Ionic, Cordova, JasmineJade, SASS (not the old syntax, but the new one)/LESS, TypeScript, etc., etc., etc.?

It also means a kind of identity crisis. I’ve considered myself to be one of the rare, hybrid, “purple unicorn” web designer-developer types he described in the first part of the video.  In 2009, I went to Midlands Tech to study both coding (Java, SQLJavaScript, HTML, CSS) and the Adobe Creative Suite Tools (PhotoShop, DreamWeaver, Flash, etc.). . . . Yep, Flash.

. . . . However, since then I have worked for two years in a LAMP shop and then another two in an enterprise .NET shop.  I’ve coded and deployed a native Android app, and have configured my own Linux VPSs from scratch.  My interests lately have been in exploring full-stack web development using Mongo, Angular 2 (and React), Express, and Node – the so-called “MEAN” and “MERN” stacks. . . .

. . . . So am I still a “front-end” web developer?  My web certificate was in “web design”, but am I really a “designer” anymore?

Thankfully, he does give some solid steps for prioritizing a learning path and saving some sanity (apologies for the potty mouth).

There comes a point, too, where one has to not worry about titles and labels. . . .  (Years ago, I tried to explain/sell myself as someone with the “T-shaped” skill set mentioned in the video, and no recruiter or hiring manager had any idea what I was talking about.)

. . . .But, rather, just get to the business of building elegant, useful digital things that live on the Internet. . . .

web development

Measuring My Blog’s Emotional Tone with IBM Watson

[Original post, from 2015-12-09:]

I developed a WordPress plugin that shows the emotional tone of blog posts using the “experimental” IBM Watson Tone Analyzer API.

My plugin extracts the contents of a blog post and sends it to the IBM Watson Tone Analyzer API, which returns scores for several attributes, including the three attributes of emotional tone that IBM has found to be most salient, viz. cheerfulness, negativity and anger.

According to IBM:

  • Cheerfulness refers to positive emotions such as joy, optimism, contentment, inspiration, and happiness.
  • Negative emotions include feelings of fear, disgust, despair, guilt, rejection, and humiliation.
  • Anger is a type of negative feeling with strong intensity such as annoyance, hostility, aggression, hurt, frustration and rage.

Finally, the plugin pulls these scores from the API response body and displays a simple bar graph.

The cognitive science behind their analysis is a bit beyond me.  It appears to look for emotitone of post bar chart (using IBM Watson)onally loaded words. For example, if you put the word “lousy” in your post, it will bump the negativity and anger scores way up… (Note how the word “lousy” in this post results in high “negativity” and “anger” scores in the bar chart. )

This product has interesting implications. I’m guessing someone in advertising somewhere is doing A/B testing on copy to see if more “cheerful” ads sell more widgets….

For Further Reading

Rama Akkiraju, IBM Watson Tone Analyzer – new service now available, (July 16, 2015).

Update: The State of My Emotional-Tone-Measuring WordPress Plug-In

[Update of 2016-02-26:]

IBM updated the API used by my plugin in February, which broke my implementation of it.

(Such is the nature of using random, free, experimental APIs….)

From “Experimental” to “Beta”

Their Tone Analyzer API has been promoted from “Experimental” status to “Beta”.  The new version adds some significant enhancements.

This WP plugin project was a proof-of-concept done for giggles. No client; no budget.

I consider the concept to be proven and have moved on to the next adventure.


coding, graphics, mobile, ui, web design, web development

Winning Hackcess to Justice (NC)

It was a pleasure to meet Raleigh attorney Caroline DiMaio this weekend and to advance her vision of an app to help inform migrant workers of their legal rights.

Our creation placed first out of five entries at the Raleigh edition of Hackcess to Justice, a hackathon presented by the ABA Journal and the N.C. Bar Association.  The competition was held at Campbell Law School and sponsored by Citrix ShareFile, Lawyers Mutual, and Poyner Spruill, LLP.

(It’s kind of a small world: I learned of this hackathon from Matthew Wilcut, a legal-aid attorney (and developer!) I met at a Startup Weekend competition in Greensboro a few years ago.)

Press Coverage

“App to aid migrant workers wins 3rd Hackcess to Justice hackathon” (ABA Journal)

“Code of law: ‘Hackathon’ gives birth to ideas for bridging the justice gap” (N.C. Lawyers’ Weekly) (Subscription Required)

Official Contest Site

Learn more about the competition, including the esteemed panel of judges, the judging criteria, and other entries at the official site:

Hackess to Justice (NC) on Devpost

(As a developer with a long history in and around the legal profession, I was impressed by each of the other entries – I could see any of them in production!)


We developed our entry using rapid prototyping techniques and the Bootstrap JavaScript/CSS framework.

Screencap of NC Farmworkers' App (Interactive Prototype)
Screencap of NC Farmworkers’ App (Interactive Prototype)

coding, web development

Closures in JavaScript, a Quick Primer

“To page authors coming from a traditional OO (object oriented) or procedural programming background, closures are often an odd concept to grasp, whereas to those with a functional programming background, they’re a familiar and cozy concept.”

Bibeault and Katz at 428-29.
Chapter on Closures in JavaScript Ninja Book

Definitions of “Closures”

Q.: Just what is a “closure”? Is it a function? A scope? An object?

A.: Yes.

“A closure is a special kind of object that combines two things: a function, and the environment in which that function was created. The environment consists of any local variables that were in-scope at the time that the closure was created.”

Closures have also been called

“the scope created when a function is declared that allows the function to access and manipulate variables that are external to that function. Put another way, closures allow a function to access all the variables, as well as other functions, that are in scope when the function itself is declared.”

Resig and Bibeault at 90.

Put yet another way, a “closure is a Function instance coupled with the local variables from its environment that are necessary for its execution.”

Bibeault and Katz at 429.

“A function declaration and its environment form a closure allowing the function, when later invoked, to access those local variables that become part of the closure.”

Bibeault and Katz at 431.

In most languages,
“when a function is declared, it has the ability to reference any variables that are in its scope at the point of declaration. . . . With closures, these variables are carried along with the function even after the point of declaration has gone out of scope, closing the declaration.”

Bibeault and Katz at 429.

“In other words, the function defined in the closure ‘remembers’ the environment in which it was created.” MDN. This is one of the “good parts” of JavaScript: With nested functions, “inner functions get access to the parameters and variables of the functions they are defined within (with the exception of this and arguments). Crockford at 37.


A popular closure answer on Stack Overflow shows the following example syntax:

function foo(x) {
    var tmp = 3;
    function bar(y) {
        console.log(x + y + (++tmp)); 
        /* will log 16 */

“This will always alert 16, because bar can access the x which was defined as an argument to foo, and it can also access tmp from foo.

That is a closure. . . . Simply accessing variables outside of your immediate lexical scope creates a closure.”

Note that the above example features an inner function and an outer function – when you see nested functions, it should trigger thoughts of closures.

Implications for Development

“While scores of page authors get along writing on-page scripts without understanding the benefits of closures, the use of closures can not only help us reduce the amount and complexity of the script necessary to add advanced features to our pages, they allow us to do things that would simply not be possible, or would be too complex to be feasible, without them.”

Resig and Bibeault at 89.

In other words they have an “ability to drastically simplify complex operations.” Id.

For example, “the ability for callback functions to reference the local variables in effect when they were declared is an essential tool for writing effective JavaScript.” Bibeault and Katz at 429.

Emulation of “Private” Methods through the Module Pattern

In JavaScript, methods cannot be declared “private,” meaning that they can only be called by other methods in the same class. However, this can be emulated in JavaScript, especially by using the module pattern. See MDN and Ben Cherry, “Module Pattern in Depth”. Also see Angus Kroll, “Function Delarations v. Function Expressions”.

Cautionary Notes

It is possible to inadvertently create closures in JavaScript as they can be created without explicit syntax (unlike in other languages). Bibeault and Katz at 430. This can cause issues.

Memory Leaks

“It is unwise to unnecessarily create functions within other functions if closures are not needed for a particular task, as it will negatively affect script performance both in terms of processing speed and memory consumption.” MDN. For example, “circular references can lead to memory leaks. A classic example of this is the creation of DOM elements that refer back to closure variables, preventing those variables from being reclaimed.” Bibeault and Katz at 430; also see IBM.

Creating Closures within Loops

Also, see MDN for an example of possible problems when closures are created within loops.

mobile, Uncategorized, web development

All I Got Was This Lousy T-Shirt!

This weekend I participated in the official Mobile Developer Week.

All I got was this lousy T-shirt:

Official Salesforce Mobile Developer Week T-shirt Official Salesforce Mobile Developer Week T-shirt

OK I did get some good learning as Salesforce developers from Raleigh to Charlotte were introduced to Salesforce’s new mobile tools. We also hacked out a simple mobile-cloud app.

OK, so the shirt’s not that lousy — the shirt is American Apparel 100% cotton, with some spiffy multi-color screen-printed graphics — And I didn’t find a single louse on it. Plus, they gave us some pretty good chow from O. Henry Hotel‘s catering department.

But the key take-aways for me were meeting some very talented developers and learning more useful stuff about cloud & mobile… I’m grateful to SFDC and the organizers for putting on a very useful workshop.

coding, process, web development

Adzerk Rebuilt Its Ad Server with Node.js

It’s always fun to visit the Triangle and see what the cool kids are working on…

Why Node?

I went to Adzerk in Durham yesterday to see how their team re-built its ad server with node.js, the exciting new server-side JavaScript technology.

So what does an ad server do? It serves ads. (You’re welcome.) For example, say you visit — Adzerk’s ad server will determine which ads you see on the sidebar. Someone visiting the site from Austin, Texas on a Sunday afternoon using Chrome would see a different ad than someone in Australia.

Obviously, speed is a priority, and Adzerk’s ad server has been processing 10,000 – 16,000 requests per second. There is no time for database calls, so they use a ginormous JSON blob.

No database
There is no database

So Node.js is ideally suited for this kind of thing — responding to a ton of requests very quickly. Nate Kohari of Adzerk explained that it would be less useful for web apps that required a lot of intense processing of each request.

While I love seeing how other folks build these kinds of cutting-edge web apps, I told my CIO that hanging out with the node.js folks made me feel like I had rented a programmer costume from the Halloween store or something.


coding, web development

Hello, World!

Is there a better first statement than “Hello, World!”?

It carries the same powerful message as “Greetings, Planet! I’m here. Deal with it!” in a compact, pithy package.

Many programming students wrote “Hello World” as their first output.  (The original such use is widely attributed to Brian Kernighan of Bell Labs.)

Ways to Say It

The syntax required to produce “Hello World!” gives you a flavor of the language.

In Java one would type the following:

class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!");

In JavaScript, one would code the following:

document.write('Hello, World!');

A PHP programmer’s first line is typically something like this:

echo "Hello, world!";

This syntax hints that it’s a lot easier to get up and running in JavaScript or PHP than in Java (The further implications of that suggest a subject for another day).

It’s fairly easy to get started with WordPress — the platform does the actual coding for you.

Ways to Say It, Part 2

But what is in between the quotes?  Doesn’t that say something about the programmer’s (human) language?

Shouldn’t there be a comma in “Hello World”?  In English, commas are used to set off words of direct address, and you’re directly addressing the World.  Speaking of which, “World” should be capitalized – you’re not addressing any world, you’re addressing THE World — by name!  And an exclamation point, for that matter — First impressions count – don’t you want to be seen as enthusiastic about your very first output!

So, “Hello to you, World — hello!”