السبت، 28 نوفمبر 2009

Christopher Avery on responsibility

Christopher Avery has a nice take on the topic of responsibility:

In his view, if something goes wrong, the mind has several automated responses, none of them completely adequate (in order of increased maturity):

  • Denial

  • Lay blame

  • Justify: Interestingly, he does not think that justifying one's actions is useful and puts this activity in a category similar to laying blame.

  • Shame: Obviously, beating yourself up over something that went wrong is as unproductive as beating someone else up.

  • Obligation: There is a lot of honor in the idea that someone “has” to do something. On the other hand, using the words “have to” (as in “I still have to do the dishes”) automatically creates friction as no one likes to be forced to do something, even by oneself.

Avery suggests that true responsibility goes beyond all these automated responses. One can work towards the goal of responsibility by refusing to accept some of the mind’s simpler answers for a given problem.

Adults must be supervised

This is a photo I made in London:It is obvious what they mean, but I liked the idea of adults having to be supervised by children.

الاثنين، 23 نوفمبر 2009

JavaScript will (probably) be moving forward

A quick recap of JavaScript history: For a long time, ECMAScript 4 was a really feature-rich proposal for a next generation JavaScript. It even included optional typing! Sadly, the involved parties prevented this proposal from ever becoming a standard. Instead ECMAScript “Harmony” was proposed that changed very little so that everyone could agree on it. In order to avoid confusion that proposal was called ECMAScript 5.
In the video “ECMA Harmony and the Future of JavaScript”, Brendan Eich talks about ECMAScript 5 history and possible future features. And this is where it gets interesting. Among the features that might make it are catchalls (functions that supervise how an object is accessed), classes as object facories, concurrency, iterators (to abstract iteration), generators, runtime type-like guards, versioning. Modules are being worked on at commonjs.org, as a library. More on the proposed features can be found at the ECMAScript wiki.

الأحد، 22 نوفمبر 2009

Things I miss most in Java

The following is a list of the language features I miss most when programming Java:



  • Closures: are useful for implementing abstractions that involve behavior. Smalltalk provides ample proof that functions and object-orientation go together well. Instead of giving Java functions as objects, its creators decided to support the encapsulation of behavior via inner classes. At long last, it looks like Java 7 will have closures. They are essentially functions with built-in compatibility with single-method interfaces. Not perfect, but certainly very useful.

  • Modules: are also coming to Java 7. Reinier Zwitserloot has a nice write-up of the rationale and current state of Jigsaw, Java’s module system. It is interesting that one requirement was that module have to cross-cut packages so that the core of Java can be properly modularized.

  • Generators: let one repeatedly invoke a method. The method does not return a value, it yields it. A yielded value is passed to the caller in the same manner as with a return statement. But, the next time the method is invoked, execution continues after the last yield. Thus, a yield suspends method execution, and an invocation resumes it. This helps whenever data has to be computed lazily, on demand and in a piecemeal fashion: (The beginning of) an infinite list can be iterated over by writing a generator with an infinite loop. Tree iterators become trivial to write; one uses a generator and recursion. And so on... Astonishingly, generators are already in an experimental version of the JVM.

  • Mix-ins: are class fragments that can be added to (mixed in) any given class, while defining it. The effect is similar to multiple inheritance, but results in a chain of classes (and not a tree, as with true multiple inheritance). Mix-ins are also sometimes called abstract subclasses, because they are classes whose superclass is left to be filled in. While it doesn’t look like mix-ins will be added to Java anytime soon, they could be simulated by tools as interfaces with implementations: If one attaches method implementations to special mix-in interfaces, those implementations could be automatically added to classes implementing such interfaces. While the compiled code will contain redundancies, the source code won’t and subtyping will work as expected. The attaching could be done by letting an annotation refer to a class.

  • Post-hoc interfaces: Wouldn’t it be nice if one could let a class implement an interface after it has already been defined? After all, one can add new leaves to the inheritance tree, why not new inner nodes? This would give one many of the benefits of duck typing, while keeping compile-time checking.


While other features (such as multiple dispatch and better code browsing) would be nice to have, the above list contains my most urgent wishes for Java.

الخميس، 19 نوفمبر 2009

Java 7 will have closures!

These pages have the details:
  • Closures after all?” is continually updated with new links and information.
  • Gafter’s “Closures for Java” has been updated with the new syntax which closely resembles FCM. Thus, the new closures use FCM syntax and (a simplified version of) Gafter’s type system. Correction: Gafter’s spec was written 2 weeks before Devoxx, as an attempt at a compromise between the competing proposals.
  • Reinier Zwitserloot has more background on how everything came about.
  • Update 2009-11-22: Stephen Colebourne gives an overview of the current situation.
  • Update 2009-12-03: Mark Reinhold posts “Closures for Java: The Q&A”.

السبت، 14 نوفمبر 2009

Mac OS: dim other displays while playing a movie

The scenario is obvious: You occasionally connect a projector to your Mac (be it a notebook or a desktop machine). While projecting a movie, the display of the Mac should be dimmed, in order to not distract from the projection. Luckily, the three most important applications for playing movies now support this feature. They allow one to dim when going into full screen mode:


  • DVD Player: Preferences → Full Screen → Dim other displays while playing


  • QuickTime Player 7 (old): Preferences → Full Screen → Background Color → Show on all displays


  • VLC: Preferences → Video → Black screens in Fullscreen mode (should play everything that QuickTime Player can)


Now, even better would be to let unused displays sleep, but this is definitely good enough. If you encounter a program that does not have this feature, you can use Shades as a work-around.



Update 2010-05-28: QuickTime Player 7 – which still comes with Snow Leopard – has the aforementioned preferences. Alas, the current version of it has not.

الاثنين، 9 نوفمبر 2009

FRITZ!Box: get call notifications on a Mac

The FRITZ!Box DSL modem also connects telephones to an analog line. In such a setting, the nifty Frizzix can be used to receive call notifications on a Mac. All you need to do is install Growl and then run Frizzix. The following image shows a Growl notification being displayed in the lower right corner of the screen. Note that in this case, “Axel Rauschmayer” is the caller (as I’ve called myself with my cell phone).