chris blogs: October 2005

30oct2005 · Moving to Atom 1.0

Thanks to a patch by Sebastian Vuorinen, Nukumi2 now supports Atom 1.0 feeds. I changed the feeds of chris blogs and Anarchaia to Atom 1.0. If your feed reader can’t cope with it, please get a different one, use the RSS2 feed, or use the old Atom 0.3 feeds which have the extension .atom0.3. I don’t want to keep them around for too long. (I’ll check the logs for this.)

If you want to publish Atom 1.0 too, darcs pull now.

Thanks a lot, Sebastian.

NP: Bob Dylan—It Takes A Lot To Laugh, It Takes A Train To Cry

29oct2005 · The Rightyear parsing library

Last week, I ported Monads in Perl to Ruby just for fun and learning. It’s amazing how one can port code without really understanding it, for programming languages the Chinese Room Argument certainly works.

When I converted all the code from the page, I reread some of my Haskell papers and got hooked by Yet Another Haskell Tutorial which has a good chapter on monads and their use. It also uses monads to build a parser combinator, which is an popular approach to parse in Haskell and other functional languages.

Rather quickly I had a direct port of something akin to Parsec. I needed a name and Martin DeMello proposed “rightyear”, the japanese pronunciation of lightyear, which is about a third parsec, of course. For testing, I wrote a parser to read something like a very primitive kind of XML. This is an easy example of a context-sensitive free grammar in Parsec:

xml = do{ name <- openTag
        ; content <- many xml
        ; endTag name
        ; return (Node name content) }
      <|> xmlText

And that’s the complete Rightyear parser:

