What is Art? is code Art?

The musings of today’s Thought for Today on BBc Radio Four are often interesting perspectives that drive at something both personal and social. Today’s subject was the concept of modern art, it’s valuation and the way in which artists invest in the art while knowing little about it.

This got me thinking about code. You see code is something that requires an imense amount of creative thinking. Not just problem solving and puzzle mastery; but down right honest to god design and humble craftsmanship to boot. A piece of code must be more than just functional for the user, it must be maintainable in an ever changing world.

This requires that the code be readable and possibly even attractive to potential maintainers as a learning exercise. The best code is obvious where is can be and smartly presented where it needs to be clever. It must deliver it’s cleverness carefully and in reasonable chunks, much like a classical lesson in latin or a course of antibiotics. The code needs to cozy up to the reader and be as familiar with it’s patterns, syntax choices and variable naming conventions as a well worn pair of slippers.

Start using single letter names, odd abbreviations or inventing undocumented artifice and you’ll lose the audience. You’ll alienate the future from your comfortable seat in the past with a smug sense of converse hindsight. The arrogant developer assumes all things are known in the future and all maintainers are themselves or someone very much like themselves. And the trouble with people is, no matter how many you know, there’s always one strange outliers you’ve never met and one day they’ll be looking at your code thinking to themselves that you must have been enjoying your legal high quite a lot on the day you wrote /this/.

So what is art and how does it fit into this whole “understandable code” thought?

I’m not going to pretend there’s not seven billion ways to define art. But I believe art to be “the intentional communication through emotional language”. This means I consider stand up comics to be artists, I consider Fox news to be an arts show and music like rap to be one of the most powerful forms of art around today. But art can be bad like Fox, art can be good like Banksy and that doesn’t detract from it’s medium.

Art can be a failure when it fails to deliver the intended emotions like most modern visual art (to the general population anyway). We can feel disappointed in politicians for failing to be concise and factual, while at the same time marveling at their artistry for using their home spun bull shit to evoke the emotions they want in their audience. It’s wonderfully successful art, and a terrible education for the public. Not that art needs to be true, or that it needs to not be true of course.

Code in this narrowed definition of art, can be art. Sure as above we really want code to be artful as in crafted well; but we also could have code that intends to and successfully delivers an emotion. It has two ways. The usual way is that the code runs a game or some other intended visual art say. It’s the mechanism by which art is delivered and the code in there is part of the whole art.

I remember the radio head “Big Ideas” video that uses a specrum and hard disk array. That delivers art through it’s code is some interesting ways.

But I think most interesting to developers is how their emotions can be engaged by just reading code and repositories. I think source code poetry is a pretty well established way of making art out of code and I really enjoy reading some of it and running it. There are code flowers and other clever mechanisms that evoke wonder and joy as they are compiled and run.

But what of every day code. I think all our code evokes some emotion in those that have to read it and fix it. Mostly this is frustration and annoyance that you didn’t write it in a way more comforting to the reader. But there’s got to be scope here for making functional code that’s beautiful, interesting, passionate, lovely, hateful or just plain fun.

And not just for the user.

What do you think? Can your code be art?

Introspection Introspection

I’ve written a script which I can use to get information about gobject introspection modules for use in python. It’s written in python and allows you to look at actual function names, actual object names and what really is going on.

http://paste.ubuntu.com/872138/

This is mainly a problem because the documentation for Gtk with gi.repository is so poor and not clearly described that it makes it impossible to use without great force of will.

Hopefully this script can make the job easier for others, feel free to adapt it and post your remixes.

XBMC Librarian (New Addon)

Hello Community,

I’ve finished writing a new addon for xbmc (the tv media center for Ubuntu) called Librarian. She will take a look at your impressive video library and check for various inconsistencies and potential problems which you might want to look into. This 1.0 release includes the following features:

  • List Movie Files not Included in the Database
  • List Movies which have incorrect length, i.e. misidentified or corrupt (requires ffmpeg installed)
  • Lists TV Shop Episodes separately with both above features
  • Tells you which seasons and which episodes of each show you’re missing
  • Shows you which TV Show Paths are being ignored completely.

More checking can be added as good ideas come in, I’ve also written an addon module called xbmcdata which wraps sqlite3 the xbmc httpapi to give a consistant inside xbmc and outside testing/scripting interface. This makes addon development _much_ easier. For instance listing movies is now just a case of:

from xbmcdata import Movies

for movie in Movies():
    print "%s (%s)" % (unicode(movie), movie['Year'])

Please download the code here: http://divajutta.com/doctormo/doctormo-xbmc-addons.tar.gz and install in ~/.xbmc/addons/ then test, entry is available under ‘Programs’. Please report issues back to me with full logs from ~/.xbmc/temp/xbmc.log included.

Have fun.

Registration Form, Gtk Forms

The GtkMe python lib provides a form window which allows me to construct a multi-page form with data validation. I’m pleased with the results I’ve committed today that allow a new user to register themselves within the login screen.

class RegisterWindow(TranslatableFormWindow):
"""Display a create user window"""
name = 'register'
primary = False
fields = [ 'postcode', 'age', 'gender', 'passphrase', 'computeruse' ]
def __init__(self, *args, **kwargs):
self.realname = kwargs.pop('real_name')
TranslatableFormWindow.__init__(self, *args, **kwargs)
intro = self.widget('label').get_label()
self.widget('label').set_label(intro % self.realname)
def cancel(self, widget, event=None):
if isinstance(widget, Gtk.Button) or (event and \
event.key.keyval == Gdk.KEY_Escape):
self.destroy()
def get_data(self):
"""Return all the user entered data"""
result = self.field_data()
result['name'] = self.realname
return result
def pre_exit(self):
register_service.create_user(self.get_data())

While I’m not finished debugging it all, the idea is to be able to make Gtk apps which have a wizard style layout with minimum effort. Each page has validation checks (if you want) and standard signals which you can stick into glade and have next, back, cancel and destroy handled for you.

This code controls a 5 page registration window as so:

Thoughts?