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?

Audacious CSS Desktop Programming

Take a look at this video, here I show an awesome new technology for using Clutter/Gtk with Cascading Style Sheets.

Audacious Video

You can test this out for yourself with Ubuntu 12.04 (Beta) using the following:

sudo apt-get install gir1.2-gtk-3.0 gir1.2-clutter-1.0 gir1.2-gtkclutter-1.0 gir1.2-gconf-2.0
bzr branch lp:csslavie
cd csslavie

Note: default clutter/cogl has a bug which prevents the background’s opacity setting, so you won’t get as cool an effect. But a fixed version of those libraries should be available eventually.

Please comment below what you think.

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.


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.

Python List Inheritance Post Creation Pattern

One of the fun things to do with python is to use the language to bend the rules of programming. One neat way of using your resources wisely with objects is to create objects in the right places, but not generate or call costly data gathering operations until you absolutely need to.

So called ‘late data initialisation’ is useful in certain kinds of programs. I document here the best pattern I’ve found to turn a python list into a late data class:

class newList(list):
    def data(self):
        if self.populate:
        return self

    def populate(self):
        print "Generating Now"
        for x in range(42):
            self.append( x )
        self.populate = None

    def __getitem__(self, key):
        return super(newList, self.data).__getitem__(key)

    def __len__(self):
        return super(newList, self.data).__len__()

    def __iter__(self):
        return super(newList, self.data).__iter__()

Basically populate can be any piece of code which calls what ever it needs in order to gather the data. It’ll only be called once and to prevent having to use an __init__ variable we just clobber the method attribute. Sneaky!

When the list is used for an iteration (for loop), or if you delve into it directly for a specific item, or need to know it’s length, then we can get the data behind our object and have it contained within the list object we’re inheriting. No need for secondary list object variables dangling off of self. Ugly! Although this pattern does require that every use you want to put the object to (i.e. string, representation, slicing, dicing, mincing or conditionalising) you’ll have to make a new super method to wrap around to make sure that the data is generated if that’s the first way the list will be used.

What are your thoughts about this pattern? Do you know how to fix the init issue with a better pattern?

Freely Fixing and Developer’s Time

I was reading over the ever wise Matt Zimmerman and his blog post about Listening to Users; in it he argues that user involvement is a nuanced subject and which approach the developer takes can be highly dependant on the timing, cycle and context of the developing project. Providing examples and some interesting comment.

I basically agree with these ideas, but I wanted to add something more to the economic thought.

I talk about user involvement here; I never mean users who are programmers, users who help support other users or users who turn into developers by their continued project involvement. For that subject see User to Developer evolution.

What developers want from users is fine communication on what the challenges and needs they are facing. They would like as much depth into the issues with as much detail on the specifics which cause issues. This communication is not actually in effort to help the user, but is instead a way to help the developer’s project. The user can see the bug or interaction as a way to get their immediate issue resolved, but the developer will be focused on collecting and filtering the relevant information and making tasks to push the project forwards.

Of course the user will still benefit in due course; but the user’s direct support needs are instead not met by bug reports, but by support type people who may or may not know the aims of the project. The goal for support people is to give the user instructions so that they can mitigate their issue and it isn’t about helping the developer. A wily support person will be able to turn a successful support request into a successful bug report which the developer can process and turn into a permanent solution; on the other hand a user or support person who is used to mitigation strategy, but not used to developer interaction will fail to tie the loose end of why the user needed support in the first place.

This can lead to the dreaded ‘toxic workaround’ which Tim Cole has given a talk about. This is a workaround which becomes so well documented and so ingrained in the culture of the users of a product that they fail to actually tell a developer to fix it. So the problem always remains causing issue for anyone new and causing users to go through extra steps to get usable systems. A good example of this is in Ubuntu support channels when people are asked to and expected to compile anything instead of the code being added to a PPA.

In order the listen to users, I think a developer must know the difference between supporting the user, and supporting upstream development; which may place conflicting demand on the developer’s time. The user for their part, if they get frustrated with reporting bugs that never get to be solved, can lash out at developers, ordering and demanding action should be taken and issues resolved.

Of course, if the user isn’t paying the developer to fix their issues, then the user has no right to ask any developer to work on their issue. The user’s only real power is that they can be of use to the developer’s aims in their project’s future refinement. This is because the developer is the one that holds the majority of the economic power. When a developer talks with a user, it’s clearly with an effort to solve the issues the user has brought up; but I think the developer is always thinking about what fixes will benefit the project the most and which users are the most useful to communicate with to achieve those goals.

What are your thoughts?

Unity and Places

I was excited to hear from Ted Gould ironically at the Gnome Boston summit about the Unity Places system and the opportunity to create custom places which can expose all sorts of collections and online connections to the user in interesting ways.

This is not that file system deprecation that people keep on mistakenly banging on about, but instead a way to view interesting data objects in a user session context and even perhaps search on them.

