Monday, November 26, 2012

An Android On Device Programming Environment

For years I've imagined developing an application for my Android phone (at the time, a G1) that would let me write code directly on the device. I imagined it would be easy: wrap a Java based Scheme interpreter in an Android App, and allow access to a REPL. With that scaffolding in place, programmers could then get creative and really start automating their phones.

As time went on, I imagined that Forth, not Scheme was a better option for on device programming. The language can be quite compact, and can be molded to fit whatever paradigm you want.

Still, I wasn't ever quite able to find the pieces (a solid Forth interpreter in Java) or the time to put this together.

Then, a few weeks ago, Shira mentioned this powerful Android application she's heard about: Tasker. It's a pricy $6.49 on the market, and potentially seemed *too* flexible to be of much use. Did I really want to spend that much time fiddling with the settings of my phone?

Curiosity got the best of me, and after poking around on the Tasker website, realized that you can get a Free 7 day trial. I gave it a try, and quite quickly fell in love.

Sure, you can think of Tasker as a way to customize your phone, but really, it's so much more. To me, it's the on device programming environment that I've always dreamed of. Sure, there's no cryptic (and powerful) REPL, but there's everything else you'd want in programming environment: loops, conditionals, variables, access to files, HTTP POST/GETs and even a degree of modularity. Most importantly, you've got access to dozens, if not hundreds of things you can do to the phone itself, from snapping a photo, to turning on WiFi, to triggering device vibration.

The programming model is built around the notion of Profiles, which combine an initial context and a series of tasks to run when that context is met. I just setup a context like this one: when the phone is plugged in, turn on WiFi, Bluetooh and jack up the screen brightness and turn off the key lock. The environment is relatively easy to use, allowing me to hunt and peck to build an application. I'm sure some sort of text based interface would be nice for super experts, but for beginners, the GUI works quite well.

As little random photography experiment, I whipped up a script that discretely snaps a photo, then waits 5 minutes and loops around again. It does this 20 times before quitting. I turned on the script, put the camera back in the case on my hip (which has the camera pointing out) and let it shoot away. The results were as bland as you'd expect, but it sure was fun rigging up this hack in just a few minutes right on the device itself.

Tasker reminds me very much of AutoHotKey. It has a steep learning curve, but is incredibly powerful. I can already tell it's going to be a go-to tool for problem solving on my device. Also, like AutoHotKey, it is an ideal way to learn about programming. I can easily imagine a programming army of Tweens who got their start by automating SMS responses and generation.

Tasker even goes so far as to allow you to make your own stand alone apps from your Tasker recipes. Really, it's amazing.

But of course, you knew all this already. It's been discussed on Lifehacker months ago. Still, thanks for letting me share about my new toy. What slick profiles/tasks have you setup?

And who's up for adding a Forth based REPL to Tasker? Yeah, didn't think so.

2 comments:

  1. I feel your pain; I go through the Forth vs. Scheme thing about once or twice a year too. The past year, working in Scala, it has been Scheme-based DSLs all the way. Scala's pattern-matching and mixins make it sooo easy to implement s-expression languages. Maybe next year it will be back to Forth...

    ReplyDelete
  2. Well said TechNeilogy.

    Of course, I've actually written useful code in Scheme...but I'm telling you, one day, Forth will be making a come back. I can just feel it.

    ReplyDelete

LinkWithin

Related Posts with Thumbnails