[ACCEPTED]-Should I learn GTK+ or GTKMM?-gtkmm

Accepted answer
Score: 38

I could be accused of bias since I do help 42 contribute to gtkmm, but I was a user first, so... In 41 any case, I would highly recommend gtkmm 40 if you're comfortable with C++. Memory 39 management is much easier with gtkmm than 38 with GTK+ because reference-counted objects 37 are managed automatically with smart pointers. You 36 can also instantiate objects as auto variables 35 (e.g. on the stack) and have their lifetime 34 determined by their scope. So in practice, it's 33 much easier to avoid memory leaks with gtkmm 32 than with GTK+.

Another huge advantage of gtkmm 31 over GTK+ (in my opinion) is the use of 30 a type-safe signals framework. In GTK+, you 29 constantly need to pass things as void pointers 28 and then cast them around to the type you 27 think they should be. In gtkmm, you dont 26 need to do this, and can take advantage 25 of the compiler enforcing type-safety on 24 your signal handlers.

Another big advantage 23 over C/GTK+ is the ease of deriving new 22 classes. In GTK+, you need to write a lot 21 of boilerplate code and basically re-implement 20 things that you get for free in C++ as part 19 of the language (e.g. inheritance, constructors, destructors, etc). This 18 is more tedious and error-prone.

greyfade 17 mentioned that gtkmm is incomplete, and 16 he's right to a certain extent -- gtkmm 15 does not cover absolutely everything in 14 the GTK+ API (though it gets awfully close). But 13 in practice this is not a problem because 12 you can always use the C/GTK+ API directly 11 from your gtkmm code. This C compatibility 10 is a huge advantage of C++ over something 9 like C# or python bindings where you would 8 have no alternatives if the binding didn't 7 cover part of the API.

The only real reasons 6 to choose GTK+ over gtkmm (IMO) are that 5 gtkmm has a little additional overhead since 4 it is a wrapper on top of the C library 3 (but this is generally just a single function 2 call, which is going to have negligible 1 impact), or if you hate or can't use C++.

Score: 19

If you're a C# programmer, why don't you 9 take a look at Vala?

I use pygtk for most of 8 my Linux GUI applications, but Python was 7 simply too slow for the project I'm working 6 on right now, so I was trying to pick one 5 of GTK+ and GTKmm. Then I met Vala.

It's 4 a pretty new language, and therefore documentation 3 is pretty limited at the moment, but I think 2 it has the best of both worlds: C# syntax 1 with C speed.

Score: 13

Since C++ is more familiar to you, you may 11 find GTKmm to be a better fit, since you 10 can use idioms like RAII. Unfortunately, GTKmm 9 is a little incomplete and is missing a 8 few of the lesser-used parts of GTK.

GTK+ on 7 its own, however, essentially exposes an 6 object model similar to what you find in 5 C++, but with only C functions. Things like 4 construction and destruction in C++ are 3 done explicitly in the C API and instances 2 of widgets are handled via pointers exclusively.

Try 1 both and see which fits your project better.

Score: 7

Like many have said, Gtkmm does provide 10 you with good memory management, reference 9 counted objects, etc. It does fall down 8 in one department, though. Documentation. The 7 whole of the Gtkmm project suffers from 6 the "undocumentation" phenomena, where 5 the posted (and reposted on 3rd party sites) documentation 4 is simply a javadoc scan of the header files.

Just 3 wanted you to know what you'd be getting 2 into. For instance, the Scrolled Window is one of the 1 better documented classes in Gtkmm.

Score: 5

I would suggest to learn vala with gedit.

http://www.valaide.org/doku.php : vala

https://launchpad.net/valable 1 : Eclipse

http://code.google.com/p/vtg/ : Gedit

http://abderrahim.arablug.org/blog/ : anjuta

Score: 3

Have you looked at Qt?
It's nice C++ design, cross 1 platform and LGPL

Score: 3

I think the best way to go would be first 14 learn gtkmm! After you are done with the 13 basics of gtkmm, GTK+ should be fairly straightforward 12 to learn(provided you know C and are comfortable 11 with pointers).

In case you don't know C, you 10 can learn it quickly by reading The C Programming 9 Language by Dennis Ritchie

I recommend you 8 to learn gtkmm first because it is specially 7 designed for C++, which is somewhat similar 6 to C# since both are Object Oriented, so 5 gtkmm will be relatively easy to learn first 4 than GTK+.

After gtkmm, you can move on to 3 GTK+

Most of the open source companies use 2 GTK+ rather than gtkmm, so GTK+ is worthwile 1 to learn!

More Related questions