ACE: The Adaptive Communication Environment

Feb 03 2007

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.

Tags:

No responses yet

Leave a Reply