class ParseXML < Parser
  def parse_xml
    parsing { xml.passthru eof }.run
  def xml
    choice open_tag.bind { |name|
      many(xml).bind { |content|
        end_tag(name).bind { ret [name, content] }
      }, text
  def open_tag
    char(?<) >> one_or_more(char_matching { |c| c.chr =~ /\w/ }).bind { |t|
      char(?>).bindret t.join
  def end_tag(t)
    char(?<) >> char(?/) >> string(t) >> char(?>)
  def text
    one_or_more(char_matching { |c| c.chr =~ /\w/ }).bind { |s| ret s.join }

As you can see, Haskell’s do-notation doesn’t map very well to Ruby; it’s rather cumbersome to write. After a bit of twiddling, I found out that I didn’t actually need monads at all; instead I can use exceptions or throw/catch to trackback. Now, the parser looks like this:

class ParseXML < Rightyear::Parser
  def xml
    choice seq {
      name = open_tag
      content = many { xml }
      end_tag name
      [name, content]
    seq { text }
  def parse_xml
    v = xml; eof; v
  def open_tag
    t = text
  def end_tag(t)
    char(?<); char(?/); string(t); char(?>)
  def text
    one_or_more { char_matching { |c| c.chr =~ /\w/ }.chr }.join

Which is a lot better for the eyes, no? It’s actually straight-forward to write parsers in this, but you need to ensure you don’t have left-recursion in your grammar, because that borks parser combinators in general. The big advantage over Bison and similar tools is that you easily can mix in your own code and can parse full LL(∞).

Unfortunately, the trackback via exceptions still is rather slow, it takes about 6 seconds to parse "1+#{'1+' * 6000}1" on my iBook. So consider this as an academical exercise for now; I learned a lot about monads and Haskell and how it sucks when you rewrite it in non-Haskell languages. :-)

People have been doing this in Tcl/Tk and Python, and even C too.

Further reading: Fast, Error Correcting Parser Combinators: A Short Tutorial (PDF) by S. Doaitse Swierstra and Pablo R. Azero Alcocer.

NP: Bob Dylan—Tonight I’ll Be Staying Here with You

22oct2005 · Heidenröslein, Muselmänner und Tomatografie

Trotz Kaugummi- und Rauchverbot und anfangendem Klausurenstress bleibt auch bei uns der Spaß nicht zu kurz:

What do you think?Nix!

Was? Die Muselmänner sind in Deutschland?

Lieber Heidenröslein als Christrose.

Manga Moralia

Ich weiss schon wie’s geht, ich wollte nur den Spruch loswerden…

Mir ist kalt!Jammere nicht, so schläfst du schon nicht ein! [Kriegsveteranen unter den Lehrern?]

[Lehrer packt US-Flagge aus. Schüler:] Anzünden!

Wir sind in der 5. Klasse, und ich hab immernoch das geistige Niveau.


Werwolf & Waswolf

NP: Bob Dylan—Sarah Jane

16oct2005 · Euruko 2005 -- Day two

Continued from day one.

On the second and final day of Euruko 2005, the European Ruby Conference began at about ten o’clock.

Steve Purcell, Mocking Objects with RMock

Steve Purcell, who by the way was the first speaker that said he is a Rails user, presented an implementation of mock objects done by him.

Mock objects are a technique for writing better unit tests; they provide fake versions of other systems. These fake versions now can be made to produce the test scenarios you want.

He said that by using mock objects, one can trade “reality” for control over the test environment, as testing classes can happen in isolation using fake collaborators. He emphasized that mock objects are not just stubs. After this, he demonstrated how to use RMock by implementing tests for an imaginary BurglarAlarm—with lots of feedback from the audience.

Update: RMock is now known as Mockr and can be found at

Michael Neumann, Ruby and DSLs

The next one in order was Michael Neumann, who presented various Domain Specific Languages that he developed in Ruby.

Michael implemented a DSL for dealing with formal systems (think logic terms) in Ruby, which gets very usable due to heavy operator-overloading. He also wrote a script to automatically typeset those terms using lout. An example of what this DSL looked like:

V::x { P(:x, :y) } >= E::y { Q(:y) & V::Z(:x) }

Michael also wrote a high-level macro assembler for MIPS and an interface to the Ploticus visualization package in Ruby.

Of course, he showed the programmatic HTML generation made for Wee which is based on “brushes” that are outputted on generation of the next one. This allows for a very convenient syntax.

Then, he explained how to implement DSLs in Ruby and which language features help with this: instance_eval, undef_method, method_missing and const_missing. Interestingly, he also mentioned scoped globals, which are pretty much the same I presented as “dynamic variables” the day before. :-)

Sven Koehler and Armin Roehrl, Futurometer

First, Sven Koehler told us about the state of financial tools for stock market analysis. He claimed these programs are stagnating, and went on by outlining a system, dubbed Futurometer, that they have been writing for quite some time, which can help with that. It is supposed to be a kind of “google for the financial market”.

He compared the patterns in earthquakes and stock market crashes and told us how linking graphs of different areas could help predicting stock markets.

The Futurometer web application counts and graphs the occurrence of certain words, like “bird flu” or “al kaida” on Google News.

After this, Armin continued the talk and showed us some slides that analyzed the grounding of Swiss Air. He explained how statistical techniques like EVT (Extreme Value Theory) can help with investing. He said schoolbook statistics usually are 20 years behind from what the current methods of statistics are.

This talk sparked a long and very interesting discussion on economics and globalization. After the discussion, we tried to estimate the amount of energy that could be saved if everyone used Ruby instead of Java. :-P

Marcus Barchfeld, Eclipse’s Ruby Plugin

After the discussion, Marcus Barchfeld did a live demonstration of Eclipse’s Ruby plugin, RDT. I can’t say much about this either.

Michael Neumann, We.eXplained

In his second Wee talk, Michael Neumann explained the inner workings of Wee.

He compared Wee to a GUI that runs over the net and explained how Wee is component oriented and which parts are inspired by Seaside2. Then, he went on by talking about decorations and their implementation and how URLs in Wee are mapped.

A full demonstration of a Wee request cycle and when one should or shouldn’t use Wee concluded his presentation.

Johannes Pirkl, Nitro, Wee, Og and Glue

After this, Johannes Pirkl demonstrated how Nitro, Wee, Og and Glue can work together. He showed quite a lot of code and some of the techniques behind Nitro and Og.

Robert Kuzelj, Teclarative, a DSL for Testing

The last talk of Euruko 2005 was by Robert Kuzelj, who presented a more declarative unit testing framework he actually wrote in five hours during the conference. :-)

He argued a bit against Test::Unit and spoke about how syntax matters because syntax expresses intent.

Advantages of Teclarative are easy configuration, activation, and grouping of tests. Also, there is per-test-configurable setup and teardown. Furthermore, Teclarative allows for more flexible test naming (any string) and smooth creation of huge suites.

Robert finished his presentation by demonstrating how to use it.


