Category: Blog

Easter Aftermath

Happy Easter… usually it starts with something like this, then you find 4 days later at the workplace wondering exactly what happened… Well it happened that supermarket shopping on Friday evening is always nefarious. Everyone, his friends and his brothers are there to shop for the weekend. People with no other goal than staring absent mindedly to shelves while keeping their cart across the corridors. Crowds of long unseen old friends clustering together (and usually complaining about people stopping in the market or about new generations without good manners). This time it had been a bit worse, because someone took our cart at about one third of the process and we had to restart from the beginning.
Then on Saturday it was the Shoes-Day, I spent the whole day with my wife in and out from shoe-shops and outlets in Parabiago. We also succeed in smashing another car door, fortunately no injuries for anyone and not much damage for our car (anyway our insurance fee will raise). We started about at 9:00 and we got back home after 20:00.
On Easter and Monday we paid the belonging to our families.
During this holidays evenings we tried to figure out the best accommodation in Las Vegas for this Summer U.S. travel. When traveling to Norway, two years ago, we found very helpful the website to make hotel reservations in Germany. Unfortunately there isn’t anything so complete for U.S. and we are browsing through endless lists of hotels, motels logdes, bed and breakfasts, inns and so on. At last (after three evenings of hard search and comparison) we found a Travelodge on the strip, close to Bellaggio, at a convenient price.

Programming in Lua

(cover to the left here, refers to 4th edition of the book, I read the 1st edition). It is somewhat difficult, in writing this review, to distinguish the language from the book. The book teaches about Lua, so my opinions in favor or against this language could interfere with my opinions about the book. Anyway I’ll try to accomplish this hard task.When writing a book about a programming language you could follow either an hands-on approach or a more formal one. Both ways have their pros and cons. The first approach helps language novices to grasp quickly language fundamentals, while latter provide a convenient reference for those already using the language.
For example Bjarne Stroustrup’s “The C++ Language” belongs to the second set. It is very formal and descriptive; learning the language by this book it is definitely the hard way to do that (aside from the fact that C++ is a very complex and huge language). “Programming in Lua” is from the first camp. It features an easy to follow, example-ridden way into the language. It doesn’t pretend to give a thorough reference for the language or the library, demanding other books for this specific purpose.
I have to say that the writer does quite a good job. The text reads smoothly, examples are always fit to the chapter scope, prose is clean and clear. In theory I should have practiced with the language itself in order to state whether the book covers the matter adequately or not, but I have a limited amount of free time and no suitable project for a Lua application, not even a toy one.

Anyway while I didn’t fell in love with the language (quite the opposite as you may have read) I appreciated the book. Also I found an interesting reading the last chapters on how interfacing and extending lua with C code.
What I didn’t like is the author bias toward the language; I feel a vein of naivety. For example Lua supports only floating point values. Not the “float” kind, but the “double” variety. No integers, just doubles. The author advocates that there is no reason for integers since “double” works fine for just everything. Although I have not much experience with doubles (just floats), this appears quite a bold statement, at least from what I have skimmed through. The dumbest consideration I could think of is that doubles still have the usual precision problems that affect floating point arithmetic. It just depends on how many iterations you have to do.
On a whole I found this book a worth reading either if you want to learn a new programming language or you are just curious (like me). Just be sure to buy the 2nd edition that came out just few days after I ordered the book (I ordered the book few days after having read the, now disappeared, slashdot review… maybe you see a connection)… or to read the first one online for free.

Antipatterns at work

It is an odd sensation. I am puzzled about some decisions that are quite unanimously recognized in literature as bad, or, if you prefer the buzzword, as anti-patterns. Forests have been sacrificed for books on the matter. Given the current (poor) state of the planet I would urge management to read them, not just having them to preserving their libraries from dust.
You have this project late, the customer is coming screaming at you because you didn’t made it for the milestone, the product is still alpha quality when it ought be on the shelves. Sounds familiar? If not either you don’t work in any technologically advanced sector or you have been unbelievably lucky (or good… or both). So it is clear that the project needs extra time to achieve the goal set. I understand that there are contracts and politics involved, but for the sake of the project there is just to plan and move the milestone ahead WITHOUT adding new features. Leave them for another project. The customer could be disappointed from this refusal but she will be a lot more disappointed when you’ll told her that you didn’t made it another time.
Disclaimer: I have to be honest, this is not my project, I don’t know exactly what has been agreed on, the only thing I know is what a coworker told me in about a single line: milestone postponed, new features added. So basically I don’t know what I’m speaking of.

Copying

