Month: February 2009

Tre cose che mi hanno colpito

Di tutto quello di cui abbiamo parlato ieri nell’incontro al CIAI, tre cose in particolare mi hanno colpito. In realtà le cose che mi hanno colpito sono molte di più e alcune hanno colpito anche duramente, ma poche hanno la sintesi di queste che sto per scrivere. La prima cosa è che il rapporto genitore-figlio è l’unico tipo di rapporto che funziona bene quando è sbilanciato. In generale i rapporti tra amici, tra fidanzati, tra marito e moglie, tra colleghi, funzionano bene e a lungo quando sono bilanciati, quando si instaura uno scambio equo nei due sensi.
Il rapporto tra genitore e figlio è invece sbilanciato – sarebbe come dire che la nuova generazione ha credito illimitato nei confronti della precedente.
Vista da una diversa prospettiva il momento di chiedere è quando si è bambini, il momento di dare è quando si è adulti…
La seconda idea che mi ha colpito è, un po’ la traslitterazione della poesia che paragona i figli alle frecce e i genitori all’arco di Khalil Gibran . Cioè che lo scopo non è quello di tenere i figli, ma di farli andare, e loro possono andare solo se “fanno il pieno d’amore”. Se non sono amati abbastanza non riescono a staccarsi perchè… hanno ancora credito.
Infine, mi hanno colpito sono state queste (circa) testuali parole: “Si metta il cuore in pace, per i prossimi 15 anni, i suoi momenti di pace e di tranquillità saranno dalle 9:00 alle 18:00 dei giorni lavorativi”.

On The Edge

As far as it may seem odd nowadays, there was a time when BASIC was The Language. Computers from different vendors were 100% not-compatible and resources were so constrained that your average mobile phone could be considered a supercomputer when compared to. It was the Home Computer Era. Back then, it was the first half of the 80s, home computers started to spread around even in Italy. I was fourteen and started programming (and playing) with my ZX Spectrum 48k.
We hadn’t Windows or Linux, Vi or Emacs, Java or C#, but we had our religion wars – the most bloody, was Sinclair vs. Commodore and more precisely Spectrum vs. C64.
Owning a Spectrum I was in the Sinclair’s party – the gummy keyboard machine with a nice rainbow. Spectrum had superior BASIC and faster CPU. I like to think I always have an open mind, in fact, some years later, I was about to buy a C64. The Commodore machine sported for sure a superior hardware – more memory, more graphic modes, better audio, sprites, and decent keyboard.

I waited, then evaluated the C128, but bought an Amstrad. Some years later the Amiga arrived and I became a happy Commodore customer.
This book is like a documentary of the troubled history of Commodore. From the very early days, when the designer of the MOS 6502 CPU designed the first PET, to the final days of bankruptcy.
I found the book very good, more balanced of iWoz, maybe just because the writer is not directly involved in the company and just interviews people trying to rebuild facts.
The book reads nearly as a fiction book, with interesting characters, heroes, foes and plot twist, while the narration proceed toward the glooming end.
Two aspects stroke me during the reading – first is about success and failures, the latter is about overtime.
Many of the engineers interviewed hold that the most successful products were achieved when they were free from the marketing and worked almost free (but for the deadlines set directly by the CEO). The most unsuccessful products (notably the Plus 4 and C 16 abominations) were marketing driven. What really strikes me is how could the marketing and the middle management be so computer-unaware? They had a powerful brand, great hardware, yet they failed to steer the company helm to easily reachable success.
Overtime was a sort of way-of-life for Commodore engineers. Unrealistic deadlines were hit thanks to work around the clock for several days. One of the engineers recalls that his longest stay at office was 11 days. He just got some hour sleep in his office.
Unrealistic deadlines were needed to win against the strong competition from other vendors, but this is something you can’t live with for a reasonable time. You have to work less. I am a strong supporter of the 8h/day per 5days a week with just occasional overtime. My argumentation is that overtime tends to burn out people, making them behave in a sub-optimal way in the medium period. Also because of the long hours away from home they need to do something personal at work, just to keep up with life. So I wonder if those jewels (C64 and Amiga) that Commodore gave us could have existed and could have been the same with more human working conditions?

Simple I/O Messing Up

Basic I/O should be simple. I guess you agree. And I guess that’s way many C++ or Java programmers that look back to humble printf with some nostalgia. In fact it is hard to beat the conciseness and the clarity of something like:

printf("%03d", x );

When it comes to create formatted output C printf is usually one of the best tool available.
Unfortunately things are not so simple. One of the first limitations acknowledged for this little gem is that it lacks of robustness, or, put from a different perspective, it doesn’t type check.
What happens if ‘x’ in the above example is a float number? or a pointer? Or worst if the format string specifies a string pointer and an integer is passed?
This problem is mostly overcome in the GNU compiler via a custom extension that allows the compiler to check for consistency between format string and arguments.
The mechanism is enough flexible to be applied to user defined functions. Suppose you have a logging function that behaves like printf, something like

