Warning: Creating default object from empty value in /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/wp-includes/functions.php on line 341

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/wp-includes/functions.php:341) in /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/my-hacks.php on line 3

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/wp-includes/functions.php:341) in /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/my-hacks.php on line 3
Sebastian Kirsch: Blog » 2005 » April

Sebastian Kirsch: Blog

Tuesday, 26 April 2005

A layman’s take on aspect-orientated programming

Filed under: — Sebastian Kirsch @ 14:12

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/wp-includes/functions-formatting.php on line 76

During my classes on software technology, we were also treated to a short introduction to aspect-oriented programming. Aspect-oriented programming is the latest trend1 in software engineering: It aims to implement separation of concerns not in different classes or object, but as different “aspects” of the same object. Typically, the cited uses are a “logging/debugging aspect", a “security aspect”2, a “persistence aspect” etc.

What’s an aspect? Twenty years ago, people were asking the same thing about object-oriented programming: What’s an object? As no coherent definition of an aspect has yet emerged, I will describe aspects by their most common implementation, AspectJ, a Java dialect. AspectJ introduces the concept of join point interception: at certain points in the program flow, additional code (the aspect) may introduced into the program. “Certain points” in this case are, basically, every method call. One may write a function (an aspect, also called “advice") that will be executed before certain method calls, after certain method calls, or even around certain method calls. This function will be executed in the context of the method call in question, receive all of its arguments, and may basically do what it wants. The methods to which an aspect may be applied can be specified using wildcards.

There is a workgroup for AOP and OOP at Bonn University that has developed an even more general aspect language called LogicAJ, as well as tools for transforming java source code and run-time interception of Java method calls.

Obviously, this is a very powerful technique. The first time I saw it, I said to the instructor, “We’ve been doing that in Perl for years, manipulating the symbol table of other modules and exchanging their subroutines for our own. And we always felt bad about it.”3 I was wary of it; it somehow went against my instincts. (That’s not to say I couldn’t become used to it; I also became used to function and operator overloading in C++.)

My reasoning was thus: I perceive a trend towards more and more structural and semantic clues in programming language, in order to help the programmer to provide better structure for his code. In LISP, we had functions and lists. That was it; LISP is one of the most syntax-free languages – but on the other hand, it allowed you to do everything, to program in any way you wanted. In Java, one of the most successful languages at the moment, we have a distinction between classes and interfaces, objects, object methods and variables, class methods and variables, static variables, final variables, subclasses and subinterfaces, etc. ad nauseam. Some languages provide specialized syntax for member initialization (for example C++), for choosing the appropriate function depending on the type of the argument (function overloading, in C++ or Java) or even according to the value of the argument (pattern matching, for example in the ML language.)

And now people are using this artificial structure to put a totally generic system on top of the language. Which, predictably, leads to problems. The application of aspects to a base program is euphemistically called “weaving” – which works all right and is understandable as long as you have only one aspect. But what happens when several aspects are applied to the same base program? How do they interact? In what order should they be executed? What if one aspect relies on functionality provided by a different aspect? Can an aspect be applied to another aspect (leading to a meta-aspect)? These problems are still unsolved. I doubt that it will ever be solved – the formal semantics of even the simplest imperative languages are thorny enough.

Slashdot picked up this problem in a recent article. The article is based on papers from Passau University that attack the soundness of aspect-oriented programming. They even go as far as titling one paper “Aspect-Oriented Programming Considered Harmful” (recalling Edsger Dijkstra’s seminal paper Go To Statement Considered Harmful”.) They state some of the problems of aspects much more succinctly than I could.

In a way, aspect-oriented programming is the antithesis to another trend in language design – functional programming. Functional programming tries to minimize or even remove side effects of code, specifying that a function with the same input data will always return the same data – regardless of the order in which function calls happen. Aspect-oriented programming does exactly the opposite – the whole purpose of an aspect is introducing side effects to existing code. One may argue which way is better – no side effects or all side effects.

Functional programming does have some advantages: for one, it is usually much easier to debug and to verify than imperative code (and, by extension, object-oriented and aspect-oriented code.) – owing to the fact that it’s virtually free of side effects. Some organizations that tried it reported a marked increase in programmer productivity; Ericsson springs to mind with the Erlang language. A good overview of the characteristics and advantages of functional languages in in the corresponding Wikipedia article.

As I said in the headline, I am just a layman in the field of programming language design. I am not particularly attached to a specific programming language, but I have seen lots of them. Why I just seem to perceive all their worst points, I don’t know; I guess I just have a critic in me.

Footnotes:
1It’s hard not to say “fad” instead of “trend".
2Whatever security actually is in this context.
3It turns out that there is actually a Perl module for aspect-oriented programming that does exactly that; in difference to Java, there is no need to change the Perl interpreter itself in order to implement aspect-oriented programming. The same is true for LISP, where aspects can be introduced using macros. In fact, LISP with its macro mechanism was the first language to introduce the idea of code as a “different kind of data” that can be manipulated by other code.

Wednesday, 20 April 2005

Hitchhiker’s Guide: Quandary and Quintessential Phase

Filed under: — Sebastian Kirsch @ 21:52

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/wp-includes/functions-formatting.php on line 76

The Hitchhiker’s Guide to the Galaxy radio play is reaching its quandary phase, after the tertiary phase was broadcast on BBC in september/october 2004. The first episode will be broadcast on May 3rd, and I hope it will be available as a webcast, like the episodes of the tertiary phase were.

If you want to record the webcast (which was available in RealAudio format the last time), you can use mplayer; it can decode RealAudio and dump streams as WAV files. (I use Audacity for postprocessing the stream, and Lame for encoding it to MP3.) A howto for ripping streams with mplayer can be found here; basically, you use the “PCM” audio device (-ao pcm) and tell it to dump the data to a file (-aofile h2g2.wav).

Sunday, 17 April 2005

Atelier-Theater im Mai

Filed under: — Sebastian Kirsch @ 19:57

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/wp-includes/functions-formatting.php on line 76

Hier meine aktuellen Termine im Atelier-Theater, also die Abende, an denen ich Technik mache:

Wer im Programm noch weitere Veranstaltungen findet, die ihn interessieren, ist natürlich auch dazu herzlich eingeladen. Nur wird er meine Wenigkeit dann nicht antreffen.

Die Veranstaltungen beginnen jeweils um 20:30, Karten kosten 15€, ermässigt 12€ und können unter 0221-242485 reserviert werden. Das Theater selbst ist in der Roonstrasse 78, gegenüber des Rathenauplatz.

Allgemeines zu meinem Engagement im Atelier-Theater habe ich hier zusammengestellt.

Saturday, 16 April 2005

Heute: Lutz von Rosenberg-Lipinsky

Filed under: — Sebastian Kirsch @ 01:20

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/wp-includes/functions-formatting.php on line 76

Und wieder ein Tipp für Kurzentschlossene: Lutz von Rosenberg Lipinsky spielt im Ateliertheater, Roonstrasse 78, 50674 Köln. Beginn ist 20:30 Uhr, Tickets kosten 15EUR, ermäßigt 12EUR, und können unter 0221-242485 vorbestellt werden. Licht- und Tontechnik macht wieder meine Wenigkeit.

Ich zitiere mal von den Seiten des Atelier-Theater

Lutz von Rosenberg Lipinsky hat die Stellung gewechselt. Er wurde runtergeholt. Auf den Boden der Tatsachen. Sein Fleisch ist noch willig. Aber der Geist ist schwach…

Er will nicht mehr. Obwohl er noch kann. So sucht er sich eine neue Mission: Nicht mehr gebraucht zu werden. Er akzeptiert die Überlegenheit des weiblichen Geschlechts.

Er lässt die Frauen machen. In jeder Lage: Sie wissen nicht nur, sie können tatsächlich alles besser. Für einen Mann gibt es nur noch eine Zukunft: Als Feminist. Lutz von Rosenberg Lipinsky legt sich in seinem neuen Solo in den Schützengraben des Geschlechterkrieges. Und bleibt liegen. Endlich. Unten. Endlich liegen, gelassen und geblieben.

Ich habe vor, meinen Plan für Mai sogar mal im Voraus hier zu schreiben.

Monday, 11 April 2005

Infobesity

Filed under: — Sebastian Kirsch @ 10:59

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/wp-includes/functions-formatting.php on line 76

I learned a new word today: “infobesity” (information + obesity). There is also “infogluttony". Both can be caused by excessive googleization.

Saturday, 09 April 2005

Andy Behrman: Electroboy

Filed under: — Sebastian Kirsch @ 13:05

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/wp-includes/functions-formatting.php on line 76

[cover]I’m reading at a quite prodigious rate at the moment – I covered about as many books in the first three months of this year as I did in the whole last year. It’s not that I have too much free time on my hands at the moment, rather that I need something to take my mind off things in the evening.

So, what about Electroboy? The book is subtitled “A Memoir of a Mania", and that’s what it is. It’s the autobiography of one Andy Behrman from New Jersey, movie producer, art dealer, public relations agent – but also male stripper, hustler, hardcore drug user, and convicted felon for selling counterfeit art. Driven by an intense manic depression that went undiagnosed and untreated for a decade, he attained ever greater heights, securing millions in PR contracts and art deals, working 22-hour-days. But he spends the money as soon as he takes it in, on shopping sprees (spending 6000$ for pullovers because he thinks they’re all so wonderful), flying from Zürich to the Bahamas and back, to balance the cold and hot weather, flying to Berlin to see the fall of the Berlin Wall, storing his money in wads of 25.000$ in his freezer till he feels the compulsion to take it all out and spend it.

Behrman is the “real Americal Psycho” – a real-world version of Bret Easton Ellis’ protagonist. Outwardly, he is hugely successful, fitting right into the crazy world of 1980’s New York art scene. But he is also driven by an intense mania, over which he has no control. He craves the thrill of his manic episodes and will do anything to experience more of them.

And – much to the dishonour of the psychiatric profession – his illness is not properly diagnosed for more than ten years, even though he is almost constantly in some kind of therapy. But this may also be due to him only seeing a psychiatrist for his depressive episodes, not for the manic episodes. He is almost addicted to his mania, and sees no reason to stop it. He only seriously persues therapy when in addition to mania and depression, he experiences psychotic episodes. In the end, one psychiatrist finds a drug cocktail that, combined with electroshock therapy, seems to help him and make him sane again.

What are the implications of this book?

I think it reminded me that the playing field is level for all of us. There ain’t no such thing as a free lunch.

In our youth, we all have idols – people we admire, people we envy, people we strive to be. But you also have to be aware of what you have to sacrifice in order to attain that kind of life. If you find someone who excels in one field, chances are he had to give up other things – things that may be very important to you yourself. And if you stumble upon a career that seems to be too fabulous to be true, perhaps the person had to sacrifice something equally fabulous, like his own sanity. Everyone has to find his own mix, everyone has to find out which elements of his life are important to him.

I have been in situations that demanded that kind of decision – decisions about which kind of person I want to be. I declined some opportunities that, perhaps, would have led me to a much more exciting life. Perhaps not, perhaps I’d have failed the challenges. But in the end, I found my own way of life, found out what’s important to me and what challenges I have to overcome in order to get happy. I made some wrong decisions, but also a lot of right ones. I learned a lot. I found out a lot about what makes me happy. I think that some of these revelations would have taken a much longer time, had I chosen a different path through life.

If you want to know more about the book, Andy Behrman also has a web site about Electroboy. German news magazine Der Spiegel published an article about Behrman in february.

Wednesday, 06 April 2005

Heute: Kattrin Kupke

Filed under: — Sebastian Kirsch @ 09:21

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/wp-includes/functions-formatting.php on line 76

Heute abend spielt Kattrin Kupke ihr Stück “La Deutsche Vita” im Atelier-Theater, Roonstrasse 78, 50674 Köln. Beginn ist 20:30 Uhr, Tickets kosten 15EUR, ermäßigt 12EUR, und können unter 0221-242485 vorbestellt werden. Und ich mache die Licht-, Ton- und sonstige Technik.

Hildes eigene Worte zum Stück:

Was für ein Land, in dem Geiz geil sein soll und glücklich nur noch die freilaufenden Hühner. Was für ein Land, in dem sogar Vegetarier ihre Sparschweine schlachten und Hildes Konto so im Minus ist, dass sie nur noch bei Plus einkaufen kann. Na Gott sei Dank ist die freiwillige Mitgliedschaft im Verein „Schöner Scheitern“ noch umsonst.

Was bleibt Hilde da außer einem homöopathischen Selbstversuch: Lachesis in Höchstpotenz und Überdosis! Und die Wirkung ist total phänomenal … nach Erstverschlimmerung offenbart sich der lächelnden Hilde die Kunst, für immer reich zu sein!

Monday, 04 April 2005

Samuel R. Delany: Empire Star

Filed under: — Sebastian Kirsch @ 23:09

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/wp-includes/functions-formatting.php on line 76

[cover]Empire Star is the novella that started my interest in Samuel R. Delany, many many many years ago. As a teenager, it fascinated me, it opened up a whole new view of what a writer could do with language and story-telling. The story of “Comet Jo” stuck in my mind, who has to go on a journey to discover his true self, and meets himself again at the beginning of his journey. The circular nature of the story captivated me, and the frequent hints that all may be more complicated (or multiplicated) that it seems at first glance held my interest.

For a long time, Empire Star was out of print. It has now been published again together with Babel-17, because at about 90 pages, it is too small to be published on its own. I’m very glad to have it in my bookshelf again. I originally read it in a dreadful german translation, and have since lost the book that contained it.

Sunday, 03 April 2005

Kochbücher: Encyclopédie de la cuisine asiatique

Filed under: — Sebastian Kirsch @ 21:19

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/wp-includes/functions-formatting.php on line 76

[cover]L’encyclopédie de la cuisine asiatique (Linda Doeser)

Mein dickes asiatisches Kochbuch. Hier kommen die ganzen (oder die meisten) leckeren asiatischen Rezepte in meinem Blog her. Laut Impressum die Übersetzung eines englischen Kochbuchs (The Ultimate Chinese and Asian Cookbook), aber ich habe nur noch die französische Übersetzung gekriegt. Eine deutsche Übersetzung scheint nicht zu existieren.

Die Enzyklopädie ist ein reines Rezept-Buch, kein Koch-Buch: eine Sammlung von 400 Rezepten auf 500 Seiten, mit vielen Bildern. Über die Qualität der Rezepte kann sich ja jeder hier in meinem Blog selbst überzeugen – ich habe auch das Gefühl, dass ein paar der Rezepte vielleicht “ursprünglicher” sind als in anderen asiatischen Kochbüchern, oder ich sie zumindest in anderen Kochbüchern noch nicht gelesen habe.

Das Sprachproblem hat sich auch als lösbar herausgestellt, mit französischem Wörterbuch und diversen Internet-Wörterbüchern. Und wenn man partout was nicht versteht, dann improvisiert man halt. Wie immer beim Kochen.

Friday, 01 April 2005

Data Structures in Python

Filed under: — Sebastian Kirsch @ 19:05

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /homepages/u37107/www.sebastian-kirsch.org/moebius/blog/wp-includes/functions-formatting.php on line 76

Modern programming languages, especially scripting languages like Perl and Python exhibit a suspicious lack of data structures. They provide arrays (or lists), and associative arrays, which are often implemented using a hash table with a fixed number of buckets.

More complicated data structures are missing: you won’t find binary search trees (such as AVL trees or red-black trees), or priority queues (like fibonacci heaps), or tree structures for implementing sets in their standard library, nor data structures for common problems, such as graph structures. And this is despite the fact that the standard library of those languages is usually huge, providing everything from HTTP clients over modules for manipulating emails to XML-RPC interfaces. (In contrast, the C++ Standard Template Library provides a set and priority queue implementation, as does the Moscow ML standard library.)

Why is that? Is it because everyone who needs a specialised data structure is supposed to implement it himself? Or are the performance gains deemed to be negligible because the built-in data structures are heavily optimized and therefore “fast enough"? Or because nobody expects these languages to be used in performance-critical environments anyway? I don’t know …

Common wisdom in data structure design is that an algorithm that is in a lower complexity class will always outperform one in a higher class for large problems, regardless of its overhead. So a search tree implementation in Python should be able to outperform the built-in hash table implementation for large data sets regardless of how well optimized the hash table is.

For example: A lookup in a hash with 8 buckets (the standard size in Perl) and about 10000 items will need on average about 600 operations. (On average 1250 items in one bucket, and the right one will be found after searching on average half of the items.) Hash tables are only appropriate when the number of items that will be stored is about the same as the number of buckets. A lookup in a balanced search tree of the same size will need at most 14 operations (because a balanced binary tree with 10000 nodes has a depth of log2(10000) ≈ 13.3)

Every computer science student has implemented these data structures at least once, and most have before the end of their second year – so it cannot be the shortage of capable programmers or maintainers that prevents them from being included in the standard library.

Of course, there are Perl packages on CPAN that implement trees and sets and whatnot. Usually, they are at version 0.1 or 0.3 and have not seen a release for a couple of years – and look like they were implemented by a computer science student before the end of his second year. By putting those algorithms in the standard library, one would ensure that the code is properly maintained and follows the coding standards.

For Python, there is an online book called Data Structures in Python, with downloadable source code. The author has a Ph.D. in computer science, was associate professor at the University of Waterloo, and published two books on data structures and algorithm with OO languages, namely Java and C++. These books, plus their C#, Python and Ruby versions are all available online. However, the source code is copyrighted by the author and is not licensed for further use, so one cannot use it in one’s own projects.


Copyright © 1999--2004 Sebastian Marius Kirsch webmaster@sebastian-kirsch.org , all rights reserved.