Archive for February, 2007

Useless fuss about ZIP and RAR

Feb 24 2007 Published by Salvatore Iovene under Software

There has been some fuss gen­er­ated by Jeff Atwood (who is a Win­dows devel­oper, which is bad, and a Visual Basic one, which is worse), who seems, in my hum­ble opin­ion, to be giv­ing par­tial infor­ma­tion around, as closed in his Windows-only world as he appears to be. In a recent arti­cle of his, Jeff makes a basic com­par­i­son between the ZIP and RAR com­pres­sion sys­tems. Unfor­tu­nately, most Win­dows peo­ple com­pletely ignore that there’s some­thing much bet­ter out there, that has been float­ing in the *nix world for quite a long time now. I’m talk­ing about the pow­er­ful com­bi­na­tion of tar and bzip2.

Let’s get to the facts right away. To exper­i­ment around, I’ve used a direc­tory con­tain­ing the source code of the Linux ker­nel, then I built that ker­nel, so that the size of the direc­tory would be pretty big, and we would have both text files and binary files.

Here’s the size of the orig­i­nal directory:

$ du -sh /usr/src/linux-2.6.18.3
539M    linux-2.6.18.3

This is what hap­pens with ZIP:

$ time zip -r ~/linux /usr/src/linux-2.6.18.3
...
real    2m35.917s
user    0m32.486s
sys     0m6.024s

$ ls -gGh ~/linux.zip
-rw-r--r-- 1 141M 2007-02-24 01:04 /home/siovene/linux.zip

Fine, 141Mb in 2 min­utes and 35 sec­onds. Let’s try RAR:

$ time ./rar_static a ~/linux.rar /usr/src/linux-2.6.18.3
...
real    5m8.715s
user    2m14.012s
sys     0m12.473s

$ ls -gGh ~/linux.rar -lh
-rw-r--r-- 1 132M 2007-02-24 01:26 /home/siovene/linux.rar

Ouch! Dou­ble time and just a slightly bet­ter com­pres­sion! Let’s try TAR and BZIP2:

$ time tar cv linux-2.6.18.3 | bzip2 > ~/linux.tar.bz2
...
real    4m22.265s
user    2m38.134s
sys     0m5.608s

$ ls -gGh ~/linux.tar.bz2
-rw-r--r-- 1 90M 2007-02-24 01:09 /home/siovene/linux.tar.bz2

Not too faster than RAR (but using two pro­grams com­mu­ni­cat­ing through a pipe, so some over­head), but much more effi­cient! The com­pressed file is only 90Mb start­ing from an orig­i­nal uncom­pressed of 539Mb

Let’s sum­ma­rize the data:

Method        Time        Size
zip           2m35s       141Mb
rar           5m08s       132Mb
tar.bz2       4m22s       90Mb

In con­clu­sion, you should use the best tools, inter­de­pen­dently from their pop­u­lar­ity, and remem­ber that there is so much more than what you can see from your Windows-user-perspective.

10 responses so far

Architecture of patching semantic versus logical content

Feb 19 2007 Published by Salvatore Iovene under Software

Inspired by a cer­tain patch that hit a darcs repos­i­tory to which I con­cur, I would like to talk about one thing that devel­op­ers don’t seem to get very often, when using revi­sion con­trol sys­tems: the struc­ture of your files in the repos­i­tory should have noth­ing to do with the log­i­cal units that make your patches, or with the com­ment of your patches them­selves.

Yes­ter­day, I saw this patch hit the repos­i­tory: “Adding Cloth.h to the repo”. The patch was adding an empty file, named Cloth.h. What’s wrong with this? A cou­ple of things:

  1. The patch adds no log­i­cal value unit to the repos­i­tory, but merely a tech­ni­cal value, i.e. an infor­ma­tion about the con­tent of the repos­i­tory itself, which is, then, absolutely redun­dant, as you could retrieve that infor­ma­tion in a sep­a­rate (and more proper way), which of course depends on the revi­sion con­trol sys­tem you are using. Indeed it was just a tech­ni­cal infor­ma­tion. Fur­ther­more, the fact that the file was added, would have been there and obvi­ous also with­out hav­ing to ded­i­cate a sin­gle patch to it.
  2. The com­ment (“Adding Cloth.h to the repo”), once again, doesn’t make any log­i­cal sense of its own, as adds an infor­ma­tion that was already avail­able using the revi­sion con­trol sys­tem tools.

