Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
×
GNOME GUI

Murray Cumming on Programming for GNOME with C++ 25

GonzoJohn writes: "Christian Fredrik Kalager Schaller for Linux Orbit: 'If you have followed GNU/Linux for the last few years you know that GNOME has long been a stronghold of C, Perl and Python GUI programming. With Ximian's work on Mono, C# seems also to be a language that will see wide use in GNOME. Sun's involvement should also make Java applications integrate strongly with GNOME. But what about C++? Even in the GNU/Linux and Unix world this language has received many advocates and developers. I sat down with Murray Cumming, lead developer on the gtkmm and gnomemm C++ bindings for GTK+ and GNOME to get some information on the status of C++ development in GNOME.'Read the Interview."
This discussion has been archived. No new comments can be posted.

Murray Cumming on Programming for GNOME with C++

Comments Filter:
  • Slashdotted already! (Score:1, Informative)

    by Anonymous Coward
    Interview by Christian Fredrik Kalager Schaller [mailto]

    If you have followed GNU [gnu.org]/Linux [linux.org.uk] for the last few years you know that GNOME [gnome.org] has long been a stronghold of C, Perl [perl.org] and Python [python.org] GUI programming. With Ximian [ximian.com]'s work on Mono [http], C# seems also to be a language that will see wide use in GNOME. Sun [sun.com]'s involvement should also make Java [javasoft.com] applications integrate strongly with GNOME. But what about C++? Even in the GNU/Linux and Unix world this language has received many advocates and developers. I sat down with Murray Cumming, lead developer on the gtkmm and gnomemm [gtkmm.org] C++ bindings for GTK+ [gtk.org] and GNOME to get some information on the status of C++ development in GNOME.

    Christian: What is your background and what puts food on your table in real life?

    Murray: I'm a freelance developer, though that's difficult in the current market. I do C++ development on Unix, on all kinds of projects, such as protocol implementations, compilers, interpreters, data converters, management systems, and GUIs to make sense of all these. I've lived in Munich, Germany, for the past 3 years, but I'm officially a Brit. I love Munich's healthy outdoors lifestyle and easy-going socialising. I try to put the Lederhosen out of my mind.

    Over the past ten years I worked my way up through paper-shuffling, data-entry, typography/design, tech-support, database consultancy, and Windows development. I didn't learn programming at a college, and I still stubbornly believe that it made me a better developer. You have to really care about something to teach yourself in your spare time.

    I didn't use any Unix-like systems until Linux was widely available. People forget that before Linux you had to go to University to use Unix. Some companies had big Unix boxes, and the staff who used them generally earned huge sums because they knew how to move files around. Naturally they didn't let anyone else near them.

    I've grown to love the control that Unix gives you but I've done hardcore GUI development on MacOS [apple.com] and Windows, so I know there's more to life. Unlike lots of GNOME developers, I know that the Mac is a worthy influence but that Windows gives us nothing to chase.

    Christian: How did you get involved in developing gtkmm and gnomemm?

    Murray: I was originally just a user, more attracted to the up-to-date gtkmm than the awkward (and then non-free) QT [trolltech.no]. I did the carthorse work necessary to get gnomemm 1.2 usable and stable, and that's how I learned about the general issues involved.

    Then I decided to make a big effort to get gtkmm2 going, when it didn't look like anyone else was going to do it. Karl had the beginnings of gtkmm2, but it didn't build and he was reluctant to show it to the world, fearing that people would expect a certain amount of work from him. He didn't have time to do much more on it, but I did persuade him to put it on the gnome cvs. I worked on it gradually, sending progress reports to the list in case anyone was interested, and so that other people could learn too. After about 4 months I understood what it was doing, and it was able to run simple example code. As soon as I reached that stage lots of people started helping out.

    Christian: What are the main design ideas of gtkmm and gnomemm?

    Murray: We aim to provide the interface that a skilled C++ coder would expect, based on his experience of the language and the standard C++ Library. We try to use the standard language features wherever possible, just as any sensible C++ coder should. There would be nothing unusual about this if it weren't for bizarre C++ libraries such as QT and MFC. Is sanity really a design decision?

    It's not really a design decision, but we are particularly proud that C++ allows us to simplify the underlying C interfaces. For instance, GtkTreeView has a great deal of flexibility, but gtkmm doesn't expect you to worry about that functionality unless you actually want to use it.

    Christian: Okay, as you told me you made an effort to get gtkmm going, what where your aims when starting out with it?

    Murray: I had 2 aims for gtkmm2:

    1) Refactor it until both the interface and the implementation were ridiculously clear. I did not want any lingering doubt about the code just because people couldn't understand it. I believe that even a dull-witted person, with enough time, and enough notepaper, can make sense of anything. If he's not dull-witted then he'll make it easier for the next person.

    2) Get more developers involved. This becomes easier after 1) when people can understand the code enough to improve it, but it's also necessary to:

    • Present a clear vision so people know what's happening. To this end, I make a point of pre-announcing all major changes, discussing them, and announcing my interpretation of the consensus before proceeding. Everybody now understands that that's how we work, and that's why we've been successful. We only have to point to the list archives to justify our decisions in detail.
    • Nurture people to get them started. We do this on the mailing list and in the #c++ IRC channel on irc.gimp.net.
    • Let people know that their contributions are valued.

    I know from commercial software development that money alone doesn't motivate people. In both proprietary and open-source projects, a team can only succeed if its members feel valued and involved in something worthwhile. That requires constant attention, but it pays off eventually.

    Christian: That sounds good, so what is the current status of the C++ bindings for GNOME 2?

    Murray: We are approaching API stability for gtkmm2, I think. Our code generator warns us about any functions that we've forgotten to wrap, and we are keeping track of API coverage manually too. We are spending most of our time now perfecting and simplifying the complex TreeView and TextView interfaces, and I see the end in sight there too. Lots of people are using gtkmm2 now and the response is overwhelmingly positive.

    gnomemm 2 is progressing more slowly, mostly because it's more difficult for people to install all the latest GNOME 2 libraries. While it's still in development. Gnomemm 2 is much more integrated than gnomemm 1.2 - you can even download and install it as one tarball to get wrappers for libgnomeui, libglade, and gconf, among others.

    I recently shared the gtkmm maintainership with Daniel Elstner because he's been doing so much good work on fundamental stuff. With two committed maintainers, and several regular developers, the future should be secure.

    Also, we just announced support for the Forte C++ compiler that Sun will use for GNOME 2 on Solaris. And we are on the threshold of supporting Windows. Both of these platforms should be of great interest to commercial in-house developers.

    Christian: Do looking ahead, what are the future directions of gtkmm and gnomemm?

    Murray: For the future, we need to work on more Rapid Application Development stuff. The idea should be to add convenience without adding complication or straying from existing standards.

    I'm working on some libglade additions that should make it easier to link custom code with separately-designed user interfaces. libglademm's syntax is already simpler and more helpful than libglade.

    When GNOME's Anjuta2 [sourceforge.net] is released, and when I can easily install KDevelop [kdevelop.org] for KDE3, we need to add helper features for gtkmm.

    We need to add things such as:

    • Application-creation wizards so people can get started quickly.
    • An "Add a signal handler for this widget to this class" feature
    • An "Add a member variable for this Glade widget to this container class" feature.
    • A widget creation wizard.
    • A Bonobo control creation wizard.
    These IDEs should already have standard C++ features such as
    • Add a class, deriving from this widget class.
    • Add a method to this class.
    • Override this method in this class.
    We should then have all the functionality of Visual C++, but without requiring the same IDE for future editing or building of the code. It's possible to have those features without the insanity.

    Christian: OrbitCpp is being integrated to ship as part of the core ORBit2 package. What will this mean for C++ developers working on GNOME apps?

    Murray: The Bonobo bindings are progressing well, but until ORBit2's C++ support is merged in, just after GNOME 2, we must supply bonobomm separately. I'm particularly proud of the Bonobo bindings - the lack of API clarity in Bonobo has long irritated me and this is an opportunity to show that it's not really that difficult. I've explained the issues in more detail elsewhere. C++ is the natural language for CORBA, which is inherently object-orientated - CORBA in C was always a freakish idea so it's no wonder that it's difficult.

    So this means more people can use Bonobo. And the API clarity should mean that the Bonobo interfaces receive more scrutiny, because people will understand them well enough to criticize them.

    We're really lucky that Michael Meeks [gnome.org] decided to support our efforts by merging the C++ mapping into ORBit2 itself. It gives it a mainstream future.

    Christian: The release of GNOME 2 is approaching fast now, how does the GNOME 2 platform look from the view of someone producing language bindings for the GNOME platform? Will there be any significant design changes introduced into the bindings due to the changed in the GNOME 2 platform?

    Murray: Language bindings should now be much easier. The GTK+ and GNOME authors are more aware of the needs of language bindings and the various bindings are cooperating more, particularly with the .defs interface-definition files. For instance, we use James Henstridge's .defs generation scripts for pygtk.

    The transition to GNOME 2 has allowed us to make previously forbidden interface changes to the underlying libraries. We developed gtkmm2 while GTK+ 2 was being developed. With gtkmm 1.2, we just complained about problems in GTK+ 1.2, but this time we fixed the problems in GTK+ as we found them.

    gtkmm2 (for GNOME 2) is significantly different than gtkmm 1.2 (for GNOME 1.x). Some of these changes are due to changes in GTK+, but most are just lessons that we learned from gtkmm 1.2. GNOME 2 rationalizes its interfaces a lot by deprecating its more crufty stuff, and we make our interfaces even clearer by omitting those deprecated parts completely.

    Christian: What are you favourite applications that has been developed using the gtkmm and gnomemm bindings?

    Murray: I use Gabber [sourceforge.net] every day as an instant messenger client - I love how it Just Works. I'm trying to persuade Julian to start the gnomemm2 port, even if I have to code it myself.

    Cactus's Guikachu [rulez.org] is also pretty impressive - it has made me want to do some Palm development.

    There's a bunch of specialist apps out there, though not so many have been ported to gtkmm2 yet. I think that a lot of our users are doing in-house stuff. C++ is much more popular than C for that kind of thing.

    I have high hopes for my own Glom [sourceforge.net] app. It's meant to be a very easy-to-use database application that embodies my years of database design experience. But I've been too busy working on gtkmm2/gnomemm2 to port it properly. In the meantime, I released a small file utility, PrefixSuffix, which is a pretty good gtkmm2 example.

    Christian: What are your thoughts on the future of the C++ language? Will it continue to be one of the major computer languages or is it set to be replaced by languages such as Java and C#?

    Murray: In my opinion, Java and C# are much closer to interpreted languages in their design. By this I mean that much more is decided at runtime than at compile-time. I'm bored by discussions of executable speed, but I do feel that compile-time checking verifies designs and speeds development. Java and C# offer object-orientated improvements over scripting languages such as Perl and Visual Basic, but I see no competitor to C++'s feature set. I expect it to maintain its current high level of popularity.

    Christian: About two years ago there was a lot of noise around gtkmm and gnomemm, with Havoc Pennington having started the Inti project, and with the leaving of Guillaume Laurent from gtkmm development, after which Guillaume was quite vocal in why he felt that gtkmm wasn't what thought is should be, in fact he called it a 'throw-away prototype' for a GTK+ C++ wrapper. Two years is a lot of time in the software world so I'm wondering what your thoughts are on the issues debated on back then, and how you see today's versions of gtkmm and gnomemm responding to any real issues raised back then.

    Murray: I wasn't involved in those discussions, but I was annoyed at the schism. I like to think that I would have found an acceptable consensus. Most gtkmm users and developers strongly disagreed with Inti's design decisions so we carried on hoping that we would prevail. We did, and Inti didn't, and it's all history now. Inti died because it never involved a community of hackers, whereas I like to think that people preferred to work on gtkmm's design and felt more welcome in the gtkmm community.

    RedHat's whole Inti framework never made much sense to people. Havoc is such a pragmatic developer that I still don't believe it was really his brainchild.

    But Inti did create confusion among users, and even prompted one of the gtkmm maintainers to give up. My guess is that Guillaume never really got a handle on the gtkmm codebase and took the opportunity to jump clear of something that daunted him. When I was building gtkmm2 I sometimes felt the same but I chose instead to radically refactor it until it was manageable. I believe Guillaume felt certain anyway that, with RedHat's backing, Inti would succeed and gtkmm would fade away.

    Guillaume uses QT now. He has stated that it was more important for him to have a full working toolkit than a perfect API. gtkmm2 will go stable soon - then we will have both in one toolkit.

    Christian: What are the main differences of coding with gtkmm and gnomemm compared to coding with QT and KDE [kde.org]?

    Murray: I addressed this in my GUADEC [guadec.org] talk (1 [murrayc.com]) and (2 [murrayc.com]).

    Basically, QT isn't developed publicly so it makes a number of mistakes without the benefit of any real criticism. Chief among these is its modification of the C++ language and the use of its own non-standard string class. It isn't necessary, as we've proved. These are just two ways that we've kept more up-to-date with the state-of-the-art in C++. It's then easier to use gtkmm in combination with other C++ APIs. I believe that you'll love gtkmm if you love C++, and that gtkmm is a better role-model if you're learning C++.

    People sometimes complain about a lack of gtkmm documentation compared to QT, but that hasn't been true for a long time(* [gtkmm.org]).

    And perhaps most importantly, if you find a problem with gtkmm you can submit a patch or discuss it with the developers.

    Christian: What is the advantage of using the bindings when creating GNOME and GTK+ applications in C++ compared to just accessing the C widgets?

    Murray: Again, the GUADEC talk mentioned this (1 [murrayc.com]) and (2 [murrayc.com]).

    gtkmm applications tends to be more organized than GTK+ programs. That's mostly because it's laughably easy for us to derive new widgets just to organise our code. In comparison, the structure of GTK+ code tends to be defined by the path that data happens to take through the code, rather than the layout of the source code itself.

    Christian: What would you say to a developer who is trying to decide whether to write his application in C or whether to use gtkmm and gnomemm and C++?

    Murray: I believe it's easier to develop software with C++, even if you're not very experienced, because the structure is there in the code, not just in your head. If you're as good as the GTK+/GNOME developers then maybe you can deal with the underlying C interfaces, but, in my experience, most coders want an easier life.

    I'd recommend that people compare the C and C++ versions of the examples before deciding.

    Christian: You made a presentation at GUADEC 3 this year. What is your impression of the GNOME community, is it becoming more language agnostic or is there still a strong favouring of C among the hackers you talked too?

    Murray: I think people accept now that there will always be active language bindings for GNOME, and many of the core hackers now routinely use more than one programming language. There is still some general Unix-style dislike of C++, but interest has grown as people have seen that gtkmm is very much alive and useful.

    Christian: For anyone wanting to learn how to create applications using gtkmm and gnomemm, where should they start looking? Are there any applications out there that you think a newbie would find a easy starting point to look at before starting creating their own applications?

    Murray: Assuming that you're already a C++ coder, you should be able to get started easily by looking at the examples and the 'Programming with gtkmm' book. In fact, we have a particularly good documentation overview page with quick links into the manual and the reference documentation: http://www.gtkmm.org/gtkmm2/ [gtkmm.org]

    We have converted all of the GTK+ examples and demos and added some of our own. I believe it's easier for a C++ coder to understand the gtkmm examples than it is for a C coder to understand the GTK+ examples.

    I strongly suggest that you start with gtkmm2 rather than the stable gtkmm 1.2, because we have obliterated several confusing things.

    People should also join the gtkmm-main mailing list and the #c++ channel on irc.gnome.org. We are a helpful bunch.

    Christian: Okay, thanks for taking the time to talk with me Murray.

    Murray: No problem, it was a pleasure.

  • I do C++ programming with C libraries and API's all the time. It's not like C++ can't interface with C libraries. . .

    If you absolutely need to have it be OO, it's not too hard to write wrapper classes for all the functions you'll be doing. For OpenGL work I have a few classes of that kind that I use a lot - a camera class, for example.
    • Ah, but why write your own wrappers when someone (and not just someone, but lots of people) has written wrappers for you? Why worry about the design when there's a design already done and reviewed and redone?

      Give me a good reason to reinvent the wheel, and I will. Hell, I used to reinvent the wheel for bad reasons or no reason. Wanna see my StringBuffer class? Didn't think so.

      I've been using gtkmm on a little project of mine, and it's quite nice. I used gtkmm to give a gui to du. Used code from 2 different open source projects to do what I wanted.

      Every line of code you reuse is more likely to be right than every line you write. If it's already been written, if it's already been tested, it's one less thing to worry about.
    • It's not like C++ can't interface with C libraries. . .

      It's often pretty painful, though. Off the top of my head:

      • Complex C APIs, especially GUI systems (e.g. Win32, Motif) often try to implement an object model themselves, which usually doesn't map well onto C++'s object model.
      • APIs with callbacks are almost never exception safe.
      • Varargs at the C level usually implies const incorrectness at the C++ level.
      • Don't get me started on concurrency, though at least modern C APIs tend to get this right.
      • Memory management/ownership issues occasionally crop up, though this is a bit more rare in a well-written C API.
    • by mbrix ( 534821 )
      Go see the gtkmm FAQ: Why use gtkmm instead of GTK+? [sourceforge.net].

      Working with STL-style interfaces, and having the chance to use std::string and std::vector to input data to your widgets is just *great*.

      Of course, all the other advantages of C++ can be used as an argument on why to use the C++ interface.

      You never mentioned why you don't want to use the C++ interface, maybe you should mention what you consider the disadvantages.
  • Qt bad gtkmm good? (Score:4, Interesting)

    by pmz ( 462998 ) on Thursday May 23, 2002 @01:04PM (#3573983) Homepage
    Can someone clarify what the awkwardness, bizzareness, and insanity of Qt are? I've used Qt on a couple of small projects and found it pretty intuitive. No flames, please, just a couple of good arguments.
    • In one word: moc
      • Moc? Moc is simply a preprocessor to add on language support for the signal/slot methods. If you remember, C++ started out as a preprocessor for C. OK, so it might not be kosher C++, but it's much more intuitive to do things that way than with base-classes, etc, that you see with other C++ GUI techniques.
    • by Seli ( 51600 ) on Friday May 24, 2002 @02:03AM (#3577503)
      There aren't any really (well, at least not more than in other pieces of code). Let's for example have a look at the table comparing gtkmm and Qt linked from the article (this one http://www.murrayc.com/murray/talks/2002/GUADEC3/s lides/html/img6.htm). For a guy who's supposed to know C++ so well his arguments have rather weak base ground, so he's either not that good, or he's just badmouthing Qt without knowing the things.

      Moc extends C++: Oh yeah, telling this to people believing moc is a preprocessor can be hard, but moc extends C++ about as much as Doxygen. Moc is a code _generator_ (or call it precompiler), it's not needed to preprocess the sources, programs written in Qt are valid C++, otherwise one wouldn't be able to compile it with so many C++ compilers. What moc does is it analyzes headers files with few tags added, and for reasons like making it easily readable those tags are created using few #define macros. If TT wanted, they could be written in comments, just like for Doxygen, and it would be perfectly perfectly pure C++, yet there wouldn't be any real difference. In fact, it would be possible to write Qt code even without moc, but one would have to hand-write all the generated code, and that would probably get some people in madhouse.

      Containers: Qt has to run on a number of quite old and crappy platforms (unfortunately, I'd be happy if TT dropped the support for them too). That's the real world. It's easy to limit a brand new library (which gtkmm2 is) to using things like that, but there are still C++ compilers in use that can't handle things like that. Some key design decision for Qt were made many years ago, and some (paying) developers wouldn't be happy if Qt completely changed every year. Moreover, Qt3.x has support for STL (I don't know how good though, I don't use it), and maybe Qt4.x will have its own containers only for backwards compatibility, and will prefer STL.

      Namespaces: Qt is in a sort of namespace, and it should be sort of namespace clean (everything starting with Q). Since for KDE4 it's planned to have it completely namespace clean, including plugins, etc., Qt4 will be maybe in its own namespace too. Not that putting it in a real C++ namespace will make that much difference.

      Memory management: One can delete widgets in Qt, and they will be automatically removed from the parent, who's otherwise responsible for the deleting (and getting used to this simplifies things). It's also not true you can't create Qt classes on stack, I do that sometimes when it fits. The truth is that it doesn't fit most of the time.

      GNOME classes: Let's skip this one.

      Widget containers: I don't know enough about the way it's done in gtkmm, so let's skip this one too. It's doesn't matter much anyway, I don't have any problems with separate layouts in Qt (in fact it may be easier to code the layouts that way, but that's just a guess).

      Typesafe signal handlers: Well libsig++ has its problems too, like possibly increased compile time with already slow enough g++, and the compilers need to be very good at handling templates, which g++ wasn't not that long time ago. http://doc.trolltech.com/3.0/templates.html might be a good read in case you wonder why Qt still uses moc and not libsig++.

      License: The table misses QPL and commercial licenses for Qt. TT developers also have to eat, and people need to be payed in order to e.g. write as good documentation as Qt's is (just compare it to gtkmm's). If you can't handle the fact somebody tries to make money and yet is so Open Source friendly, just shut up, ok? I can undestand some people prefer Gtk+ just because of LGPL, but that's no reason for TT bashing.

      Development: There are at least two places where Qt is discussed, for the first one see mailing lists section on TT www site, the other place is KDE lists. For a commercial company, their handling of bugreports and suggestions is quite good. (Not to mention that those FSF fanatics screaming about Qt not being Free(tm) should actually love it - it's GPL'd, not LGPL'd and that's the one true RMS way, isn't it?)

      I'm not saying Qt is a perfect thing. Nothing is. There are certainly things that could be better, some of them are there because of the wide platform support, backwards compatibility, some of them are there for other reasons. But there's no valid reason to call Qt bizzare or insane. It's one of the best toolkits in the world, and I mean it.
    • In one one his slides, they are compared pretty nicely:

      http://www.murrayc.com/murray/talks/2002/GUADEC3 /s lides/html/img6.htm

      I have been programming gtkmm for about a year now, and I really love the APIs. If you know the STL, you'll also feel at home with the gtkmm API.

      As an example, the Gtk::Notebook widget provides push_back() for pushing back your widgets, and you can iterate through the list using rows().begin() and rows().end().

      Another thing is that you won't have to fiddle with MOC. And no reason to add 'Q_OBJECT' to all of your classes.

      I'm looking forward for the Windows support, then we'll have a *great*, 100% free widget set for Windows.
  • by account_deleted ( 4530225 ) on Thursday May 23, 2002 @01:06PM (#3573998)
    Comment removed based on user account deletion
    • by PD ( 9577 )
      That redundant moderation betrays the festering pile of maggots between some moderators' ears. This wasn't redundant at all.

      It was funny. Funny in a sophomoric way, true. But it ain't redundant.

      Posted with my +2 cluestick.
  • This guy can't even spell Qt right, let alone criticise it. I'd advise using Qt first before making off the cuff remarks like that.

    The whole reason for Inti's existence is to compete with the ease and power of Qt. Sorry but the latest m&m release doesn't even come close to matching Qt in the terms of ease of use and power.

Top Ten Things Overheard At The ANSI C Draft Committee Meetings: (10) Sorry, but that's too useful.

Working...