No, I haven’t forget my last post. I had a look at Engineering without Frontiers, a no-profit NGO, which should be the engineer answer to medical initiatives like Medecins Sans Frontieres. Although their magazine is interesting, and their statute is agreeable, I find the overall association a bit loose, somewhat too tied in the academic world and too abstract. Apparently the prompt answer to the question “How can I help?” is just “Send money here”. Maybe I have to dig further.The topic of the day is copying. When talking about this issue, I usually agree with content owners that deplore the act of copying for money and for personal use. My favourite example is that if you like a Ferrari, you don’t steal it only because you cannot afford it. The same goes for music, movies, software and so on. There are people who worked to create that content and it is their right to be paid for their work.
I could agree on some special cases such as when you are looking for something that’s not available or even out of print. But this should represent the exception, not the rule.
Sometimes ago I skimmed through Carlo Gubitosa’s Praise of Piracy, without being convinced at all about the point of the right to copy.
Although, during these days, I’ve been hit by a sort of revelation. There’s actually a practice of legally accessing content, without paying for it. More, you could actually access content any time you want with no restrictions. And this practice has been available for centuries to human kind… public libraries the name.
Some public library lends VHS/DVD movies, maybe this practice is discourages by video rental business. But from my point of view, what’s the difference in borrowing a book from the public library or downloading it via eMule?
From one side I think it is worth noticing that the book industry is not suffering from the free availability of books in public library. It may suffer from the fact that people read less and less, but not from the fact that I could chose to borrow a book rather than buying it.
From the other side I wonder how could it be legal? 🙂 After all if everyone would go to the library, then no one would buy the book and the writer would be starving. Would it be enough for the authors to receive the payment just from public libraries? In that case authors could be payed directly from our taxes cutting the public library service costs, the media costs, by letting everyone access everything online.

African Roses

I would like to write about the Hungarian notation, the good (not much) and the bad (quite a lot) of this source coding convention, but I really can’t. This matter sounds quite silly and irrelevant. My mind is still full of the images and the implications of the documentary I watched Saturday evening on La7. The title is “Rose d’Africa” (African Roses) and the author is Daniela Grandi. Unfortunately I cannot find the video on youtube nor google video, neither a summary on La7 website.
Well, what impressed me so much? The documentary brings hard evidence about the deep injustice affecting the African continent. An injustice that European and American corporations are feeding actively.
In Africa people actually die of starvation, sadly no news, but they are prevented from exploiting their fertile lands (such as near Tana River) because these lands are planted with roses (and other flowers) greenhouses. Flowers are grown and then sent to Netherlands for world distribution. Inhabitants, mostly women, are exploited in the greenhouses under terrible working conditions. The wages are incredibly low (basically we could pay for a pizza and a beer what they earn in a month), while they have basically no right. If they got pregnant, they work until the last day and then are fired. They are requested to enter the greenhouses just a while after the chemicals have been sprayed on the cultivations.
Moreover the remaining chemicals are dumped in the river, poisoning and polluting the environment.
Just outside of Nairobi (the Kenya capital) there is a huge slum where 2 millions of people live from what they can find in a nearby giant dump. That’s two millions! The slum has no sewers, no electricity and no water. The air is polluted by the dioxin coming from the dump.
All this is heartbreaking for me, deeply saddening, I can’t stand the idea of such suffering and waste. And I’m asking myself what can I do for helping…

The Good, the Bad and the Ugly

Engineers are supposed to deal with systems, usually large and complex devices that are expected to work. They are expected to work at least, but the common expectation is that they keep working reliably under a wide set of circumstances and mostly regardless of the environment. Consider any system that results from an engineering process (say a TV set or a car) from this point of view – it is not enough that the device works fine only at the seller’s location. This should put under the right light one of the most used programmer defenses: “It works on my PC”.

For us, as programmers and programming team leaders, the point of concern is how to deliver such robust products that could reliably work even in non-clean room conditions. A lot of entropy has been sacrificed to this goal and I don’t want to start anything new or propose any existing process methodology, I’d just like to recall what a friend of mine reported from one of his senior coworkers (thanks Xté).

This is a quick analysis that allows you to understand how much in good shape your project (or task) is.
Consider two nearly binary variables – working and understanding. You can get four combinations that identify four states of the system composed of the object the engineer is working on and the engineer itself. Here we go to analyze the four states (I swear, I’ll be brief).

It doesn’t work and you don’t know why. This is the typical state of the project start, you have this black box not working as expected and you are supposed to fix or implement it. This is not so bad if you have enough time to study, ask other people, analyze, and get your knowledge on what you need to do to fix it. Summing it up, this can be fair or bad according to the time you have.

It doesn’t work and you know why. This is quite good. After all, knowledge is power. With the knowledge you can both devise strategies and solutions and figure out the time or the means you need. Moreover, you have plenty of facts to explain the situation to the management and ask for the most suitable resources you need to accomplish the task.

It works and you know why. Perfect, you achieved your goal. You fully understand your system, and why is it working so that you can predict to a good extent when and how it is going to work.

