Month: July 2006

The Riddles of Epsilon

It happens quite often – I go to the local mall bookstore, get intrigued by some book, resist the insane temptation to buy it immediately; get back after a while when my reading queue is somewhat lighter and find that the book has vanished.I can no longer find “Tokyo soup” and a book about biggest lies… and many other I don’t remember right now.
So it was for this book. I found it intriguing, rich in mysteries, but then it disappeared. After about a month I found it relocated in the teen-books section. My reading queue was still fat and I resisted once more. And the book disappeared again.
At last my wife gave me that book on July 14th (“Do you know what day is today?”, “ehm, well, … “, “Joke’s day! This is for you!”). So, jumping over the full reading queue I started reading it the very same day and completed the reading in just three days… addicting!

The story is set on the fictional island of Lume, where Jess, the twelve years old main character, and her family just relocated. They arrived in the family cottage, an old building full of old rooms.
In the family past some troubles among the parents, and other, rather ordinary, trouble in Jess’ friendship. Back to the origin is going to do good for the family.
When Jess finds a stranger in the private chat-room where she’s talking with her friend, at first she thinks of some hacker, This mysterious being, which then turns out to be a man named Epsilon, will pull Jess, riddle after riddle, into an epic battle between Good and Evil.
For Jess it will be even more dramatic because she can’t tell which part is the Good part. She will meet odd strangers and will see unusual buildings, and will find herself going after the very same story of a boy from the previous century.
I found the story really good. Just in a few points could be somewhat childish, after all this is a teen oriented book. But the light-horror movie sense is preserved throughout the book. Also the atmosphere of the lone island, where the community knows about something you don’t, where customs have been tailored around unnatural things.
I am not sure that there is an explication for all the riddle posed by Epsilon and or for their need. Nonetheless I’m ready to forgive this because they are so well integrated in the story that you don’t feel any artificiality in them.
Very recommended.


As a general rule, I could agree on the principle that complicated things should be masked away from the user behind a simple and intuitive interface. Well maybe more than just agree. Even if the user could manage to get that complication working, she could easily to make an error, or be endangered. A clean and crisp interface is advisable.What is just irritating is when something with a clear and simple model is hidden behind a smoky interface with a different model.
I am talking about Palm synchronization. I think that the idea of synchronizing is for people who don’t want to know what a ‘file’ is. And, yes, what the heck, if you have two databases (such as the contact list) you actually want to ‘synchronize’ them, copying records back and forth until everything looks the same (and hopefully nothing gets lost in the process).
But if you have a word processor document you just want to copy it from the PDA to the PC or vice-versa. It *IS* a file. So the abstraction is that of two file containers (directories? drives?) that you want to operate on. The USB mass storage dongle abstraction – hook it up to the PC and you get a drive, drag and drop files to this drive, unplug and be happy.
Moreover the synchronization of the whole system has some dark points – what is supposed to the synchronization mechanism if you remove a file from one of the two synchronizing devices? Propagate the deletion to the other system? Ask for user intervention? Undo the deletion with the other copy?
What if the same document is available in the two system but it is modified in both systems?
Not to talk about Linux that does the synchronization its way – the SD card is not synchronize neither the sub-directories are.
So I really don’t understand why Palm is so stuck to the synchronization abstraction. It’s handy in the real simple scenario, but it sucks elsewhere.

Selected power

It is alway a good surprise when a task you thought being rather hard turns out to be quite easy when you actually do it. Using select for I/O multiplexing and stuff like this is one of those pleasant surprise. The man page could be quite intimidating, therefore I start with an example. Suppose you are dealing with network communication (or any other form of interaction where an I/O operation could take too long to be correct). You are likely to read (or write) into a file descriptor (previously opened via socket and then bound in some way) AND to check for a timeout. If the operation is taking too long, you want to bail out of the read operation and perform the needed action.If you are stuck with standard read and timer operations you may need to set up some signaling check for the right thread to catch them and so on. But there is a better way.
Select accepts several arguments: a limit, three sets of file descriptors and a timeout, and returns as soon as one of the conditions (defined by arguments) is met. The file descriptor sets are defined via fd_set type (handled with fellow macros FD_SET, FD_ISSET, FD_ZERO and FD_CLR). All these arguments can either be NULL or point to a fd_set. The first one is the set of file descriptors checked for non blocking read. That is that if one of the file descriptors contained in this sets become ready to be read without blocking the caller, then select returns. The next argument is for writable file descriptors and the third one is filedescriptors that have to be checked for errors (exceptions).
The first argument is the maximum filedescriptor contained in the union of the three sets plus one. This serves as a limit to avoid checking the whole range of file descriptor.
The last argument is a timeout. It is a struct timeval (the same filled in by gettimeofday) that can define timeouts with a microsecond resolution. In practice the resolution is much less fine grained than that and depends on the kernel and the architecture. For example on Linux kernel 2.4 on ARM the resolution is 10ms. Better check the smallest handled timeout before blindly relying on it.
Select returns -1 in case of error, 0 in case of timeout or the number of the filedescriptors that changed status in the three sets.
For the example the return code is easily processed, while for more convoluted cases could be more complex.
Let’s take another example, suppose you are reading audio packets from a stream and you want to decode and playback them. The first approach to this problem could be using two threads with a coupling buffer. One thread reads packets and pushes them into the buffer and the other thread pops the packets out of the buffer and sends them to the audio driver. This is conceptually simple, but not straightforward to do in the right way. When dealing with threading you always have to synchronize them. It is likely that you need a third thread to control the streamer and the player threads.
If you employ select the solution is very simple and natural. Just check the wall clock and compute a timeout for the next play, then wait with select either for a new incoming packet or the time to play.
In this case there is just one thread and the warrant that if you are reading the buffer no one is writing in it. This allows you to simplify the buffer management.
If you are not so lucky to work with Linux, but your daunting task is to earn a living with Windows the good news is that a similar function is available for Microsoft platforms.

