Tags

Faut que ça danse (F 2006)

December 31st, 2007

Das Duo Lvovsky/Tedeschi zum Zweiten.

Handlung

Sarah ist vierzig und ihr Vater Salamon is 80. Was erwartet man noch vom Leben, er sucht, sie wird noch (unerwartet) schwanger. Man muss durchs Leben tanzen

Warum sollte man den Film sehen

Die beste Filmgeburt seit den 30er Jahren. Eine perfekte Komödie. Hier scheint wirklichkum eine Perspektive der Norm entsprechen. Ein Fil für Nonkonformisten, die trotzdem gerne glücklich sind.

Was nervt

Wenn ich schon mal nichts zu meckern finde, dann sollte ich auch nicht krampfhaft nach irgendwelchen Schwächen suchen.

Automatic Resource Management blocks

December 30th, 2007

In his (perhaps successful) attempt to sink the BGGA proposal, Captain Bloch send the closuralists packing to Scala island in the Swiss Sea and promised milk(CICE) and honey(ARM) for the rest.

Besides some remaining choices of freedom a ARM block will look somehow like this:

do (InputStream in   = new FileInputStream(src);
    OutputStream out = new FileOutputStream(dest)) {
  byte[] buf = new byte[1024];
  int n;
  while ((n = in.read(buf)) >= 0)
    out.write(buf, 0, n);
}

I thought this should be pretty easy to imitate in Scala as well. Ideally I’d like to have

with (fi<-  new FileInputStream(src);
      fo<- new FileOutputStream(dest)) {
  val buf = new Array[byte](1024);
  def cp() {
    val n = fi.read(buf)
    if (n>0) {
      fo.write(buf,0,n)
      cp
   }
  }
  cp
}

But writing a “with” is not possible - the 2nd idea was to have a with where the resource is “this”:

with (new DbConnection) {
  executeUpdate("delete from scratch")
  commit()
}

As Jamie Webb pointed out a simple wrapper is easy to write and might do the job:

class ManagedResource[T<:{def close()}] (resource:T) {
  def foreach(f : T => Unit) : Unit =
    try {
      f(resource)
    } finally {
      resource.close()
    }
  }
}

and so it is easy to write:

for(pi<-new ManagedResource(new PipedInputStream);
    po<-new ManagedResource(new PipedOutputStream(pi))) {
  po.write('A');
  Console.println((pi.read).asInstanceOf[Char]);
}

So interesting part it: How does this magic work. On Scala island everybody knows swiss-army knives. We usually use “for”. The code above is equivalent to

for(pi<-new ManagedResource(new PipedInputStream)){
    for(po<-new ManagedResource(new PipedOutputStream(pi))) {
  po.write('A');
  Console.println((pi.read).asInstanceOf[Char]);
    }
}

and each block (or closure) is passed to foreach:

new ManagedResource(new PipedInputStream).foreach(pi=>
  new  ManagedResource(new PipedOutputStream(pi)).foreach(po=>{
     po.write('A'); //where is po defined?
     Console.println((pi.read).asInstanceOf[Char]);
   }
  )
)

Here you see the for-magic in action. For defines some nice symbols pi and po for us that make writeing the function much easier than wrapping it all up in nested anonymous functions.

As the expansion of for shows we are getting the nest of resources as we would get if we would write everything by hand. Less visible is the cleanup. Note that the argument to each foreach is a closure. This means th code is excecute where it is writen and not evaluated and then passed to foreach. By this the finally block in foreach executes two times:

  1. After the print
  2. After po had been closed

So far so simple, but why some might ask can I refer to pi and po as PipedInput/Outputstreams instead of ManagedResource[T]s?

The reason is that “for” is just some compiler magic, what eventually gets executed is the foreach which takes a function T=>Unit (i.e. a funtion with a single argument of type T and return value void). T here is either PipedInputStream or PipedOutputstream and the pi and po are type to accommondate for that.

In practice it is a bit more complicated to define ManagedResource because there are three different possible expansions (via map and flatMap). We investigated as well lazy resource acquisition, but this might open some other wholes, but it is possible to write ManagedResources that aquire the underlying resource iff it is accessed. You opening a ctor to the application developer is too dangerours as inadvertedly an open resource might get passed to the ManagedResource without that it can tell that it got already opened.

Resources with explicit open methods as Josh mentioned in his text would solve this problem easily with no overhead for the application developer. An alternative are Linear Types, but that doesn’t go well together with a language like Scala.

