Intricacies of cross-platform development.
Jul 22nd, 2007 by susheel
Ah yes, so you want to make your new program/software cross-platform. Sure you can, just make sure you understand properly what it takes to write robust cross-platform software. If you haven’t written any cross-platform software thus far, then chances are you have no clue what is exactly needed. Writing truly scalable, robust and error-free cross-platform software with consistent behavior across platforms is difficult and I have put an underline on that to emphasize my point. Go out and search for software that satisfies all the above mentioned points. I bet you won’t find more than a few. FireFox browser is one such project that comes to mind. It is a very good example of how cross-platform software should be created. This blog entry is not about how cross-platform development is to be done, you can find that plenty all over the net. It is more about my own experience about cross-platform development and it’s pitfalls.
Cross-platform development can be really easy or really difficult, depending on the design decisions you make. It could add as little as 2% overhead to the entire development life-cycle or things can be as bad having nearly 40-60% of your time trying to get things working the way you want them. Everything really depends on the type of design, the quality of code and the tools you choose. The fact is having cross-platform compatibility does add overhead to any project. So if you don’t have to, don’t aim for cross-platform compatibility. If your project is never going to be executed on a platform, or if you are sure there is no market for a particular platform, don’t get overzealous and try to port for that platform. (Design can be important while implementing cross platform compatibility, understand and use design patterns like Adapter and Facade).
If you every do want your project to be cross-platform, the first thing you have got to do is choose the right development language. Yes, you can write cross-platform C++ code. However different C++ compilers out there can be a nightmare to work with. You could save yourself a whole lot of trouble by choosing GCC for all platforms, but that can’t always be possible. In any case C++ programs can be tough to maintain for cross platform compatibility (though I repeat, it is very much possible to do so). Another thing that can be a real pain in the a** to work with is the build system. Not all platforms will give you a cick and compile IDE for C++. In the worst case you will have to delve into the misty underworld of Makefiles. C++ is not a particularly good choice for cross platform development. Java or Python would be an ideal choice of language in such a case. Both languages scale across platforms pretty well, but that doesn’t mean you have all the features of the language on all platforms. Read the docs carefully before implementing obscure functionality.
A good GUI can make all the difference between for an application. Making a correct choice for a cross-platform GUI is an equally daunting task. There are a lot of GUIs and a lot of libraries that claim to be cross-platform. Don’t be fooled, take them for a test ride and check the functionality yourself by making prototypes. Or save yourself the trouble by choosing a solution that is time tested. While choosing the GUI for cross platform development I have found that there is no easy answer. I worked on Qt some time back but wasn’t impressed with the moc-compiler thing. Also Qt uses obscure and redundant C++ coding practices to maintain compiler compatibility. Qt is a commercially available library and their support is, well I will put it at “OK”. wxWidgets has a huge community, but it builds on top of natively available widget libraries. It’s design mirrors MFC design, so it is a popular framework with MFC developers. I have developed using wxWidgets also and I would put it at good. I have found forum help (not kidding) to be better than Qt. My current favorite GUI is wxWidgets bindings for Python called wxPython. It is very easy to use and supports a ton of functionality (, and yes it is Python).
Another promising project is the Mono project. “Mono provides the necessary software to develop and run .NET client and server applications on Linux, Solaris, Mac OS X, Windows, and Unix.” — The mono project. However some of the parts of the projects like the GUI are still in beta versions. Also one thing I have seen is Mono consistently lags behind Microsoft’s .NET framework. That is to be expected, since Microsoft will lead in .NET implementation and try and keep its version ahead of the competition. But nevertheless, Mono seems a serious contender for any cross-platform development. I haven’t give it a try though, maybe one of these days, when the game is shipped.