Stefan Schmiedl quickly summarized Euruko 2005 and thanked everyone that helped and made it possible. He gave an outlook on next year, which will be interesting, as the number of attendees doubled this year. It peaked at about forty persons, even though RubyConf 2005 was talking place at the same weekend. When the conference is going to get bigger and bigger, there will be a lot more planning involved, and the space at Sulzer GmbH won’t be enough anymore. I’m sure they’ll find a solution for this, though.

All in all, I only can say that Euruko 2005 was a huge success from my point of view, and I think everyone that attended will agree. See you all on Euruko 2006!

NP: Blood Ruby—Remains of the Day

15oct2005 · Euruko 2005 -- Day one

This is the first part of two blog posts about Euruko 2005, the European Ruby Conference that took place on October 15th and 16th 2005 in Munich.

On Friday evening, the guys that already were in Munich met at “Ristorante Ai catelli”, which is an excellent Italian restaurant in the night-active heart of Munich. We probably talked (and drank!) there until half past twelve.

On Saturday morning, after everyone had introduced himself, the talks were collected in an “agile” way and we decided the order of presentation.

These were the talks of Saturday in chronological order:

Kingsley Hendrickse: Agile Testing with rubySelenium

Kingsley first gave an quick overview of the agile process and acceptance test driven development for the people that didn’t know about TDD yet. He outlined the use of stories, how to practice test-first and that stories are accepted when all tests pass.

Then, he explained the testing phases used by him, iterative testing, system integration testing, regression testing, performance testing and, finally, wider user acceptance testing.

He told that his web testing framework, which is by the way called rubySelenium because of the competitive, commercial, system Mercury, was especially good for test-first development. Also, it is easy to use for people of different levels of ability and, unlike Mercury, free of licensing restrictions. It is available as a gem.

He also explained that they use exploratory testing, which is essentially unscripted testing performed by humans to find potential bugs that were not considered during design and development. However, bugs get scripted and added to the test-suite when they are found.

According to him, agile testing covers three parts of testing: development interface testing, quality assurance and system integration testing.

The main benefits of the agile process are to have fully automated regression tests, get immediate feedback about bugs and the state of development in general, create tests with minimal training and feeding back (production) bug fixes. In the end, you have a far higher confidence in your quality.

All in all, agile development helps building the application around the customer’s criteria, have bugs ironed out by constant feedback, being able to better estimate due to constant feedback and allow for early integration tests with mock interfaces.

Kingsley finished his talk with an demonstration of rubySelenium, which probably is best described as a kind of DSL for declaring assumptions about websites.

Armin Roehrl, Watir — Web Application Testing in Ruby

Armin Roehrl continued demonstrating how to test web applications, this time using Watir, which is essentially a library to drive Internet Explorer to make it look like a user is using it. Watir makes this possible by providing full access to the DOM of an Internet Explorer instance over COM. The benefit of this is that Watir allows for having control structure in Ruby, whereas Selenium is purely declarative.

Paul Battley, Using Unicode in Ruby

Next, Paul Battley had a talk on how to make use of Unicode in Ruby. After an quick introduction of Unicode, it’s pros and cons and how it is encoded (UCS-4, UTF-32, UCS-2, UTF-16, UTF-8, not to forget the thing with endianess) he elaborated on the advantages of UTF-8.

Then, he also informed us about the “banana skins” of Unicode, according to him: the Byte-order Mark, differing operating system capatibilities, confusion about byte/char/codepoint/glyph, sorting and casing Unicode, normalization and Microsoft—which tends to handle some Unicode issues in a different way.

After this, he explained how to be careful in Ruby as Strings only are arrays-of-bytes, so, for example, there is no reliable [] and the length is returned in bytes. He also explained how to use Iconv and showed a nice trick with //IGNORE that I didn’t knew about Iconv yet. He taught the audience a lot of tips and tricks on how to deal with Unicode.

Paul ended his talk by looking at the future of Unicode processing in Ruby. There probably will be bindings to ICU, a library to deal with many Unicode issues, and Oniguruma, the future Ruby regular expression library with better Unicode support. Last but not the least, he also showed how to do mischief with Unicode.

Sven Koehler, Introduction to Wee

Sven Koehler now did the first of IIRC three talks on Wee, a web application framework that aims to be a clone of Seaside, which is written in Smalltalk. Wee is continuation based and features convenient HTML generation by code. He says Wee can be described as “dynamics on the server side” and contrasted it with AJAX, which can be used to implement this dynamicity on the client side.

