tuProlog 2.1.1

•December 23, 2008 • Leave a Comment

More or less an hour ago the tuProlog 2.1.1 bugfix release has been made publicly available. You may read the announcement, download the software, and see the log for the detailed review of what changed in this new release. That’s all from myself as project maintainer, since I will no longer be personally or professionally involved in tuProlog anymore.

Free for personal use

•December 6, 2008 • 5 Comments

Have you ever seen the most famous Free Culture presentation given at OSCON 2002 by Larry Lessig? I did, and I was fascinated not only by how Lessig coordinated speech and slides, but even by the craft of the slides themselves. In particular, I really liked the font he used. So, in the process of preparing a very small deck of slides for ICLP 2008 (a short paper/poster, less than 10 minutes on stage, really nothing to see here) I searched for some more information about the colophon of the presentation.

It turned out that the font Lessig used is P22 Typewriter, said to be not CC licensed but released free for personal use. Unfortunately, if you visit the link provided by the Free Culture presentation colophon, you’ll discover how that font is no more freely downloadable.

Damn! “I must have that font”, said the Unsatisfied Baby inside myself. I started Googling, of course, but kept finding only sites offering sales for the P22 Typewriter. I was already thinking about writing an email to Lessig or some other people who advertised that font as free, just to check if they had a copy they could pass along, when I found this project on Google Code, called piped, which, really, I don’t even understand what it is about, but has P22TYPEW.TTF among its downloads. So, here it is, P22 Typewriter free for personal use again.

Implementation patterns: loop variable name

•October 8, 2008 • 2 Comments

After looking at how high the latest Kent Beck’s book has been valued among aNobii italian readers, in contrast to some delusional Amazon reviews, and after looking at a video interview about that Implementation Patterns book, I’ve had a chance to give it a quick skim, curiously reminded of the tale of Beck himself reading Alexander’s The Timeless Way of Building standing up in a bookstore because he couldn’t afford to buy a copy.

I read all the philosophy chapters at the beginning of the book, then when coming to the practitioners patterns I started jumping here and there… a look at collections, a quick glance at changes for implementers of frameworks rather than applications, and eventually I stopped by the patterns for naming local variables, among which lie pattern for naming loop variables.

I’ve been quite interested in that, since I read in the first chapters that such a pattern was contained in the book, because, you see, I have had a similar problem for a certain time. I started with throwaway names, as I believe everyone had done. In a Java 1.4 loop, for example, I would have written:

for (Iterator i = books.iterator(); i.hasNext(); ) { ... }

That i however bogged me, because such a meaningless name seemed to show that the iterating variable was also useless. (And, indeed, Java 5 abandoned the explicit use of iterators in favor of the new enhanced for loop, but I’m coming to that in a moment.) So that went, until I had to iterate over clauses in a Prolog theory, and found that I could write:

for (Iterator clauses = theory.iterator(); clauses.hasNext();) { ... }

which was much more meaningful and pleasant to write and read. I was using some API objects, though, so I figured that the luxury of having meaningful names for loop variables couldn’t possibly be always affordable. But in Java 5, such loops are gone! You would now write something such as:

for (Clause clause : Theory) { ... }

which in C# would even result more readable:

foreach (Clause clause in Theory) { ... }

In such glorious naming galore, Beck’s suggestions didn’t reasonate with me at all. He writes loops using each as a variable name, thinking that he could turn to the for line if he wants to know more information about the object that the each variable holds a reference to. For example:

for (Clock each : getClocks()) { ... }

But really, each can be anything, and with that name you are just conveying the idea of being in a loop, which, well, I personally don’t find that much interesting to devote a variable name to it. What about, instead, using:

for (Clock clock: getClocks()) { ... }

Things get worse when you have nested loops. Beck’s example runs like this:

for (Source eachSender : getSenders())
    for (Destination eachReceiver : getReceivers())

which seems a little redundant to me. Of course, I would have written:

for (Source sender : getSenders())
    for (Destination receiver : getReceivers())

More interestingly, even if patterns change with the programming language, as Beck repeated in the video and in the book, applying this pattern to C# would sound a little, uhm, funny:

foreach (Clock each in GetClocks()) { ... }

because of the each repetition in the keyword and variable name. Adding to that, consider that each is also a method name in Ruby structures such as lists, and that the variable name holding reference to each object in such a loop is usually something more meaningful that a mere repetition of the method name.

I don’t think that the word “each” just assumes a meaning in Java because of different naming in loop keywords or methods; I find it as disturbing as i for numerical indexes or it for iterators, something that you couldn’t even came up with a good name for, so what is it doing in your code? I prefer the convention of naming the variable after the object it contains, or the concept that the object conveys.

From the little bits and pieces I read, the book seems to lie half way between Java code conventions and Effective Java. I would value it not for the concrete patterns, but for the idea of making such a journey in one’s own programming habits by oneself. Implementation Patterns seems to be a very personal book, one from you could learn the process of investigating how much your habits helps readability and convey code meaning, but where the results are hardly useful for each other reader, apart perhaps some hints about the things to look after.

Fly me to Ganymede

•July 8, 2008 • 2 Comments

I’ve spent the best hours of Sunday afternoon (after the F1 race in the UK, that is) and some hours this night to test a possibly new and revamped version of the Eclipse plug-in for tuProlog through the use of features and update sites. No problem whatsoever in Eclipse Europa. However, at the first install, Eclipse Ganymede did not recognize the existence of any extension in the branding/main plug-in for the feature… OK, well, I probably had something wrong in the build configuration for that plug-in, so I tried to do some changes here and there… but to no avail. What definitely pissed me off was that, while through the update site and feature Ganymede still showed an inexplicable behavior, running the plug-in as a Runtime Eclipse Application worked just fine.

This night I also discovered that the tuProlog Eclipse plug-in had no problem running from the dropins folder, one of the “great advances” of p2, the new installer framework in Ganymede. Finally, completely upset by the illogical behavior of the platform when it came to “correctly” installing the plug-in, I had a look into the plugins directory, just to find that older versions of folders and jars from the tuProlog plug-in were still hanging in there, even if the plug-in had been long uninstalled. So, I did exactly what “officially” you should never, never do: I manually deleted the offending files, and tried to reinstall the plug-in from p2.

Hey, it worked.

Then again: I uninstalled it from p2, then changed a couple of things in the about.mappings file for the branding plug-in… and tried to reinstall the whole plug-in, via the regenerated feature and update site, from within p2. Guess what? Those changes didn’t show up. Again, the older version was still on disk after uninstalling, restarting, jumping on one foot, and praying in chinese to a greek divinity.

Given that p2 is also storing configurations of installed plug-ins in a historic fashion, I like to think that what I experienced was a caching problem, but that’s just because caching problems have been a pet peeve in our open space at work, lately. Whatever really is, it definitely is a problem: the usual idea of uninstalling a piece of software and then reinstalling it maps quite naturally to a reset; if you change that mental mapping, you should have a good reason to do it… and click counts are not that good a reason, sorry.

Just for completeness: to have Ganymede see the oh-so-important brand changes, I had to do again the manual uninstall dance. This time, when I tried to reinstall the plug-in, p2 complained. What followed was a mix of restarts, use of the dropins folder (a couple of times, since the first time the plug-in didn’t show up even from there), and a general state of tiredness, but in the end the world turned up to be happiness and glee.

I hope to see the problem solved in the future… at least, not to experience it anymore with future Eclipse releases. In the meantime, I’ll return to bed, and try to finally get a good sleep.

Bitchiiiin’

•May 14, 2008 • 1 Comment

You have already installed Ubuntu 8.04, right? Everything was fine, you got Firefox 3, perhaps even installed a beta of Firebug since 1.05 does not work with it, played around with some applications… you know, the usual things people do when upgrading an OS.

But, have you seen the new anti-aliased emacs? No, really, have you seen it? If you didn’t, you have to.

So, install emacs-snapshot.

Then, set the default font to some anti-aliased font, perhaps such as monospace, or Bitstream Vera Sans Mono; probably it doesn’t matter if you do it through .Xdefaults or through .emacs. Just do it. Then run emacs-snapshot, open whatever file you like, and…

Flames.