So Long and Thanks for All the Oil

Everyone knows it, soon or later we’re doomed to run out of oil. The question is just when this is due to happen. I remember when I was a child, back in the seventies, when first oil crisis arose, then awareness that oil was a finite resource started to be shared by most. Time passed and, apart from a constant rise in the gasoline price, nothing happened.
Yesterday I was at the local mall bookstore and found a book about this. Curious as I am I couldn’t resist to a (not so quick) glance through the text.
Unfortunately I don’t remember the title, nor the author; he is a geologist who worked for many oil corporations, so he should know his stuff.
The most alarming thing I read is that we’ve consumed about half the oil available on Earth. Within ten years we’ll reach the production peak and then oil will be scarcer and scarcer. Considering that beside western countries, with an ever growing energy need, we have emerging countries like China and India that are… emerging, the end of the oil era could be really soon now. Think twice before buying a new car.
What is going to happen to us? How this will impact on our lifestyle?
Our economy is strongly based on oil, so economic problems will cause an increase in poverty and stagnation.
We need something that could replace oil really fast. Unfortunately Hydrogen is not the answer, for the simple reason that we cannot mine it, despite being the most common element in Universe (beside stupidity, they say). To produce a liter of Hydrogen from water we need more energy than what the same liter could give back when employed. Nonetheless Hydrogen could be good to “store” energy for vehicles, as long as we keep ignoring its high explosive potential.
What about nuclear power? In the fifties it was the panacea – everyone and his brother expected to have an atomic powered vacuum cleaner in a matter of years.
I am not an expert, but from what I read if the current energy demand had to be satisfied just by nuclear fission, the nuclear fuel on Earth would last just 3 years. While debries would stay with us for thousands.
Maybe nuclear fusion is better, but not everyone agrees. Those that don’t think fusion is the answer are not just a bunch of green, environmentalist, hippies, but respectable scientist are among them. One for all, Nobel prize Rubbia.
So what’s the answer? Apart from renewable sources like wind and tides, an interesting source of fuels could come from vegetables – soy and rape could be converted in bio-diesel fuel and alcohol produced from fermentation is another good fuel. Maybe not so efficient like gasoline and diesel, but we won’t have the choice.

Rainbow spectrum

You know you’re old when you’d like to start today blog entry with something like: “There was a time when 1k was your roof. Everything, well packed, had to fit in this size. When the ZX Spectrum arrived with the full glory of its 16k in the budget model and astonishing 48k in the advanced model, it was really a quantum leap.” I tried to avoid all this gone golden age crap even if those times were really great and exciting. As most geeks of my generation I learned computing the hard way on a Spectrum, then it came the Amiga, but it was the next quantum leap.
So, aside of meeting some old friends, I was quite intrigued when I heard about the retrocomputing fair held last week end in Varese.
The fair was small, just two crowded rooms, filled mainly with Spectrum derivatives and other Sir Sinclair creations. Being there with my wife I started searching the original Spectrum, the one with the blue gum-looking key buttons. This proved to be quite hard, there was just one (empty) case, at the end of the first room.
Looking at the device, after my explanation of what and why, my wife asked: “But, why computers were so small then and now are so large?”.
Look at the Speccy, it is maybe 25cm by 15cm (more likely some round number expressed in inches), all included but the power supply and the mass storage. Now look at your nearest PC, it is huge compared.
That’s damn a good question. If you think at it, it is not the mass storage – a 1Gb smart digital card is smaller than your thumb, my Palm Tungsten is smaller than the Spectrum and has 64Mbyte of RAM and a 400Mhz CPU. Therefore I’m sure we can build unbelievably powerful computer the size of the Spectrum, saving lot of space in our houses. So why?
I think it is just the way taken by the evolution. Our modern PCs are descendant from the first IBM PC which in turn was inspired by the Apple II. Both were large boxes, filled with empty space in order for people to spend their money filling them in. Adding memory, I/O, storage, and so on. So today you buy a PC that’s based on the same philosophy, even if just a small fraction of buyers will change anything inside, you can add memory, change your video card or upgrade your CPU.
Home computers, luckily, didn’t disappear, they left they legacy to game consoles. In fact, it is here that you find the same strive for compactness (look at the slim PS2!), the same standardization in the hardware, the same fast boot time… they even connect to the TV set like 20 years ago!
What is missing from the current generation of video game console is the chance for everyone to program them. I mean to legally programming them, allowed by their manufacturers. Actually console manufacturers fear the piracy that could arise from letting everyone program their hardware. The PSP case is emblematic. You can do your own PSP home-brew development by downgrading the firmware to v1.0. This is easily achieved on v1.5, somewhat achievable on later releases of the software. Anyway every time you do this you risk to turn your precious handheld into an useless brick. Sony, rather than finding a constructive way to deal with the hobbyist community, choose the destructive path of having all the retail games and demo that update the firmware to the latest version, basically having everyone to chose between having only home-brew (or pirated) software or only original software.
This will go on until someone will make an hardware modchip that will allow users to have both a development firmware and the original one. It is just a matter of time, it is a lost battle for Sony.
I acknowledge that the business model of nowadays console manufacturer is pretty different from the old home computer manufacturers, but I wonder what could happen if the same effort gone into preventing users to run their software on their hardware would have gone into creating constructive ways for discouraging piracy while empowering the home-brew community.