He went on with demonstrating basic Wee usage.

Rob McKinnon, Ruby Editor Plugin

The next demonstration was by Rob McKinnon, which presented his JEdit Ruby Editor Plugin. I can’t say too much about this, actually. :-P

Sven Koehler, Monitoring Enterprise Applications

After Rob, Sven had his second talk today which was about enterprise environments and how to deal with them.

Sven is using Ruby and Wee at BMW to get an better overview about a really complex legacy system they run there and quickly demonstrated how he did this.

They have two systems there, a procurement application (which can be described in terms of User, Requisition, Catalogue, Account, Order that are all from different systems) and a ticket application which is like Bugzilla. The probably most amusing thing was that some old applications do kind of “RPC over SQL” for inter-process communication; that is, they insert a record into a database and a different process looks for new entries, does some calculation and inserts another record with the result. What a hack. :-)

Christian Neukirchen, Dynamic Scope and Context-oriented Programming

The last talk on Saturday was mine about Dynamic Scope and Context-oriented Programming. I have put the slides and accompanying code online, so it’s probably best you see for yourself. :-)

All I can say is that people probably really liked it, at least quite a few people told me how impressive they thought it was.

Dinner at Aumeister

After my talk, we all walked to the Aumeister beer garden and continued discussions there about various things. Ain’t nothing better than to hack code after dinner. :-) I, for one, had an interesting conversation with Stefan Schmiedl on various programming languages. Especially Forth was quite popular there, almost everyone talked about it somehow… how will this influence the future of Ruby?

To be continued on day two.

NP: Rolling Stones—Ruby Tuesday

14oct2005 · Off to Euruko 2005

Right now, I’m really busy packing my things together for Euruko 2005, the European Ruby Conference. I’ll be talking about “Dynamic Scope and Context-oriented Programming” there. Slides to appear here.

I’ll try to blog about EuRuKo, but since I only have net access at the conf (hopefully!), updates will appear on the next day soonest.

Looking forward to meet everybody…

Also, drop by if you can!

NP: KT Tunstall—Heal Over

10oct2005 · Paradoxien des darwinistischen Kapitalismus

Eigentlich scheint es alles ja ganz einfach: In meiner Heimatstadt Biberach gab es zwei Kinos, beide hatten drei Säle und durch Listen wurde garantiert, dass beide Kinos stets verschiedene Filme zeigten.

Beide Kinos hatten eine lange Vergangenheit, das eine Kino, “Filmtheater” genannt (für diesen tollen Namen würde vor langer Zeit übrigens mal ein Wettbewerb ausgeschrieben…) war immer etwas günstiger, vorallem für Schüler. Das andere, das “Ringtheater”, war etwas teurer und hatte nur einen großen Saal, die anderen waren ziemlich klein. Der Betreiber hat allerdings zwei weitere Kinos in der näheren Gegend.

Da die Filme jedoch fair verteilt wurden, wurden beide Kinos wohl gleich stark frequentiert. Um das in drastischen, kapitalistischen Worten auszudrücken: Stillstand. Unentschieden.

Ergo beschloß der Betreiber des Filmtheaters, eine riesige Summe (man redet von vier Millionen Euro) aufzuwenden und das Kino total auszubauen. Dazu musste es allerdings für ein halbes Jahr schließen. In dieser Zeit hatte das Ringtheater praktisch das Film-Monopol in Biberach, und machte wohl ungeahnten Umsatz.

Das Filmtheater ist inzwischen wieder geöffnet, heisst nun allerdings “Sternenpalast” und ist mit acht Kinosälen das größte Kino Oberschwabens – laut eigenen Angaben. Es bietet sehr bequeme Sitze, riesige Leinwände und modernste Soundtechnik.

Desweiteren hat es attraktive Preise; montags zahlen alle den Einheitspreis von 4,50€, donnerstags ebenso, wenn man weiblich ist. Interessanterweise war der Sternenpalast nach der Eröffnung immernoch billiger als das Ringtheater davor.

Da der neue Sternenpalast nun ja auch über acht Säle verfügt, ist es ihm möglich, sämtliche Filme zu zeigen, die momentan im Vertrieb sind.

