Monday, January 4, 2016

Cheap Code for Cheap Computers

The Free/Open Source Software movement has made me a perfectionist, but that's not always a good thing.

When I look around at the programs I can download and use for free, I'm frequently amazed.  I can have everything from word processors to webservers up and running with a couple of clicks.  And what's more, these are incredibly well-written -- I can look at the code and it looks much nicer than anything I do!

This often stops me from writing things to scratch one of my own personal itches.  I start by thinking how great it would be to have a little app on my phone to turn down the lights, turn on my stereo and television, and get everything ready for watching a movie.  But when I start writing that, I start generalizing.  "What if someone wanted to change the settings on the lights?  Or if they have a different television brand with totally different controls?  And of course there needs to be a way to autodetect what devices are on the network and set them up..."  By the time I get to this point, I usually decide it's more effort than getting up and turning down the lights myself.

But there's something different about it when I am playing with IoT devices.  When a Raspberry Pi is so cheap that it's given away for free with a magazine, suddenly making a quick and dirty button to do only what I need doesn't seem as bad.  Somehow having a computer so small and cheap that I could literally lose it and not even notice makes it okay for me to write ugly code just for myself.

So I've started doing that!  I'm not even putting most of it up on Github.  Sometimes because it really is embarrassingly bad, like the webservice I made to control my projector: a PHP script that just takes a request and passes it straight through to a shell script with no error checking or security.  But sometimes just because I'm too lazy to write the more complex, general case code and want to just put IP addresses or light bulb IDs directly into a bit of Javascript and be done with it.

The result of this is something magical: I finally have my little remote control app, and it didn't take long at all to write.  (I even have a button to turn the lights in my room a deep violet, turn on the lava lamp, and start playing Barry White.  Just in case.)

I may eventually clean some of this up and publish it for others to use, if for no other reason than as an example of how it can be okay to not worry about doing things the Right Way™ on occasion.  But for now, I'm enjoying the fact that what I wrote is actually useful to me!


  1. But what if you wish to something that is actually useful? Or, FSM forbid, safety-critical? You'd have to employ a REAL programmer using proprietary software!

    1. Michael, that's exactly the mindset that keeps me (and probably others) from sitting down and writing something! My living room remote *is* actually useful to me, but isn't really safety-critical. I'm not advocating that people shouldn't think about scalability, correctness, security, etc. I am saying that thinking about these every single time when not necessarily warranted can be counterproductive -- the perfect becomes the enemy of the good.

      (Though I disagree about needing proprietary software. E.g. )