Archive for October, 2007

Standard C++ and GUI frameworks

October 15, 2007

A very common complaint against C++ is the lack of a standard GUI library. While I agree that it would be great to have one portable, modern GUI library, I don’t think it will ever happen. Traditionally, in the Windows market, GUI frameworks are a strong selling point for tool suppliers, so everybody has their own. Under Unix not only are GUI libraries mostly C oriented, but the one that emerged at one point as the vendor backed standard, namely Motif, has since been obscured by more attractive open source alternatives.

Among the cross platform C++ specific solutions available today QT and WxWidgets are probably the most popular ones, but they don’t appear to be suitable for inclusion in the standard. QT is produced by one of the field players and uses some non standard syntax, handled by a precompiler. The fact that Trolltech, QT’s developer, is including in it just about everything and the kitchen sink is not likely to help, even assuming that Trolltech is interested in QT’s inclusion in the standard, which isn’t something I would take for granted. WxWidgets, being an open source project, appears to be in a better shape from a political point of view, but while effective it can hardly be considered a modern design.

Another factor that must be taken into account is the advent of the web browser as an alternative interface paradigm. While I’m not convinced that this is an all-round superior alternative to GUI’s, it is often a valid contender and a more “fashionable” one. This is one of the reasons why I don’t see a business case for a new commercial C++ GUI framework and I don’t expect an open source one to emerge, especially in the light of the non trivial effort that a similar endeavour would entail.

Yet another option that is mentioned every now and again is the development and adoption of a simple, bare bones library. I don’t think such an approach would be of much use. In my opinion C++ is still chosen to develop GUI based applications because it guarantees responsiveness and control over appearance and behaviour of the interface. Ease of development is important, but not enough to be traded against speed and access to detail. This makes also adopting a thin wrapper over an existing , portable framework not viable. The other reason being that requesting vendors to supply an external library in order to comply with the standard would be awkward. The fact that C++ is defined by a standardization committee rather than by the developers of a reference implementation limits the extent to which an approach such as Python‘s “batteries included” may be applied.

In my opinion, however, there is an alternative approach that might have better chances of succeeding: rather than aiming for a full fledged GUI library it might be more effective to concentrate on the interface between the GUI and the application logic and forsake everything that relates to the visual aspect of the interface. The resulting library would include a framework for event handling and callbacks, which might be based on the Boost/TR1 Signals and Function libraries; paradigms for input /output towards visual components, from toggle buttons, to text fields, to combo boxes; and possibly a validation framework.

I’m aware that such an approach would leave out a good deal of GUI programming, but a sound design would encourage a clean separation of GUI and program logic, and probably lead to more testable code. A similar library could be implemented as a set of add-ons for existing GUI frameworks, without requiring the implementation of a completely new one.

Advertisements

My, it’s damn quiet around here!

October 15, 2007

It’s been some twenty days since my last post. What has happend is that, after languishing for several months as maintainer for a project scheduled to be dismissed, I’ve been moved to something completely different.

After refining my C++ skills for almost ten years, after embracing object orientation, then generic programming, then template meta-programming (in rather small doses, to be honest), an unexpected twist in my career has suddenly brought me to the extreme frontier of software development: Cobol on System i (aka iSeries aka AS/400).

Well, yes, so it’s the opposite frontier from the one that’s usually boasted, but frontier it is, at least for me. If we discount a couple of brief encounters with menu based applications that ran on IBM mainframes, it’s been close to twenty years since I logged into, sorry onto, a system I knew nothing about, the last one being VAX/VMS, I think.

I must say I find it rather amusing to have to learn a set of technologies that were considered obsolete when I was at the university about a quarter of a century ago. I expect to post more on the subject in the coming weeks, even though blog time has become awfully scarce.