I work daily with PHP and JavaScript thanks to WordPress. Our server environments are primarily PHP, and the front-ends are scripted with JavaScript. It's fun, but building a prototype in two languages, one of which that needs a server to process requests, is a bit burdensome.

Lately I've been experimenting a lot with Node, the V8-powered server-side JavaScript tool we all know and love thanks to Grunt, Bower, and countless other JS-based task runners. Node lets me work quickly in JavaScript, spin up sophisticated prototypes quickly, and test my work both locally and on a real (remote) server in seconds.

The Power

When I first dabbled with programming in high school, the only options available to me were QuickBasic and C++. At the time, all but one C++ compiler were closed-source and, frankly, my allowance wasn't large enough for me to afford both an instruction manual and the compiler so I could learn how to write C++ and actually use C++ at the same time.

Instead I stuck with Basic - actually with QBasic, a stripped-down, compiler-free version that shipped with Windows 98. It was easy to learn and in no time I was building fun little to-do applications and mock console UIs and monkeys-throwing-explosive-banana games.

But without a compiler, I was forced to run all of my code in QBasic itself. I worked around the limitation by writing a few .bat files that would load QBasic, load my script, and run it automatically. Unfortunately, when the program closed, QBasic was still there in the background. If an exception/error was triggered, users would be thrown into QBasic's debugger.

It was a crappy experience.

The power of a tool like Node,[ref]Or Ruby. Or Python. Or newer versions of PHP that come with a bundled, lightweight server.[/ref] however, is that you can write a script that runs locally. No compiler, no distributable binary. Just a script file and an interpreter.

While you still need the interpreter, once it's installed scripts behave just like they're regular, built-in commands. I use Grunt and Bower as if they're system commands (both are Node applications). Like most of my peers, I use [cci]vagrant up[/cci] daily - it's a Ruby command.

This is hugely powerful, and the exact kind of experience teenage me would've loved to see.


My wife takes the bus. Unfortunately, our local transit system has stopped posting bus schedules at the stops and instead urges you to either call a help line (with annoyingly long instructions) or text an SMS shortcode (that potentially charges you each time and bundles meaningless ads for gold to "keep the service free"). Instead of dealing with the super-long messages on the phone, or risking a charge for texting, she texts me and asks me to look up when the next bus will arrive so she knows when to leave work and head to her stop.

It's a great system for her, but a minor interruption in my day.[ref]I'm more than happy to help, but we both wanted to figure out a way that didn't require me to pause in a meeting or stop coding to look up bus times.[/ref]

Yesterday, I took some time to prototype an automated application to do the lookup for me.

Our transit system has a rich API that I can pull against when I know a stop ID. The API will return both scheduled and estimated stop times; if a bus is late I can still grab it's information to figure out when it will arrive.

My first attempt was a simple command line utility. Specify a stop ID at the command line, get back an array of route numbers and estimated arrival times. Fantastic! But my wife can't use the command line on my local machine while she's at work downtown.

Enter Twilio.

I wired the utility up to Twilio's API. A text message to a specific phone number triggers an HTTP POST to my application, which in turn reads and validates the stop ID you've sent it. The application still pulls the same data from the network, but instead of writing it to the console, it pushes the data back through Twilio to the device that sent the stop ID.

Now my wife can text her stop ID to my custom number, and my application texts back a list of upcoming bus arrivals. For free. Without advertising. Win-win-win.

I built the app in a grand total of 2 hours last night. It's less than 120 lines of code. Thanks to RedHat, it's also hosted online for free. Make that win-win-win-win-win-win.

What kinds of tools do you prototype with easy-to-use scripting languages like Node, Ruby, and Python?