Month: January 2007

The Design and Evolution of C++

C++ language despite of the powerful mechanisms supported is not a language for the faint hearted. Two forces drive its peculiar concept of friendliness (it is not unfriendly, just very selective) the backward compatibility with C and the effort to not getting in the way to performances. This book, written by the language father, presents and analyzes the language history and the design decisions. And, given the writer, the perspective you get reading the book is very interesting and more than once helps to shred some lights in the dark corners of the language.
The history is very interesting since it details how the language genesis and marketing went from the AT&T labs to the academy and industry.
C++ design principles are presented and the most notable is that of ease of teach-ability. Several time proposed/existing features had been modified or dropped entirely because they were not easy to teach.
Another very interesting principle is the “you don’t pay what you don’t use”, meaning that features added to the C language in order to define the C++ language were designed so that the programmer would not incur in any penalties if not using them. That’s why if a class has no virtual method, then the pointer to the virtual methods table is not included, saving the pointer space from the class instance memory footprint.
Aside from answering to many questions, the book opens up a bunch of new ones. For example, the very first implementation of C++ has been developed practically around a threading library. Now more than 30 years later, in a world with an increasing presence of multi-core machines, the C++ standard still lacks of a multithreading / multiprocessing facility.
Also Stroustrup asserts more than once that a Garbage Collection way of managing memory could be add by a specific implementation. But fails to explain how this non-deterministic way of terminating dynamic memory life could deal with the deterministic needs of destructors. Likely I’m just to dumb to figure out myself.
The big miss I found in the book had been a comparison with Java language. Basically one of the great contenders for the title of most widely used programming language. Java, on its side, has some interesting approach to language design that conflicts with those of C++ (e.g. the C compatibility issue). Therefore it would have been nice listen from Bjarne voice his thoughts about. In his defense it has to be noted that by the date of this book hit the streets, Java hype had just been started.
Last complain about the book is the lack of conclusions. The book seems cut a couple of chapters before the real end. Aside from stylistic point of view, some words about the future evolution and perspective would have been at their place at the end of the book.

So Long and Many Thanks Folks

I don’t like the way it is being put. By now everyone understands there’s something really wrong with the climate. You don’t need to be a genius – just have a look at the calendar and the thermometer.Rather than being some degrees below zero, this winter we have blossom, buds and shoots. That’s not the way that’s expected to be in mid-January.
So media are starting covering the issue. And I don’t like the way they are handling this. They are telling us that unavoidably things will go worse and worse – desertification, sea raising and submerging lands and cities, drought, and so on. Now, even more alarmingly, they speak about huge number of casualties and economic crashing in the Mediterranean areas.
The reason I don’t like in this message is the implicit statement that all this is ineluctable and unavoidable and it has always been. In other words – you are going to die, start considering it… but, hey, you wanted comfort, car and TV-set? Don’t complain… die quietly please.
Since I was young (that’s now more years than I’m keen to mention), environmentalists and scientists are telling us, our government our industry leaders that we were polluting too much, that we had to choose a more sustainable way of exploiting our planet resources. We also had a number of summits and round tables (Kyoto anyone?) about the matter where light or no actions were agreed.
If now it is too late, the only fault we could be blamed about is not having given our vote for different political leaders more attentive to these problems.
But is it true that nothing can still be done?
It is true that things change quickly, often with an exponential rate rather then linear. The meaning is that it could well be that we get aware of a certain effect when it is too late to act on its cause removal.
To explain exponential growth I really like the chessboard example. Everyone knows the legend. It is about the payment a wise man asked to his King for having taught him to play chess. The exact amount of the payment had to be computed with the chessboard. Starting with one grain of wheat in the first square and doubling the amount at each square. That is 1, 2, 4, 8, … and so on.
Here comes the most interesting point – the King gave him a couple of sacks thinking that it was enough, but the wise man objected that the exact quantity was more than the entire collection of the whole kingdom.
What’s so amusing? It is that exponential growth fights and defeats our intuition. You can consider it a slow pace linear process until it really explodes.
Back to the weather it is well possible that now it is to late to cancel the nefarious effect of the mankind on the environment, but I am strongly convinced that it is never too late to do the right thing.
I have the impression that media are just relaying propaganda. What is the most convenient move? Just do nothing, let the poor people die while those who hold the power survive. It won’t be hard to survive if you can live everywhere you like, if you can afford water, food and energy at any price, if you can have your personal army.
“Dear passengers this is the captain speaking, the smoke on the right side of the aircraft is the engine that’s burning, the little spot below it’s me with the only parachute that was on-board… I hope you enjoyed the flight”.

Back from Sciliar

I had great days on the Alpe di Siusi (Alp of Siusi) or SeiserAlm as those who live there call their home. It is a lovely and smooth plateau at around 1800m, braced by imposing Dolomite pikes. Sasso Piatto (“Flat Stone” a sort of understatement) bounds the East side, while Denti di Terra Rossa (“Red Soil Teeth”) bound the South Side and ends with the tooth shaped Sciliar pike.We had sun for nearly seven days and, despite of the warm winter, snow was enough to ski.
Alas, in order to appreciate great things, we have to compare them with the grey, dull industrial landscape of Castellanza, that’s why (I guess) I’m back home and at work.
The first interesting surprise hitting me at work has been the anticipation of the milestone I was working for. Our customer product has been selected for a design prize, so we are expected to deliver the working product earlier. Anyway we’re working hard, against time and hardware shortage to hit the milestone nonetheless.
At home, Santa (in the person of my wife) gave me a Xbox 360 and I started playing a not-so-Xmas-spirit game: Gears of War. I’m about the first boss and I should say that it’s great. From the technical viewpoint I think this is one of the first real next gen game. It runs on the Unreal 3 engine and the look is as detailed as awesome. The gameplay is based on taking cover, i.e. as soon as enemies are encountered you should take cover or you get badly shot. This is somewhat different from the classical shooter where the player drives a Rambo-like bullet-proof character (well, in Serious Sam, this was intended). The first boss is a chasing game play – run away from the monster, let him smash the doors for you and eventually take him off. Great.
While I was so fresh from the holidays and relaxed from Gears of War, I decided to update my notebook to the latest linux available. I gave a brief look to Sabayon Linux, only to discover that it behaves badly with the Toshiba touch pad and apparently has no support for my wireless adapter (I can’t believe that today distros still do not support the Centrino wireless adapter that is so widespread and at least two years old). So I turned to what I know quite well – Fedora Core 6.
I opted for the upgrade option instead of the install. Years ago I was used to upgrade, only to find that the system resulted in something that wasn’t completely new nor old and often was prone to glitches. A friend of mine suggested me to never upgrade, rather to backup the /home directory, install and restore it. This time I was so light from the holidays that I decided that an upgrade could do.
Well, I was wrong.
Yes I got a sort of FC6 tailored on my previous FC4 installation, and, yes, the wireless adapter sorta worked. But I could only browse the google website. No matter how I set the firewall/SELinux properties, there was no way to browse the rest of Internet. But this is another story.