My own ideas range from exposing openclipart to integrating a list of projects from ground control. All seem like pretty interesting candidates. From the wiki the only thing that concerns me is the canonical user space, I’ll live with it but the anti-social contributors agreement makes me uncomfortable to be involved any closer than simple plugins. Hopefully there will be something similar in gnome shell or kde (although preliminary questions on the topic suggested that gnome shell would be a rigid as a board of plywood so perhaps not).

See here for more details: Unity Places Wiki

Why Gnome? Why.

I have a love/hate relationship with gnome. I use it, I develop for it and at the same time I dislike the way the gnome project produces functional libraires.

Take for example librsvg, an awesome library for turning svg files into pngs for display and for making thumbnails. For some unintelligent reason installing or compiling librsvg requires gtk and thus also requires avahi and hicolor-icon-theme, xrandr and libcups2. Does making a png out of an svg require us to send icons to a rotated screen connected to a networked discovered printer? No? Then why do I need all this stuff?

The problem as I see it is that librsvg should be split out more into it’s none-gtk library parts and it’s pixbuf/gdk parts. Making it a useful library to a wider audience from servers to other desktop systems. Larger audiences mean more attention and more attention means more bug fixes.

The gnome project historically I think didn’t have much of a culture of serving a wider ecosystem and saw gaps and filled those gaps with gnome-only libs. It pains me to say but as a programmer I’m disappointed by the lack of foresight even though I understand resources were always tight. A “do everything with gtk deps” culture produces inflexible libs with rare logical separation between layers and fewer opportunities to share with the wider community because of it.

I’ve always hoped that the FDO culture of sharing APIs and working towards standard consensus would help the culture along and promote a culture of making libs for everyone.

Does anyone know of any alternatives to librsvg that produce good results? imagemagik failed to meet standards as it doesn’t support most of the filter effects, but I don’t know of many others.

just my 2 cents, what are your thoughts?

Perl to Python

I managed to port one of my libraries that I made way back from perl to python, the experience was quite interesting, although very tiring. I don’t think I can recommend perl again since the python just looks so much cleaner and there were whole sections I could remove because they were handled by python.

If your interested in data validation check out lp:~doctormo/doctormo-random/xsdvalidate and have a look at the tests, it’s basically a module similar to the existing xml.xsd but with a focus on python structures.

Because it’s a library few of you are going to know how to run the tests and have a dig around at what it can do. For those in the know, it’s got a structural error reporting mechanism which allows the code to know what failed to validate. In perl I was using this module hooked up to a django like framework which would be able to check if the form information was valid and which fields failed and how, this information was actually fed directly back to the template for human warnings so the entire process was automated to a frightening degree, you really didn’t need any code for most transactions.

I’ve already heard that I should have used DTD instead of XSD, I never really liked DTD, they seem really ugly to me. Also a nod was given to using this kind of thing for ajax validation, but I somehow think that javascript must have an existing client side validator in the browser.

I have a test suite but I could always do with more tests, if you find something it’s not covering let me know.

Example of FOSS Economics

People who read my blog regularly know I’m big on looking into discovering what it is that will allow software creators, bug fixers and all the other people involved in producing functional products with a sustainable income.

Only two weeks ago I was talking with Matt Lee of the Free Software Foundation about this problem and apparently someone he knows had sold himself online for 6 months as a free software hacker by setting levels of pledges and some rewards and products for people who invest in the project and although the FSF doesn’t consider economics important enough to be a goal (much to my disappointment) the activists there are aware of it.

Now computer world uk is reporting on the exact same system, one where the artist, programmer or team sets out to raise money for a project and does so by setting a structured list to encourage higher amounts of money to be pledged.

Just like me they’ve avoided using words such as “charity” and “donation”, which I think are really not applicable to what we’re trying to do: viz. find a way to make Free as in speech economically sustainable.

What do you think about a stepped pledge model? Do you think that the model requires far too many direct supporters and existing backers before it can be made to work? Should I conduct myself in a similar fashion by creating a set of pledges for the ground control project and advertising it very widely?

Python Threading Woe

This is what python threading does to people:
My work on groundcontrol is trialling thanks to nautilus being based on gtk and the Thread class which is supposed to provide easy threading. And bzrlib, which may or may not be thread safe, but never actually functions in a thread even when self contained in one thread.

It’s turning into a real dogs breakfast and advice from other devels says to avoid threading in python… that may not be acceptable for this project. I’ve managed to solve now most problems via not having threads but instead loading at opportunistic times. but it’s ridiculous to me how badly Thread, gtk and bzrlib mix and how much time I’ve wasted trying different solutions. So desperate was I that I even tried using subprocess to fork out a separated script.

Now I know a lot of this is due to not knowing the precise operating functionality of threads in python… but the subject seems to operate on some kind of uncertainty principle where the more a person knows the less likely they are to explain how it works, conversely the less someone knows the more likely they are to try and explain it wrong.

So anyone know any _really_ good guides on python threading that explain it and demonstrate it? So far the guides I’ve found have been wrong.

Update: The community does not disappoint… a great simple guide in the form of a pygtk faq was most helpful, provided by M.K. Erlandsen below in the comments. Also useful is the multiprocessing explanation provided by Jess S.