Squeaking towards ICFP 2003

I am waiting for the ICFP programming contest to start. I’ve even managed to remember that we’re currently in BST, and the contest starts at 0:00 GMT. What posessed them to start a contest at this time? This is taking geek obsession with zero-based numbering schemes to new levels of stupidity.

Anyhow, I am using this contest to test Squeak “in the real world”. I’ve done lots of small-scale programming using Squeak recently, but now I want to see if it stands up to a 24 hour coding frenzy (I’m only entering the lighting division). So, first and foremost this is a Squeak coding exercise, and if I eventually submit an entry that’ll be a bonus. I wonder if they’d given bonus points if I managed to submit working entries in five different languages?

I’ve been playing around with recording my desktop with vncrec. I briefly thought about recording the whole of my ICFP effort so I could review it later. It’s really trippy watching yourself programming. You notice how inefficient current GUI’s are. I’ve just watched a recording of myself trying to click a small button, and it takes several attempts to get just the right position. The same problem occurs when positioning the insertion point before typing. No wonder Apple’s magically zooming application launcher is such a good thing for mouse users, and no wonder that I prefer to keep my hands on the keyboard. I don’t like the way that keyboard shortcuts in Squeak change their meaning depending on which window you’ve got highlighted. I’d like alt-B to always bring up a browser, regardless of where the pointer is.

On a seperate topic, I intend to later add a ‘autocomplete selector’ feature to the Inspector window. Since smalltalk is dynamically typed, you don’t really get the same sort of autocompletion which is available in IntelliJ or Visual Assist. However, if you’re entering code in an Inspector window, you do know what type ‘self’ is, so you can do better than the command-Q shortcut which just autocompletes using every single selector in the world. Most of the time, I’m typing “self foo” into Inspector windows, so it’ll be useful for me.


It’s so simple

“If we spoke a different language, we would perceive a somewhat different world”. Quotations on Simplicity in Software Design.

“There is nothing permanent except change”.



Update Debt

A random “design pattern” which just popped into my head:

Imagine you have some large data structure which is expensive to update. Maybe it’s a list of integers and you want to clamp each element to be between 0 and 100. Normally, you’d go through each element, perform the check and update it if required.

Instead, I suggest keeping the original list and creating a seperate log of the ‘modifications’ which have been made to it. So now you have the original list and a note saying “by the way, when you read an element you also have to clamp it to the range 0-100”. Now you’ve made the update cheap, but accessing the data is more costly.

However, if your program is otherwise idle later on, it can come back and coalesce everything back down.

So you’re basically saving time in your “change it” code, paying it back a little at a time in the “access it” code, and you’ve got the option to pay off the debt entirely when you’ve got a bit of idle time spare.

Whether this is useful or not depends on the frequency and cost of updates and accesses. I’m noting it here as another potential “tool in the box” for algorithmic optimization. It probably lives next to memoization and similar such techniques.


Grr, Open Source

I play in a rock band, and as a consequence I’ve been spending a lot of time trying out audio software under linux. Usually when I’m trying out programs I have quite a high tolerance for bugs, clunkiness and bad designs, but when I’m using computers to record music I want to get on with the music and forget about the computers.

Without being disrepectful to the efforts of the Linux Audio Developers, currently linux ain’t a great place to be for audio. It’s getting a lot better with ALSA and Jack. But there’s no way I would recommend linux audio to anyone other than a hardcore techy.

So, should I install Windows and do audio there? I’d rather not give Microsoft any money. Maybe I should buy a Mac? I’m sure the grass would be greener over there. Certainly, the idea of paying some relatively small amount of money to get some better quality software sounds attractive. Gosh, that’s me .. a devout linux user .. wishing for a bit of commercial software.

There’s nothing special about these other operating systems in terms of the technical features they offer. The difference is the presence of commercial software companies who produce decent quality applications. You don’t get much of that under linux. These companies spend a while checking out user requirements, writing the code (including all the boring bits) and only shipping when it’s good enough to capture a reasonable share of the market. The end result is never going to be perfect bug-free software, but it’s pretty good.

I’d love there to be a top-class open source audio package for linux. But I don’t see how one is going to appear. If I were to write such an open source package, I’d have to do it in the evening after I come home from work. After all, I need to work during the day in order to buy food, pay the bills and live within our current economic system.