Raiding tombs … again

The first Tomb Raider shook the videogame world, but I was on another world – no PS1 and not playing any videogames (sort of Max dark-age). So overbreasted Miss Videogame just marginally hit my interest. Then it came a time when I started playing on PC and I got a bonus copy of “Tomb Raider III”. I started playing it with my wife… Lara’s moves were rather clumsy, puzzles not always so intuitive and micrometric precision was required for jumps. All these factors and an overall technical obsolescence let me lose my interest around the 3rd map. The second encounter in tombs came for work reason. I was chosen to be the lead programmer for Tomb Rider – The Prophecy the GameBoy Advance Game. The idea of working with this subject was really amazing, unfortunately the project was on a such aggressive schedule that it bit. 3 months to modify engine and implement the game, while another game was ongoing.
At last I played through all the game and I enjoyed it. Despite some repetitiveness caused by the shrunk time.
Fast forward about one month ago. I had a buying impulse I couldn’t repress, so I was choosing among a bunch of XBox titles, and Lara blinked her eye from the cover. I had read some positive review so it could have been a good choice. So I get out of the shop with my brand new copy of “Tomb Raider – Legends”
The game is nonetheless good. From the technical point of view is quite strong, even if you would expect a better implementation of the character shadow. I think it is better to have no shadow rather than a wrong one, it just breaks the suspension of disbelief.
Puzzles are quite easy (I got stuck just once), the jumping, grasping is quite forgiving and often delivers a good cool-factor.
Scenarios are intriguing and the story, at least from what I have heard, should be entertaining. In fact the dialogs among characters were unbelievably soft, I barely could hear. I don’t know if it is just my TV set becoming too old, or the Italian translation that had some problem.
Beware of the spoil
What is disappointing to me is that the game is very short, I spent about 10 hours and that means that a good player could get through in half the time. No comparison with the endless Serious Sam I played before.
The other really disappointing part is that there is no ending. Just defeat the last boss and you get some hints that the story is not over that there is still something to do (don’t ask me what I couldn’t hear) and … credits.
It is even worse than Halo 2. At least with Halo the ending offers a good satisfaction to the player, the story is not over, but this chapter is well closed.
It seems much like the developers ran out of money or time and were forced to put an end and shipping as the game was.
Anyone interested in a second hand copy? 🙂 Well, it’s not that bad, I would rate it 6.5/10, for sure I don’t want to replay it, there’s no sense in playing it again just for searching all the hidden objects (3-4 per map) that just allows you to see new dresses for Lara or weapon power-up.

Cooking eggs

Ok, I have to admit it – they tricked me. Maybe I’m becoming old… There was this picture of an egg between two mobile phones. The text: “Set the two mobiles to call each other and after an hour or so you’ll find that the egg is cooked.” (For a more convoluted story in italian or another one in english). Now there should have been some warning signals. I mean, I know that the maximum emission of RF-energy from a mobile phone is from its back, so that it won’t waste energy into your brain, but in the opposite direction which is more promising for being obstacle free. Also, the GSM frequencies are not the same of your microwave oven. And microwave oven frequencies are tuned to have the best warming effect on the water molecule in foods. Alas, believing that something so simple and dramatic at the same time could reveal the real danger of pervasive wireless communications was too tempting.
The hoax is easily spot if you could do some math. I should have done it first, before blindly believing.
Talking about believing, I found this site (in Italian) that is plenty of food for thoughts, just be careful of not eat too much. Avoid it if you are sensitive on religious topics.
The link of the day is the Linux revenge for my rants against it. If you have Windows XP then you may have tried to search a bunch of file for a specific word. If files are recognized by Windows then there is no problem, but if files are not recognized (maybe just an unknown extension) then you won’t find anything. To “fix” this behavior is really simple, just twiddle bits in the registry. Enjoy!