Ungar/Burgundisches Gulasch

December 30th, 2007

Wenn einem partout nichts einfällt, kocht man etwas mit vielen Zutaten…

  • 1 grosse Zwiebel
  • 300/400g Boeuf Bourginon
  • Balsamicoessig
  • 1 grosse Paprika rot
  • 1 grosse Paprika grün
  • 2 Zehen Knoblauch
  • Paprikapulver
  • Tomatenmark (+evtl. etwas Zucker)
  • (getrocknete) Pilze
  • Pfeffer & Salz
  • Rotwein (Pinot Noir aus dem Burgund) zum abschmecken und trinken

Also Zwiebel grob hacken und in eine heisse Pfanne mit etwas Olivenöl (wer mag gern auch mit Peperonis) geben, dann Fleich in mundgerechte Bissen zu schneiden und zu den Zwieben geben. Gut anbraten und dann in einen mittelgrossen Topf geben. Die Pfanne mit 2-4 Esslöffeln Balsamico abbrennen und dann mit Wasser ablöschen und zum Fleisch geben.

Paprika würfeln und Knoblauch einfach schälen und in den Topf geben. Wasser zugeben, sodass die Paprika fast bedeckt sind, rechleich Paprikapulver hinzugeben und bei geschlossen Deckel 60′ simmern lassen.

Eine Stunde vor dem Servieren die restlichen Zutaten beigeben und bei kleiner Hitze weichgaren und abschmecken.

Als Beilage eignet sich Kartoffelpüree, Spiralnudeln oder auch Polenta. Ein frischer Salat und Baguette werden nicht als störend empfunden.

Das ist eine ideales Aufwärmgericht, einmal erkalten lassen ist Minimum, richtig gut wird ein Gulasch allerdings erst nach dem zweiten Aufwärmen.gulasch.JPG

Actrices (F 2006)

December 30th, 2007

Eine neue Welle der selbst-referentiellen Drehbücher scheint über uns herein zu brechen. Es ist immer leicht autobiographische Züge zu unterstellen, hier jedoch mindestens kunstvoll verarbeitet

Handlung

Valeria Bruni Tedeschi (Hauptdarstellerin und Regie) “[der Film erzählt] von einer Frau, die eines Tages meint gerade aufgewacht zu sein, als wenn sie ihr ganzes Leben lang geschlafen hätte, […]”

Warum sollte man den Film sehen

Nett wie die Personen des Turgeniev-Stücks, der Darsteller sich immer wieder überlappend ihre Geschichte erzählen.Für angehende Schauspieler eine zeitsparender test, ob man wirklich wirklich Schauspieler sein will und kann. Kein Zufall wohl, dass ich meine Freundin Johanna beim Herausgehen getroffen habe und sie seltsam kurz angebunden war.

Was nervt

Die Untertitel. Ein Experiment(?) im mk2 Quai de Seine für hör- und sehbehinderte Zuschauer. Für letztere ein guter Witz, die Untertitel waren zu klein und kontrastarm, für Brillenträger nur aus den ersten 10 Reihen lesbar.

Not only open source

December 27th, 2007

I pulled out an old issue of brand eins which remained still unread in the pile of magazines. If you don’t now this magazine yet and you have some interest in off-beat economics and you can read german - get it.

An article with interview with Don Tapscott on his Wikinomics I found quite interesting. The point -in short - is that openess will make you advance quicker and be more successful. I don’t buy everything he says, but he is right in many aspects.

Take the simple example of open source and closed source. Where do you think hides the worst coding and design? It cannot be generalized of course, but closed source has better to get away bad coding. There are exceptions in any domain, Axis for example (at least the 1.4) is a kludge and some closed source stuff I worked on had been beautifully engineered. Anything has to stand the test of time, thus in an active open source problems will be addressed - if not god-like committers reject these changes.

And here I lost interest in continuing until I found Why giving away your code is not dangerous.

Read the rest of this entry »

Acid2

December 25th, 2007

A week ago Microsoft’s IE8 team announced that they passed the ACID2 test. Now - nice present for Xmas - Safari for Windows Beta 4 renders it correctly as well.I checked with Firefox 2.0.0.11 and it is all but OK:acid2.PNGAnyone tried it with other browsers?

Yes, me too! Java is too …

December 25th, 2007

It became irresitable, whenever someone hit a wall in Java or found a nice hack for a specific problem in some other language: Start bashing Java.

In short: If you are still using Java you are

  • … a poorly educated retard
  • … an ignorant who will never see the light
  • … doomed as you programs are unmaintainably bloated
  • … to lazy to write unit tests that replace the declaration of the receiving type in every place
  • … should read “my” blog and stand still in awe

I think this list can be prolonged at will - and it will.

The world is more complicated - fortunately I’d say. Some truths aren’t negotiable:

  • There are programs of different complexity
  • There are programmers of different skill

even more, as slight variations of these

Java should stay Java (?|!)

December 16th, 2007

Josh Bloch’s talk at Javapolis caused quite a stir in the blogosphere, why is best summed up in a blogpost and its comments: Is Java a simple, less skill demanding language or is it - better can it be - also a home for programming geeks.There are two sides and a point can be made for both of them. As java had been need it was a geeky language - admittedly fueled by the internet hype - which attracted brillant minds. Thanks to these forerunners Java is now one of the top choices for mainstream programming. The ones of these who still stick around in the Java world now look with envy on Ruby, Scala and sometimes back on Smalltalk and want to use the ideas and techniques prevalent there in Java as well. But in practice - unless you happen to work at Google - most java programmers are not of this class. Big application written in Java are written and maintained by ordinary developers, not übergeeks that think in monads.The typical Java programmer in a large enterprise is more of the type of the VB programmer, perhaps he did some C or COBOL before. These people and their thinking about programming is deeply rooted in imperative style.A point could - and personally I think it should - be made if projects really require such large staff and if it weren’t better to use more advanced stuff to build it with fewer, but appropriately skilled developers (this is the Ruby claim), but face it, the enterprise world changes too slowly to accomondate for that.More than 10 years ago we evaluated some new development environments as a replacement for Oracle Forms 3. The most interesting candidates had been Forms 4.5 (obviously), Smalltalk (I don’t remember the vendor) and Franz Allegro CLOS (Ok, this had been the one I fancied). Java had been 1.1 or so in these days and the first looks at it were disappointing, C++ had been already in use, but there had been so many problems with it that it wasn’t ever really a consideration. Eventually we went for Forms because it would give our staff the easiest transistion. The main problem with Smalltalk and CLOS had been the paradigm shift. Neither the pure OO of Smalltalk nor the functional programming in Lisp were accessible to them.I think that the same could happen to Java if all the fancy functional programming (I love it!) would get into it. There are three problems

  • FP is not compatible with the mindset of the majority of enterprise programmers. Also FP programs are harder to debug - this is a problem for the prevalent trail-and-error programmer (aka debugging into existence)
  • Java is not Scala, one problem of BGGA is the non-local return. This isn’t an issue in true FP languages which are expression oriented, the statement oriented Java makes it awkward to deal with it
  • DSLs are in fashion and a powerful concept for layering a complex application, but they create as well new languages: You can’t hire a Lisp or C++ programmer and expect him to be immediately productive as they have to learn the DSLs of your projects first

I initially found CICE (which Bloch promotes) to come a bit short, but now I am convinced that this is the right way to change Java as it keeps the characteristics of the language and can easily integrate into larger teams in any organization.This is the curse of being a mainstream language, you most not let out you users in the cold.For the other classes of problems languages like Scala that run on the JVM could be chosen. There some research has to be done by the system architect(s) how such code can integrate with Java code and how maintenance can be organized. This isn’t a trivial problem as not everything from another JVM language integrates seemlessly with Java code (i.e. you use this code as if it was written in Java), as well the question has to be answered (in each indiviual organization) if there is enough stability in the project to support an other language throughout the life-cycle - imagine a freelancer writing some core code in a language only known by him.

Social Stalking

December 7th, 2007

Social networks allow a new way of spamming. Today I got followed by a “network” on twitter. I don’t really use twitter at all, luckily there is a block function on followers. I wouldn’t mind (and I really don’t) if someone is folling me, but doing so just to make me click his website. This is pathetic.  The name of the site is

E x p a t a c u l a r

Sorry for the horrible layout, but I want to avoid that this page will show up even on position 85  in a Google search. Yes, these jerks are horribly successful, 84 hits in Google - and perhaps 3-4 related to the site…

The clever thing thought is that they chose a name that is distinguishable from ordinary expressions. For example: You write a great Webframework and name it lift - googling for it is difficult, because there are so many stories and services about elevators.

Spam salad

December 6th, 2007

Spam belongs in the kitchen…
spamsalad.PNG