What is a bet­ter way to do that? A patch named “Pre­lim­i­nary sup­port to clothes”, which would add the file Cloth.h with its con­tent, even if not yet func­tional, makes per­fect sense. It means that you’re adding some log­i­cal value to the repos­i­tory, and the value that you’re adding has noth­ing to do with the way that value is rep­re­sented (the file Cloth.h), or that it’s being actu­ally added to a repository.

In other words, the form and con­tent of patches should not only rep­re­sent sin­gle units of implicit log­i­cal value, as dis­cussed ear­lier, but should have no aware­ness what­so­ever of being part of a revi­sion con­trol sys­tem, or being uploaded to repos­i­to­ries, con­tains file, or even being patches at all!

Read more ver­sion­ing tips here.

No responses yet

On the day I go to work for Microsoft

Feb 18 2007 Published by Salvatore Iovene under Software

” On the day I go to work for Microsoft, faint oink­ing sounds will be heard from far over­head, the moon will not merely turn blue but develop polka­dots, and hell will freeze over so solid the brim­stone will go superconductive. ”

by Eric S. Raymond

No responses yet

Please stop talking about iPhone clones

Feb 13 2007 Published by Salvatore Iovene under Software

I can read, basi­cally every other day, some web­site going nuts about some iPhone clone. Just few min­utes ago I read about the nVidia GoForce 6100, and googling for “iPhone clone” really con­firms the fuss. Well, the truth is that the iPhone actu­ally is the one com­ing late, pos­si­bly the cloner, rather than the cloned.

I’m not work­ing at Apple Inc., but, being a soft­ware devel­oper and hap­pen­ing to have also worked for a while in the devel­op­ment process of a high tech device, I know, as many oth­ers, that the process that leads to the birth of a com­pli­cated gad­get like the iPhone, takes years.

Digg.com has gone com­pletely crazy about the sub­ject. A Google Search about that sub­ject on Digg, returns 5520 results.

Given that Apple Inc. will release the iPhone only next Fall, and that there are many devices already out there, which have been yelled at as mere “clones” (absolutely dis­re­spect­fully, IMHO), how can you peo­ple abuse the term so much? I’m assum­ing that noth­ing really seri­ous leaked from Apple, so the com­peti­tors didn’t just rush to make their own touch screen phones. The truth is that the tech­nol­ogy started to be ready, and the mar­ket started to be ready too, at the same time. Some peo­ple missed the oppor­tu­nity and couldn’t even accept it, some other real­ized the chance and went for it.

I hope that the abuse of the word “clone” will cease to exist, and that, from now on, every­body will just talk about “another touch screen phone”.

Here’s a photo-list of alleged “iPhone clones” so far.

Samsung’s Ultra Smart F700 Asus Aura
Samsung's Ultra Smart F700 Asus Aura
Meizu M8 LG KE850
Meizu M8 LG KE850

No responses yet

Benefits of a weekend offline

Feb 13 2007 Published by Salvatore Iovene under Software