Nach etwa zwei Wochen senkte das Ringtheater die Preise so, dass sie bis auf Montag und Donnerstag günstiger als der Sternenpalast sind.

Das war wohl vor einem Vierteljahr.

Letzte Woche hat das Ringtheater dicht gemacht.

Darwinistisch gesehen ist das klar; wer würde denn nicht in ein tolles, günstiges Kino gehen, in dem ein interessanter Film kommt, wenn es sonst nur in ein altes, relativ teures Kino mit beschränktem Angebot gibt? Keiner natürlich.

Was aber auch nur die wenigsten bedenken ist, dass nun, da das Ringtheater geschlossen hat, der Sternenpalast beliebig die Preise erhöhen kann, da ja in 20 Kilometer Umkreis keine Konkurrenz zu finden ist.

Was tut der Kapitalist? Besser: Was hätte er tun können?

Ist es kapitalistisch korrekt, ein schlechtes Angebot anzunehmen, um ein gutes zu erhalten? Ist das mit Darwinismus vereinbar? Sind Kapitalismus und Darwinismus überhaupt vereinbar? Wie sähe die Welt wohl aus, wenn Tiere aufeinander Rücksicht nähmen, um sich “besser” fortzupflanzen statt auszulöschen? Was ist “besser” überhaupt?

Ich fragte einen Freund, was der sorgende Kinobesucher denn tun kann wenn der Sternenpalast die Preise erhöht; er meinte, “Dann fahren wir eben nach Ulm”. Deutscher Fatalismus.

Glücklicherweise ist das ganze Equipment des Ringtheaters noch da, der Betreiber kann wohl auch von den Einnahmen aus seinen beiden anderen Kinos leben… und man müsste darauf hoffen, dass er sein Totkapital nicht aktiviert.

NP: Antony and the Johnsons—You Are My Sister

05oct2005 · Neues aus China

Diese SMS während der heutigen Geschichtsstunde, die ich von Valentin, der gerade mit unserem Rektor, ein paar Lehrern und anderen Schulkameraden in China ist, erhalten habe, könnte auch andere interessieren:

Und, geschichte geil?
(wir fliegen jetzt nach peking (freibier)) :)
gruß valle

Sauerei, oder?

Desweiteren hat die Weberberg Bergzeitung endlich mal einen Schreibstil drauf, der mir doch sehr gefällt:

Am kommenden Mittwoch, 5. Oktober, findet in Biberach wieder der Michaeli-Markt statt. Wieder Gelegenheit, neue Gemüsehobel, Wunderputzmittel und Socken zu kaufen. Und Leute zu bestaunen, wie sie Hieronymus Bosch nicht besser hätte erfinden können.

Mehr kann man dazu wirklich nicht sagen…

NP: Juliette & the Licks—I Never Got to Tell You What I Wanted to

01oct2005 · The Samsung YP-U1X

Samsung YP-U1X

Today I bought an MP3 player by Samsung, the YP-U1X, primarily because it not only plays MP3, but also Ogg Vorbis (They are so humble, they don’t even mention that outside the technical specification; it’s the killer argument!). Since a significant part of my music collection is in Ogg, this was an essential requirement to me. Also, it was pretty cheap—77€ for 512MB flash.

Overall, I’m very pleased with it. The display is sharp and has a good backlight, the design is pleasing (okay, it’s not as nice as a Nano, but not as butt-ugly as some random no-name player). Last but not the least, the usability is fairly good, although this is no reason not to ship with a printed version of the manual, Samsung! Unfortunately, it has no direct encoding to MP3 while recording, but I can live with that.

There is only one thing that bugs me, and it’s a rub a lot of MP3 players have. It’s about sorting the songs and the order they are played in. My music is arranged like ~/Music/Artist/Album/Song. The name doesn’t contain the track number, mostly because I use playlists when I use XMMS and iTunes sorts the songs on its own anyway. I really don’t understand why the players can’t do that too.

Anyway, Ruby to the rescue. The script grok_order.rb takes directories as parameters and makes a list of all music files contained in them. Then, it orders them by their album and track and finally prefixes the files with nnnn- to enforce the order for alphabetically-sorted players.

Therefore, I just need to run

ruby grok_order.rb /Volumes/YP-U1X

and the tracks are in the order they appear on the albums. Enjoy.

NP: Bob Dylan—Hard Times in New York Town

Copyright © 2004–2013