PHOTOOG Photography writings by Olivier Giroux


Thoughts on Cross-Platform C++ Development

It is not as difficult as you think. Convincing yourself (and peers) of that fact is the hard part.

First, to me cross-platform development simply means developing for more than one platform. That's all. It does not mean developing for all platforms known to man, and more specifically not developing for any platforms my customers are not running. This said, my customers run the two platforms I find most different: Windows and Linux.

Let's revisit my opening statement then. In other words, I find the true hardship of cross-platform development is not that the software is so much harder to write, it's that you'll hear a million excuses to not go debug it on that 'other platform', the one where it didn't run first. This aspect of the problem is completely human in nature and produces daily drama fit for soap operas.

Before you ask: yes, in my opinion the oft-cited technical problems are mostly solvable/solved. The quality of free solutions vary greatly however, so you may have to spend either time or money to get what you really need. For certain, having one technical person on your team who's done this before will allow you to chart a course relatively free of technical obstacles.

Some of my rules:

  • Stick to the ISO C++ subset common to your compilers. It helps to be warning-clean at the highest warning levels everywhere. Warnings on one platform may point to silent errors on another. This is free.
  • Avoid system details. Use libraries like Boost/wxWidgets/Qt to abstract some system details, then speak to the lowest-common-denominator on similar system APIs. For the dissimilar APIs, write an abstraction library then consider sharing it with others. There is lots of free or cheap stuff in this space.
  • Make sure to get yourself a single-specification build. Never let your platform builds get out-of-sync with each other by specifying them in one place (quite litterally, one build spec). This does not necessarily mean you have to use makefiles on Windows, but you'll have to roll your own tool if you want to consume VC++ files elsewhere. I haven't found this to be free (down any path) in my experience.
  • Test for regressions all over. Every platform needs to have build and run regression tests. Don't tolerate breakage anywhere. This is decidedly not free - for some software (e.g. a ton of shrink-wrapped software) this cost is high enough to preclude the whole affair.

To summarize: don't be a hacker, be a software engineer. Impress me by hiding the impressive code, or using someone else's impressive code. Also: do it from the start. The later in the game you try to do this, the more painful it will be.

With the above you shouldn't need to do [relatively] much developer-wrestling. You may need to spend time/money on infrastructure, sure, but you won't irrepairably injure anyone's honor. In return you get a decent shot at reducing the frequency at which people have to work on one of their 'other platforms'. I call this a good deal.

What comes next? The drama: fear of the unknown, shame of not belonging, agony of...

Seriously, compared to the drama, you might find the technical issues fun.

Important parting note:

Cross-Platform Development is not trivial. I'm not claiming that any software you can buy in a store should be made to run on [insert-favorite-platform-here]. All I'm saying is that it is merely more work, it does not always amount to a soul transplant as it's sometimes made out to be.

Filed under: Uncategorized Leave a comment
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.