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, 1 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
vagrant up 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. 2
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.
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?