Last week­end I hap­pened to be com­pletely off the net­work. We some­how man­aged to for­get to pay a cou­ple of DSL bills (now set up to be paid auto­mat­i­cally), and the ISP “cut the wires”. Stay­ing off the Inter­net pro­vided loads of ben­e­fits. Let’s see.

  1. More time with the loved one. Of course I man­aged to spend more time with my loved one, cook together, watch a movie, just sit watch­ing the telly and talking.
  2. Health ben­e­fits. I felt over­all more relaxed, and my eyes felt much bet­ter. Espe­cially because the pre­vi­ous 2 weeks had been very intense, so my left eye had some red in it.
  3. More time to read. With no Inter­net, I spent a lot of time read­ing books that were wait­ing to be finished.
  4. More pro­duc­tiv­ity. This sounds crazy, but I did some cod­ing for a project of mine that didn’t really need net­work access (no need to check API online, no need to talk with a team mate, etc), and with­out dis­trac­tion I was able to do more cod­ing than the pre­vi­ous week.
  5. More time out­side. Not hav­ing much bet­ter to do, going to the shop to fetch food didn’t really feel like wasted time.
  6. More TV. Oh wait, this is not a ben­e­fit at all, is it?
  7. Less IRC. When I could con­nect to my run­ning GNU/Screen ses­sion which was hold­ing my IRC client in my office com­puter, I found out all the old mes­sages. And that I missed the chance to buy tick­ets for a gig I wanted to go to.
  8. Less Usenet. Do you think I cought up with all the threads? Of course I had to go for “mark all as read” and for­get it.
  9. Less RSS. My Google Reader had the infa­mous 100+ count of news… but I didn’t give up and man­aged to go through all of them.

What did I found out?
Well, noth­ing new, really. I already know I was addicted to IRC, RSS and USENET! But of course this break reminded me that I can do per­fectly fine without.

Con­clu­sion
I will prob­a­bly spend more week­ends off the net. Not.

No responses yet

Please drop SVN

Feb 08 2007 Published by Salvatore Iovene under Software

SVN might be sta­ble, it might be mature, it might be suc­cess­ful, and it might be the win­ning source con­trol sys­tem of the moment. There’s always a big risk of result­ing unpop­u­lar, when crit­i­ciz­ing some­thing that actu­ally did find its way to suc­cess, but I have to say that SVN sounds ter­ri­bly antique sometimes.

I have already given a brief intro­duc­tion to the Darcs source con­trol sys­tem, and I would like here to talk about a very strong point it’s got against SVN.

Just yes­ter­day, at work, I needed to com­mit cer­tain mod­i­fi­ca­tion to SVN. As I exam­ined the diff of my local copy with:

svn diff

I real­ized that one of the file also con­tained some other mod­i­fi­ca­tions that I didn’t want to com­mit. After using Darcs for sev­eral months, I was sud­denly hit by the shock­ing truth: SVN doesn’t allow inter­ac­tive and par­tial patches, which Darcs names hunks.

What do you do in that case? Pro­vided that there are peo­ple who actu­ally abuse the Save as… func­tion of their edi­tor by sav­ing mul­ti­ple copies of the same file accord­ing to the log­i­cal patch they con­tain (which I find absolutely hor­ri­ble), the quick­est way I could find was to:

  1. Mak­ing a diff: svn diff > logical_patch_1.diff
  2. Edit the diff man­u­ally, until I had two files, which rep­re­sented the two log­i­cal diffs
  3. Revert the pris­tine: svn -R revert .
  4. Apply the first diff: patch -p0 < logical_patch_1.diff
  5. Com­mit: svn commit
  6. Apply the sec­ond diff: patch -p0 < logical_patch_2.diff
  7. Com­mit: svn commit

With Darcs, all you have to do is issue the darcs record com­mand (which records your changes):

  1. Record: darcs record -m "First logical patch (fixes bug 1234)"
  2. Answer “yes” to the first hunk, and “no” to the second.
  3. Record again: darcs record -m "Second logical patch (fixes bug 5555)"
  4. Answer “yes” to the only hunk

Can you see the dif­fer­ence? It’s not just about the num­ber of oper­a­tions needed, but the qual­ity of them, and the fact that Darcs is per­fectly ori­ented to this kind of flex­i­bil­ity. Please con­sider switch­ing to Darcs for your projects and work, as it’s a mature and bet­ter system.

19 responses so far

ACE: The Adaptive Communication Environment

Feb 03 2007 Published by Salvatore Iovene under Software

For some time, in the last months, I have been using, both for work and leisure pur­poses, the ACE library. ACE is a very pow­er­ful, use­ful and portable frame­work, ori­ented to net­work­ing, but that can be used for abstract­ing nearly any sys­tem depen­dent task. In my case, I’m using it for two client-server archi­tec­ture projects, one of which is the MMORPG I’m work­ing on.

