The Importance of the GUI in Cross Platform Development
The key question in making your program cross platform is how to port the GUI. One solution is to write separate GUI front-ends for each platform. This gives you great flexibility and lets you hand-fit each interface to the target system, but soon you find you are rewriting the same interface ideas from scratch. You start to wonder if you shouldn't abstract out some concepts, such as creating a button or drawing a line, and use that abstraction instead. This is precisely what portable GUI toolkits already do. So instead of re-inventing the wheel, or, widget, you will probably want to choose a GUI toolkit and hopefully even improve it.
There are two approaches to providing platform-independent GUI functionality. The wrapper approach wraps the native system widgets in an abstraction layer that provides a common functionality among the different systems. The emulated, or pure, approach simply intercepts the native drawing calls and then uses those calls to implement its own widgets.
Wrappers are easier to program because you don't have to write your own widgets. The look and feel of the native target platform is easily maintained because, under the wrapper, you are using the native system widgets. However, wrappers also lose flexibility because they can only provide what the native widgets already provide—a “lowest common denominator” approach to portability. They can't be extended. They do not allow you to exploit the full power of a toolkit.
I personally prefer the pure or emulated widgets over the native wrapper classes. If you are impressed with certain native widget features in the latest release of Windows, you may fear that emulated widgets will lag behind those native, wrapped widgets. For me, it's the other way around. I see the emulated approach as having the flexibility to exceed native platform features. I believe that if the majority of free GUI toolkit makers were working on a common “Linux GUI API”, we would soon outpace Windows and other company-controlled GUI development with the excellence of our new and emulated widgets.
I'm working on programs that need to be fully multilingual, including fairly complicated composition of Chinese, Japanese and Korean characters (kanji). I'm not impressed with the new native widget features of Windows; they don't come close to doing what I need. So with widget wrappers I'm stuck basically rewriting every widget from scratch based on a Canvas widget, whereas with pure widgets I can use the usual object-oriented techniques to extend existing widgets (assuming the API is well-designed). This provides greater flexibility and consistency when writing GUI applications.
For Linux and UNIX there is another problem with native widget wrapping; it is not clear what constitutes native widgets. In Windows and Macintosh this is obvious. But there is no standard GUI API for UNIX (other than the X protocol, which is not a full GUI). The closest UNIX gets is Motif, which is not really a standard and is not free. In other words, in the Linux world, even before you consider questions of portability, you first must choose a GUI library. You must determine what widgets will be your native widgets. In addition to providing all the widgets and structure you want for Linux programs, your chosen GUI toolkit may offer assistance in cross-platform development. And that is what you want. Programming is now more efficient, as you only have to master one set of tools.
Since C and C++ are so popular, most of the toolkits have C or C++ interfaces. In fact, most of the time it is C++ because object-oriented programming seems particularly applicable to GUI code. However, some, such as Fresco, attempt to be language neutral and potentially provide an interface to almost any language. These toolkits come as libraries that must be compiled and linked for each target system. On the other hand, there are the interpreted languages such as Smalltalk, Tcl and Java that can run on multiple systems without having to be compiled for each one. Then there are the toolkits written in C, such as GTK, that can be called from many other languages such as Scheme, Python or Perl. (Note that GTK is not currently cross platform, but see below.)
Linux needs a standard GUI API. It's not that all applications must end up looking and even acting alike as in Windows, but they should be consistent in certain areas; for example, a consistent desktop, consistent help system, cut and paste, drag-and-drop and so forth.
The fragmentation of development energy into too many GUI toolkits is one of the most serious problems facing the Linux community today. There is some recognition of the magnitude of the problem but nobody can agree on which GUI toolkits to use. A good example is the Gnome and KDE desktop projects; Gnome uses GTK, and KDE uses QT.
For Windows and Macintosh, it's simple; you don't have a choice. Naturally, I prefer the fecundating chaos of the world of Linux and GNU to the stifling dictatorial conformity of the Microsoft domain but, as a programmer, it would be satisfying if the choice of GUI toolkit were a no-brainer. It would be nice if there were such a thing as the “Linux GUI API” so that the synergy of the Linux developers' community could better foster the creation of innovative and compelling programs rather than merely innovative but unfinished tools.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Google's Abacus Project: It's All about Trust
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Back to Backups
- Seeing Red and Getting Sleep
- Secure Desktops with Qubes: Introduction
- Fancy Tricks for Changing Numeric Base
- Working with Command Arguments
- Secure Desktops with Qubes: Installation
- Linux Mint 18
- CentOS 6.8 Released
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide