Back after a Break

I didn’t write anything for quite a while. But now I am back 🙂

My break had two reasons. The really good one is that I became father of a little daughter named Thalea in the mid of July. Naturally I hope for the next talent in computer science but who knows. If she is only a little bit like her mother she will absolutely have her own head and push her own ideas!

If you hope that I will publish family pictures regularly now I have to disappoint you. Family business stays private. The next public pictures of Thalea you can see perhaps in her own blog one day. 😉

The second reason for not publishing articles was the deceasing of my beloved IBM Thinkpad Tablet. I think the heat and moisture of Hainan have been too much for it and when the fan finally gave up …

As a more suitable solution for the Hainan weather conditions I bought a desktop computer with many fans 😉 and installed Linux in form of the Fedora 11 distro on it. Perhaps installed is said too much. After over a week of installation I am still struggling to get all components supported and fully up and running. Hope that one day I manage to have installed this cool machine as it should be, including accelerated graphics and dolby surround sound.

Nevertheless I will try to revive the laptop. The tablet functionality is simply cool to manipulate images.

Posted in Misc | Tagged | 1 Comment

Ruby Objects, Class-Objects and MetaClass-Objects

After a while of evaluation I started over programming mainly in Ruby about two month ago.

Long time ago I learned for a short while object orientation programming in Smalltalk-80 but soon started to use C++, first with the AT&T preprocessor and later with the gcc. Since 1998 I am programming Java. All these years have left me with a certain idea of practical object orientation which was not really what I learned from Smalltalk-80.

But Ruby changed things a lot as I have to admit. In Ruby everything is an object and Ruby is interpreted like Smalltalk! What are the consequences. This is what my post will try to figure out.

From Ruby Core – Class documentation:

Classes in Ruby are first-class objects—each is an instance of class Class.

A big help for understanding Ruby Objects has been the Pickaxe Book.

In Ruby everything is an object. This includes as well Integers as Classes. So what happens if you write something like:

  a = "test1"
  b = "test2"

You get references a and b to your Objects a and b of class String which is an object too and has the class object Object as superclass. So far the only difference is that the Classes are realized as objects themselves.

But you can do things in Ruby which you cannot do in C++ or Java. For example you can add a method only to one object like:

  c = 'test'
  class < < c
    def double
      self + self

This piece of code generates a virtual class exclusively for the object c.

What happens if you try the same for integers? If you try the same for integers it should look like object b in this graph:

The code for this would be:

  b = 7
  class < < b
    def double
      self + self
  TypeError: no virtual class for Fixnum

So what is this? I thought that all objects can have virtual (or singleton) classes which hold the methods specially attached to this object?

The solution is quite simple. There are special classes like Fixnum which are called eigenclasses. Instead of a reference to an object these classes return the class object itself (for example as parameter for a method call). Eigenclass objects only have one single Object for example for each Fixnum value. This is why it is not possible to create singleton classes for eigenclass objects.

But what you can do is to extend an eigenclass with your own attributes like:

  class Fixnum
    attr_accessor :name
  b = 5
  => Fixnum 'five'
  => "five"

The next thing I want to do is to define a class variable. I found a nice article about class variables in Ruby on John Nunemakers blog. At first I was really astonished about this:

  class Polygon
    @@sides = 10
    def self.sides
  puts Polygon.sides # => 10

This is a Polygon class with a class variable which holds the number of sides of the Polygon and a getter class method. Now we create a subclass which inherits from Polygon and holds its own number of sides:

  class Triangle < Polygon
    @@sides = 3
  puts Triangle.sides # => 3
  puts Polygon.sides # => 3

What happens here? The Polygon sides have been set to 10 originally.

To understand this behavior you must have an understanding about the Ruby Meta-class and look-up mechanism for methods and variables. When you create a class variable or method Ruby actually creates the following Meta-Class for you:

The Meta-Class hold the Class level extensions of your class. If you subclass Polygon now you have the following image:

In Ruby everything, including class definitions, are executable code. The assignment to the class variable @@sides in the class Triangle leads the Ruby interpreter to search for an existing class variable @@sides which he finds in the Meta-Class of the superclass Polygon first and makes an assignment to this variable instead of creating a new meta-Class with the same variable for Triangle.

So what can we do if we want to have a variable for the sides of our class which is unique to the according class? As the class itself is an object you can assign a variable to the class object

You can do this with the following code:

  class Polygon
    class < < self
      attr_accessor :sides

for the Class Polygon and the same for class Triangle. Be aware that you have to assign the accessors to the class object and not to the object itself.

I hope that my explanations are correct and can help other newbies in Ruby to understand the Class handling a little bit.

Posted in All, Ruby | Tagged , | Leave a comment

Tropical Thunderstorms

When I arrived in Haikou a year ago my only experience with a tropical region has been 6 month on Martinique between my studies in physics and the start of my computer science studies. On Martinique the rainy season is about 3 month and the rest of the year there is more or less sunshine.

The September in Haikou last year has been nice even though it was quite warm with around 38°C. In October the Taifun season began and I can tell you that we got drown in our apartment in the fourth floor. The wind pressed the gigantic amount of water which has been carried along with the Taifun directly through the windows into the apartment. This rainy period continued more or less until mid December. The rest of December and January have been dry but unusual cold, specially because there is no heating in the apartment.

In February it started to rain again. First only sometimes and after a while more and more. Since two month now we have temperatures above 30°C and about one thunderstorm every day. The record has been three thunderstorms in a row during one afternoon. When you are outside in such a storm, there is no protection. When you wear a slicker you are wet from your own sweat, otherwise from the rain. The water in the road can easily raise to a torrent of more than 10cm depth. There is no sewer which can take that much water in such a short time even though the city of Haikou is cleaning them all the time. A gaze through the window shows me grey in grey during such a storm and I can hardly see the neighbour building which is only about 30m away.

I never imagined that on a tropical island like Hainan it could be more rainy than in northern Germany where I come from and which I once left because of the “bad weather”. I think life is really funny and we should enjoy this fact much more ! 😉

Posted in Around the World, China | Tagged , , | 1 Comment

Joke about EU request to stop internet filtering in China

This can only be a political joke!

I was pointed by the german and Die Neuen Menschen blogs to an article you can read in the news at N24 or Deutschlandradio about a statement from Viviane Reding, commissioner for media of the European Union, about the chinese internet filters.

“Das Blockieren oder Filtern bestimmter Internet-Inhalte ist fĂŒr die EuropĂ€ische Union völlig inakzeptabel.”

or in english translation:

“The blocking or filtering of certain internet content is completely inacceptable for the European Union.”

I mean the enforced distribution of the “Green Dam – Youth Escort” software is discussed in China as well and the installation is not mandatory any more as stated by the chinese government.

But I would suggest the European Union to first stop all internet filtering within the Union before pointing out that they think that internet filtering is inacceptable !!!

The internet citizens in Europe are laughing about this sentence. 😀

Posted in Around the World, China, Misc, Politics | Tagged , , | Leave a comment

Politik der verbrannten Erde

Was sich derzeit in der deutschen Politik so abspielt lĂ€ĂŸt sich nur noch schwer mit einem Generationenkonflikt erklĂ€ren. Ich möchte hier nicht noch einmal auf die Argumente gegen eine Vorratsdatenspeicherung oder eine Netzzensur eingehen wie sie in der letzten Zeit beschlossen wurden.

Was mich erschreckt hat ist wie die regierenden Politiker mit den jungen MitbĂŒrgern in Deutschland umgehen. Wahrscheinlich mit Blick auf die Demographie, die bestĂ€tigt, daß das Gros der WĂ€hler bereits genauso ĂŒberaltert ist wie die Kader der regierenden Politiker, wurden die Mitglieder der oppositionellen Bewegung als Sympatisanten wenn nicht gar selbst als KinderschĂ€nder dargestellt. Die jungen Menschen die mehr als berechtigte Einwende gegen die Zensurgesetze haben und diese auch nĂŒchtern argumentativ untermauert konnten, wurden wie kleine Kindern abgekanzelt und mit leeren Verbalien abgespeist. In der ganzen Debatte um das neue Internet-Zensur-Gesetz habe ich von keinem der befĂŒrwortenden Politiker gehört das er einmal direkt auf die Argumente der Gesetzesgegner eingegangen ist oder diese gar wiederlegen konnte.

Die grĂ¶ĂŸte Frechheit habe ich dann heute in einem Interview in der Zeit-Online mit Frau von der Laien und Franziska Heine gelesen.

Heine: … Die Unterzeichner der Petition haben gesehen, wie Entscheidungen in der Politik getroffen werden – und das wird sie nachhaltig prĂ€gen.

von der Leyen: Das ist doch etwas Tolles

Heine: FĂŒr uns war das nicht so toll.

von der Leyen: Das ist lebendige Demokratie.
… NatĂŒrlich kann Frustration entstehen, wenn man merkt, dass da auch andere demokratische Prozesse laufen, zum Beispiel Ausschussberatungen, in denen gewĂ€hlte Vertreter Entscheidungen fĂ€llen, …

Ich möchte einmal fragen, was soll daran toll sein wenn einem auf den Kopf gekackt wird? Denn nichts anderes haben die Politiker gerade mit den meist jĂŒngeren Gegnern des Zensurgesetzes gemacht. Gibt den Politikern der Fakt das sie einmal gewĂ€hlt wurden tatsĂ€chlich fĂŒr die gesamte Legislaturperiode das Recht die Bevölkerung bei den Entscheidungen die sie treffen total zu ignorieren? Na, da haben die jungen Leute ja wirklich den politischen Umgang in einer Demokratie gelernt.

Und dann wird da auch noch ganz frech gelogen:

von der Leyen: … Diese Daten werden jetzt sofort gelöscht. So steht es im Gesetz.

Hat Frau von der Laien das Gesetz zur Vorratsdatenspeicherung wieder abgeschafft? Also stehen die Daten ohnehin bereits gespeichert zur VerfĂŒgung und mĂŒssen “bei Bedarf” nur noch angefordert werden.

Ich wĂŒrde diese Art Politik zu betreiben als Politik der verbrannten Erde bezeichnen. Die Kontrollmechanismen werden heute unter Beteuerung sie nie zu missbrauchen eingefĂŒhrt, populistisch ausgeschlachtet und gepusht mit dem Killer-Argument gegen Kindesmissbrauch zu kĂ€mpfen und wir alle haben dann in Zukunft damit zu leben. Diese Zukunft kann fĂŒr einen jungen Menschen noch ziehmlich lange dauern! Aber was interessiert das schon einen Politiker der bereits an der Grenze des Rentenalters ist (oder bereits darĂŒber hinaus) und noch ein letztes Mal in den Bundestag gewĂ€hlt werden möchte!

Ein guter Artikel ĂŒber die Situation auf Spiegel-Online. Ich denke die Politiker, die die ganze Zeit fĂ€lschlicher Weise behaupteten das Internet wĂ€re ein Rechtsfreier Raum, werden in Zukunft feststellen mĂŒssen das die Proteste gegen ihre Politik nicht nur auf das Internet beschrĂ€nkt sind sondern direkte Auswirkungen auf ihre Wiederwahl haben werden weil dort wirklich Menschen im richtigen Leben dahinter stehen!

Hier noch ein sehr interessanter Artikel auf Heise-Online ĂŒber den Umfang der Informationen die bei der Vorratsdatenspeicherung gesammelt werden. Im Internet sind die BĂŒrger lĂ€ngst transparent! Wann kommt die Forderung das sie dies im Leben ausserhalb des Internet ebenfalls werden mĂŒssen?

Posted in Germany, Politics | Tagged , | Leave a comment