Introducing GOTOJS: Sequential Programming for JavaScript

With all the Javafication of JavaScript still going around today, I'd like to take the conversation in another direction and humbly introduce GOTOJS.

It's a lightweight, low-level library that:

  • Introduces proper sequential programming based on line numbers, something sorely missing from JavaScript
  • Reduces complexity by eliminating the need for semicolons
  • Works exclusively in global space; no more var statements for your variables (seriously, don't use them or something may break)
  • Simple, direct control of code execution with goto()
  • Powered by eval()

Using GOTOJS

Basically, it's BASIC.

Example

program = {  
    10: "x = 0",
    20: "x = x + 1",
    30: "print(x)",
    40: "if (x < 5) goto(20)",
    50: "print('Done!')",
    60: "end()",

    100: "print('Hello World!')"
};

run();  

Produces:

1  
2  
3  
4  
5  
Done!  

You can also run from a given line number:

run(100);  

Produces:

Hello World!  

Easy!

Commands

  • run(line) start execution of the program at the beginning

Continue...

Is JavaScript's eval really evil?

"eval() is evil."

If you're a Web developer, you've probably heard this, along with other JavaScript commandments like "don't use with()" and "don't use ++ or --". Doug Crockford's list of "bad" JavaScript language elements is pretty long, and they're pretty subjective.

Meanwhile, Crockford had for much of his JavaScript career been a driving force behind what I call the "Javafication of JavaScript". That is, making complex hunks of code in JavaScript to simulate Java idioms and behaviors (like classical inheritance).

While Crockford has since recanted much of that "Javafication", the ripple effects are still with us today. Further, his "bad parts" of JavaScript stem from the same mindset. Basically: JavaScript is somehow "broken" and we must avoid tangling with complexities like when you need curly braces.

An open-minded approach

We should all be aware of the features and complexities of JavaScript. Instead of blindly following word from on high about

Continue...

Web developers: support a mobile OS that supports the web

<preachy>  

You know who you are:

  • You're building a mobile web app, but you're only supporting iOS and Android. Neither of which are exactly "web friendly" (I'm especially looking at you, iOS).

  • You're making a hybrid app with PhoneGap, but you're only using the iOS or Android build options. Because, well... because.

  • You see things with amazing mobile HTML5 support like BlackBerry 10, Tizen and FireFox OS and say "well, if they ever get more marketshare, we'll spend some time supporting them".

You're the "chicken" in the "chicken and egg" problem

Stick with me, this analogy holds. You know how developers like to wait for a platform to gain marketshare before they spend time supporting it? Well, that means less apps and compatible websites will launch on that platform. Less apps and websites means less curb appeal for consumers. Less consumers means... less marketshare.

Mobile OS Market Engine

By chickening out, you're

Continue...

Adding syntax highlighting to Ghost

I wanted to enhance the syntax highlighting in the default Ghost theme (Casper). I dug around and while there are a ton of solutions out there, I settled on Prism because it's simple and lightweight. Notice the colorful goodness:

// here is some JavaScript
var x = new joButton("Hello World!");  

Prism is easy to install in your default ghost theme (I'm using Casper). Don't let the length of this tutorial fool you; it took me about five minutes total to get up and running.

Installing Prism

  1. Go to http://prismjs.com/download.html

  2. Select a few options; basically, which theme you want and what languages you want to support

  3. Scroll down to the bottom and download your custom-made prism.js and prism.css files; put them someplace you can find

  4. Copy these files to your server, and login there

  5. Copy prism.js into your ghost/content/themes/casper/assets/js folder

Continue...

Pondering the future

I've worked on a lot of cool stuff over my career, both as an employee and on my own. I've met a ton of awesome people along the way (and some not; you know who you are), and I wouldn't change any of it.

Here's the thing:

I can't say that I've been happy

I've worked up and down the food chain, as a developer, an architect, manager, evangelist; heck I even made my living as a designer for a few years. Lately I find that I appreciate the allure of the steady paycheck less, especially given the trade-offs in working as an employee. Typically, I have very limited creative control, and end up making a lot of compromises between my passions and my employers' expectations. More than I'd like.

Boiling it down, here's what I like:

  • learning things
  • creating things
  • helping others to learn and create things

So what

Continue...