ACE has had, for me, a pretty nasty learn­ing curve: at first there are some good tuto­r­ial, and plenty of exam­ples and test in the instal­la­tion direc­tory, but after a while you are prob­a­bly going to need to pur­chase the books, to mas­ter it. I really can’t blame the author(s) for that, as ACE is an impres­sive (I mean it) work, and deserves some revenue.

Using ACE for my projects has turn out into an incred­i­bly use­ful out­come: I do all my devel­op­ment on GNU/Linux machines (Debian Sarge at work, and Debian Unsta­ble at home), but the code I write needs to be ported to the Win32 plat­form as well. I’m no Win­dows pro­gram­mer, and no Win­dows user, and there are other peo­ple in my com­pany who take care of inte­gra­tion with Win32 sys­tems. After writ­ing my client/server project for about two months, it started to get usable, and we decided to port it to Win32, and, to some extent, we were expect­ing some trou­ble in port­ing to Win32 an appli­ca­tion that went on for two months and was made of roughly 10 thou­sands lines of code. The project is a server process plus a dynamic library com­mu­ni­cat­ing with it, that a UI client can use. Well, the port­ing to Win32 took no more than half an hour, and just a few changes needed to be made. Of course, dur­ing the devel­op­ment, I’ve been car­ing of not using any sys­tem depen­dent code, but the facts that it took so lit­tle to port, was sim­ply amazing.

The ACE library has pro­vided for me lots of plat­form inde­pen­dent things: a way to man­age sock­ets and TCP con­nec­tions, a way to man­age load­ing of exter­nal pro­grams, a way to man­age threads (and related mutexes or locks), a way to man­age log­ging, a way to man­age trac­ing, and many more.

You can check this address for some good ACE tuto­ri­als, espe­cially regard­ing the client/server com­mu­ni­ca­tion. In my cases, I’ve gone for an approach ori­en­tated to a sys­tem that would han­dle one client con­nec­tion in a ded­i­cated thread. Thanks to ACE, this has been very easy and con­trol­lable. By con­trol­lable, I mean that I’m quite sure that the code I’ve pro­duced, to that regard, is prac­ti­cally bug free. ACE helps you very well in tak­ing care of all the errors and react­ing accord­ingly. Due to the vast num­ber of plat­forms ACE sup­ports, it lacks excep­tion han­dling, which can be con­sid­ered a bad point, although nec­es­sary. To some extent, though, ACE can sup­port excep­tion han­dling, even if, for porta­bil­ity and integrity rea­sons, it’s advis­able to let it go and rather use the clas­sic return value check­ing approach. Noth­ing will any­way impede you in cre­at­ing your own excep­tion han­dling layer on top of your classes which man­age ACE.

ACE is really strongly Object Ori­ented, which makes it per­fectly suit­able for large (but well engi­neered) projects. Need­less to say, that ACE is not advised for very sim­ple projects, unless you just want to take advan­tage of the sys­tem abstrac­tion it pro­vides. For larger projects, instead, you’d bet­ter be very care­ful and plan in advance. If you don’t know the sys­tem very well, you might end up mak­ing some wrong choices and wast­ing time. To this con­cern, I advise to read the books.

ACE is also very use­ful when it comes to log­ging, as it pro­vides some really sim­ple but pow­er­ful macros that can be used in debug mode, and that will pro­duce no code at all if dis­abled. You can check this web­site for an intro­duc­tion to the ACE log­ging facilities.

I will end this short arti­cle with a list of pros and cons about ACE, as I’ve found out dur­ing my experiences.

Pros

  • Very portable.
  • Very powerful.
  • Good ini­tial learn­ing curve.
  • Huge list of features.
  • Many exam­ples.
  • Great mail­ing list sup­port (even though they remind to read­ing the books too often).

Cons

  • API are not very well documented.
  • You need to pur­chase the books to mas­ter it.
  • No free binary releases.

What I advice it for
Any large project that need to man­age net­work­ing and multithreading.

No responses yet