It works, but you don’t know why. This is the worst case of all. Unfortunately, the rush and the wrong assumption that if it works then who cares, can lead to this terrible situation. The real problem here is that you cannot make any assumption for when the system will cease to work, you have no clue how to deal with it both to repair, move, or change. You have no warrant that the system will continue to work.
The fact that it works usually leads the project management to consider it complete and to make pressure to move on. A false sense of security may affect the team cleaning the way for greater disasters.

There are some quick corollaries to this analysis. First, always try to understand what are you doing even if it may seem like a waste of time. Second, always include a learning time in your estimations. Third, poking randomly around to fix things is a dangerous way to further damage a system while creating the illusion of work.

Programmers strongly rely on tools, basically, there is direct contact with the matter we design and develop, our tools are our manipulators and probes into the hidden work of electrons. We have to know our tools by heart. We cannot go away with a rough understanding of the language we use because we cannot afford our ignorance would let something in.

The natural question that could arise is: “What is the extent required for the knowledge?”. Does programming require me to understand OS internals? Digital electronics? Semiconductor physics?

Well, it depends. Gone are the times when a single man could brace the whole human knowledge and art in his lifespan. Nowadays we have to stop at a given interface, taking for granted that what is going on behind us is good enough. I think that you have at least a good knowledge of the first interface you are using, be it OS system calls, environment libraries, or hardware if you are working closer to the metal. Anyway, an average knowledge up to the next barrier could only be good when you are hunting for problems since it could help you to better exploit the environment and to get helpful hints to get you out of trouble… troubles where engineers spend most of their time.

Mercenary!

I was on the train, fighting against that locust general, trying to reach the solar bomb to get rid of all his vicious breed…Well I did it… at least virtually. I completed Gears of War, game of the Year, winner of several prizes and mentions, and got the status of “Mercenary”. So long, so good. Having played the never-ending Serious Sam (I and II) I expected the game to be somewhat longer, but apparently gone are the times when a game lasted for tens of hours… or maybe I’m getting too good at playing. Unlikely, I would say.
In this game you play Marcus Phoenix that begins his quest in a prison (Unreal, anyone?), freed by an old friend, stating that the army needs his help. And in fact any help is desperately needed – the world has been taken over by the Locusts, a cruel race of creatures resembling of reptiles, they savaged the cities so that the government decided to bomb everything (smart move, isn’t it?). Roughly you have the task of mapping the caves of the Locusts and then activating a “solar bomb” to destroy them all.

The game is a 3rd person shooter and one of the best yet seen. The graphics is gorgeous, really delivering a full immersion to the player, is movie-like quality and the suspension of disbelief is very easy. Classic realtime graphics defects (such as polygons cut by the camera plane, textures revealing their pixel based nature, squared objects) are basically non-existent. For this reason and the abundance of gore, this title is really not suitable for kids.
The only dissatisfying aspect is that bulk objects (such as the choppers) are apparently without mass, their movements is not as smooth and … inertial as they should be. The best bulk “mass” simulation in videogame remains Halo 2.
The camera (aside from never ever letting you down), sports an involving war-footage style.
The game play is slightly innovative, and it is quite difficult given that the genre counts tons of titles. New is the need for the player to look for a cover in a firefight, you have to plan your moves quite accurately if you don’t want to be blown off.
You can carry two weapons. Aside from grenades, there is a basic set of weaponry – the standard machine gun (with a chainsaw), a sniper rifle, a bow with explosive darts, a rocket launcher and a shotgun. You have a non-standard “Hammer of Dawn” which is a targeting device for calling satellite beam attack on your enemies. The satellite attack takes quite a long time for aiming and works only outdoor with clear sky (and satellite coverage).
You have a team, usually just another guy the fight at your side. His AI is pretty brilliant – he usually don’t get into your line of fire and doesn’t stops you from moving around (or worst blocking while you are retreating, as it happened in HalfLife 2). In the beginning of the game he usually hints you for the direction where the game proceed. The game is never too difficult on the brain side, the most difficult puzzle you have to solve is find the switch aside of the door you want to open, nor you risk of getting lost – maps are pretty big, but the path is so marked you have no chance to get it wrong.
The only downside with the gameplay is that occasionally the “take cover action” interferes with the movement, or the crouched-run that you try to save your life. Just occasionally annoying. Also, if you are picky enough you could note some bugs here and there, such as enemy boss that slams into invisible barriers, or the multipurpose floating robot Jack that appears out of thin air. The worst bug I encountered was against a boss, I was expected to attract the boss on a carriage with a gasoline tank, then leaving the cart and throwing a grenade to let the carriage explode with its annoying passenger. Unfortunately the split second I throw the grenade the boss jumped on my wagon, causing the trap to explode and leaving me without any weapon to get him off.
But these are just minor quirks for a great game I really enjoyed.

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”.