void log( LogLevel level, char const* message, ... );

That’s handy so you don’t have to perform string processing to build your message to log when you want just log. If you use Gcc and declare the function like:

void log( LogLevel level, char const* message, ... ) __attribute__((format(printf,2,3)));

Then the compiler will kindly check all the invocation of function log in your code to ensure that specifiers and arguments match.
So far so good, but enter C99. In the old days there was an integer type (int) with two available modifier (short and long). That was reflected in printf specifier/modifier: %d is for straightforward ints, %hd for shorts and %ld for longs.
And this is fine until you work on the same compiler and platform. If your code needs to be portable, then some complications are ready for you.
The last standard (C99) mandates a header, namely stdint.h, where a number of typedefs provide a wealth of integer types: grouped by size and by efficiency, you have (if I count correctly) some 30 types.
From one side this is jolly good since poses an end to the critics against C for not having an integer type with a declared bit size valid for all platforms (like Java has).
Unfortunately, on the other size printf is not able to autodetect types and thus you have to write a different format string whether your int32_t is defined as long int, or just int.
To leave the nightmare behind C99 mandates another header file – inttypes.h that provides the proper specifier for each one of those 30 integer types. For example, if you want to print an int32_t, you have to write:

printf( "here's an int32_t: %" PRId32 " and that's alln", x );

As you can see it relies on the C preprocessor that merges two consecutive strings into one.
That does the job, but, IMO some simplicity of the original idea is lost.

Bio / Ado + Family

In una famiglia biologica i figli assomigliano ai genitori e ne sono la loro prosecuzione genetica.
In una famiglia adottiva non c’è legame di sangue e spesso le differenze sono somatiche, etniche e di colore.
In una famiglia biologica non ci sono vuoti: tutti insieme, dalla nascita in poi.
In una famiglia adottiva la vita insieme, per i figli, comincia da un giorno che non è quello della nascita. I vuoti da colmare sono molti.

Una famiglia biologica nasce dall’incontro per amore di due persone, un uomo e una donna.
Una famiglia adottiva nasce dall’incontro di due persone, un uomo e una donna, e di questi con i loro figli, per amore.

Una famiglia biologica può formarsi per scelta responsabile di procreazione.
Una famiglia adottiva non si costituisce se non per una scelta responsabile dei genitori.

In una famiglia biologica i ruoli sono netti e definiti.
In una famiglia adottiva: chiariamoli insieme e inventiamoli giorno per giorno.

La cosa più ovvia in una famiglia biologica sono le radici.
La cosa più ovvia in una famiglia adottiva è l’accoglienza.

La cosa più difficile da dare ai figli, in una famiglia biologica, sono le ali.
La cosa più difficile da dare ai figli, in una famiglia adottiva, sono le radici.
Le ali, questi figli, le hanno già… è con queste che sono giunti a noi.

La cosa più necessaria, in una famiglia biologica, è l’amore.
La cosa più necessaria, in una famiglia adottiva, è l’amore.

Due donne

C’erano due donne che non si erano mai conosciute
una non la ricordi
l’altra la chiami mamma.
La prima ti ha dato la vita
la seconda ti ha insegnato a viverla.
La prima ti ha creato il bisogno d’amore
la seconda era lì per soddisfarlo.
Una ti ha dato la nazionalità
l’altra il nome.
Una il seme della crescita
l’altra uno scopo.
Una ti ha creato emozioni
l’altra ha calmato le tue paure.
Una ha visto il tuo primo sorriso
l’altra ha asciugato le tue lacrime.
Una ti ha lasciato,
era tutto quello che poteva fare.
L’altra pregava per un bambino
e il Signore l’ha condotta a te.
E ora mi chiedi la perenne domanda:
eredità o ambiente,
da chi sono plasmato?
Da nessuno dei due.
Solo da due diversi amori.
(Madre Teresa di Calcutta – trovato su In Attesa)

Time doesn’t Age the Soul of the Dreamer

I found this though somewhat inspiring…
(English follows)
La vita non è fatta per guardare indietro la strada percorsa, ma per sognare la strada ancora da fare. Non chiederti chi sei davanti allo specchio, non avrai risposta alcuna, semmai guardati dentro e scoprirai di non essere cambiato mai. Il tempo non invecchia l’anima di chi sogna.
(Giovanni Di Battista)

In English, it may sound something like:
“Life is not intended for looking backward to the road you went through, life is intended for dreaming the road ahead. Don’t ask who you are in front of a mirror – you won’t have any answer, rather look into yourself and you will find you never changed. Time doesn’t age the soul of the dreamer.”

(or maybe it’s just me getting old and liking suggestions that I’m not).