So, there’s the rub. If you want to get a team of focused developers working on an application, you need to pay them so that the project can be their “day job” and they can pay the bills. The only way you can pay them is if you can make money by selling the results of their efforts. Commercial software makes sense.

There’s certainly lots of people out there who expend huge effort developing open source software for apparently very little reward (the guy writing Ardour comes to mind). I would like to be able to do this kind of stuff without burning the candle at both ends. I work enough (paid) hours programming for my employer, and that leaves me disinclined to spend the remaining waking hours coding.

Also, since the volunteer brigade consists almost entirely of geeks, they have great success at certain types of application, such as web servers and compilers. Geeks like playing with new technology. They like doing the cool stuff, and consequently they tend to leave the boring bits of applications incomplete. Witness the number of projects with some small bit of “cool technology” at the core, but with atrocious GUIs. Maybe audio software is more left-brain touchy-feely and doesn’t win so big with the volunteers.

Apart from volunteers, there are other ways in which open source software gets built. Some open source software comes out of academic research projects, funded by government or industry. Some software starts life as an internal company tool which gets jettisoned, such as the Objective C support in gcc. A small amount of software is specifically commisioned by someone who pays a programmer to fulfil their requirements. I’ve done this kind of work before, but there’s not very much call for it.

Economies of scale make “commisioning” unsuitable as a method of seeing that good linux audio software get written. When a commercial company wants to build a new application, it takes on a certain amount of risk (the cost of development) which it hopes to recover through many sales of the product. The cost of the product is ultimately shared across many people. If someone were to commision an open source audio project they would singly bear the cost of development, which makes it prohibitively expensive.

I appreciate the technical advantages of open source software. I have often took advantage of the opportunities for learning, extending and fixing open source program which I couldn’t have done if I were using closed commercial software. And, I’ve volunteered lots of time to work on such projects. But I don’t see how it’s possible to truely walk the free-software walk when we live in a capitalist economy. RMS can believe that “reward is often not a motivator” if he wants, but peer recognition isn’t going to pay the bills.

Actually, I’ll postulate a thought experiment in which we already live in the RMS world, where all software was free. One day, someone comes up with this radical new notion of “proprietry software”. The promise of these crazy guys is that, if you’re prepared to loose some of your software freedoms and pay them a reasonable amount of money for results, they’ll be able to get some programmers together to concentrate full-time on the software, rather than working in a call-center or whatever they’re currently doing. What’s more, they’ll be able to get HCI experts to help design the GUI, and good authors to write the documentation.

So, my original question was “how do you write better applications?”. Open source may have many eyes making bugs shallow, but commercial software has fulltime eyes working on the program every day.



James Gosling is talking about his latest language project, Jackpot. It appears to be a combination of two things – “let’s edit AST’s instead of ASCII source code” and a mini theorem-prover which understands dataflow.

A few years ago, Microsoft were onto a similar thing with their Intentional Programming research project, which has since been wiped off the face of the net (except for this spinoff company and a chapter in the “Generative Programming” book).

When you run a traditional compiler, it reads in your ascii source code and analyses it to form an information-rich representation. It knows all the types, where each variable is declared and used, whether a line of code is reachable or not. It needs to know all this information before it can generate the assembly version of your program. But that same information would be very useful to developers too.

In a system like DevStudio, there’s a big wall between your text editor and the compiler. You throw your source code over the wall to the compiler, and some time later it throws you back a .obj file. It can also throw you back a dump of some of the information it figured out (“browse information”). That doesn’t work so well, because whenever you start editing code, the information gets out of date.

What systems like IP and Jackpot do is move the wall. Now, on one side you have your editor and the “information gathering” engine. On the other side you have a code generator which uses the gathered information. This means that your editor can use knowledge of the semantics of the language to enhance it’s editing factilities and presentation of your code. You can do neat editing things like having each appearance of a particular variable name be linked together, so that if you select one and edit it, they all change together. You can redefine the input mechanisms to use customized notations. You can neat visualization thing such as converting sqrt(x) into the mathematical symbol for square root, or converting a complication boolean expression into a circuit diagram with AND, NOT, OR gates. In IP, you can also define reduction methods which transform your code – the idea being that you can define a high-level notation (which you’ll then use day-to-day) and a set of reduction methods which map those high-level constructs onto something more efficient.

The “big idea” is that code should express the intention of the programmer rather than being an abstraction of machine code. This is also a goal of declarative languages and domain-specific languages.