GTK+ and Glade3 GUI Programming Tutorial - Part 2

Choosing a Programming Language for GTK+ Development

In part 1 of the GTK+ and Glade3 GUI Programming Tutorial series, we designed a graphical user interface (GUI) for a GTK+ text editor application. After doing so, we were left with an XML file (tutorial.glade) which described our application's user interface.

In this part of the GTK+ and Glade3 GUI Programming Tutorial series I will be discussing the various programming languages available for GTK+ development. Subsequent parts of this tutorial will cover both C programming and Python programming. With my help, you will have to make the decision of which one you want to learn how to use (or both!).

GTK+ and Glade3 GUI Programming Tutorial Contents

Contents

  1. Part 1 - Designing a User Interface Using Glade 3
    1. Quick Overview of GTK+ Concepts
    2. Introduction to Glade3
    3. Getting Familiar with the Glade Interface
    4. Manipulating Widget Properties
    5. Specifying Callback Functions for Signals
    6. Adding Widgets to the GtkWindow
    7. How Packing Effects the Layout
    8. Editing the Menu (or Toolbar)
    9. Final Touches to the Main Window
    10. Getting Additional Help Using Glade
    11. What Next?
  2. Part 2 - Choosing a Programming Language for GTK+ Development
    1. Which is the BEST Language?
    2. Language Choice Considerations
    3. A Look at Python vs. C
    4. What Next?
  3. Part 3 - Writing a Basic Program to Implement the Glade File
    1. Setting Up Your Development Environment
    2. GtkBuilder and LibGlade
    3. The Minimal Application
    4. Compiling and Running the Application
    5. Stepping Through the Code
    6. What's Next?

Which is the BEST Language? 

Let's get this out of your system now. This is a question for which you can spend the rest of your life reading answers to--and each will be different. The problem is that this is the wrong question to ask as the answer is different for every person in each different circumstance. Each language comes with it's advantages and it's drawbacks. The question to ask: Which language is well suited for me on this particular project?

Language Choice Considerations 

The important thing to remember when starting in with a language, is to keep an open mind about other languages. You may start GTK+ programming with language X, and later switch to language Y once you know and understand how it's benefits are suited to your task. The GTK+ concepts will remain the same from language to language.

  1. Experience Level How experienced you are with programming in general as well as how much time, patience, and devotion you are willing to spend are important factors in choosing a language. People without any programming experience have to learn fundamental programming concepts as well as the syntax and features of a new language. An experienced programmer can pick up a new language very quickly in comparison and can focus more on what the language has to offer as opposed to it's learning curve. Furthermore, if you're already a PHP expert, perhaps starting GTK+ development with PHP might appeal to you. Maybe you took a course on C++ in college and want to start there. Maybe you only worked with Visual Basic but are ready to take the plunge and learn C.
  2. Activity and Community Support GTK+ is written in C. Other languages are available through "language bindings" which "wrap" the functionality. How active the project is which provides said bindings is an important factor. You want to choose a language that is up-to-date with new releases of GTK+ and bug fixes (all languages I've mentioned are pretty well up to date). Furthermore, a strong user-base and thus large community will be important as you get most of your support from the community. The more people using a particular language for GTK+, the more information there will be readily available.
  3. Efficient Programmer vs. Efficient Program There's often a trade-off between how easy the program is to use and how efficient the program is in terms of speed and how much you can do with it on a lower-level. For many applications, the difference in efficiency of any two languages is negligable--and a new programmer would never even notice. For this reason, the increase in productivity is often the deciding factor. As and example, if I needed to write a program which allowed me to simply interface with some command-line utitlity through a GUI, I would likely choose Python or Ruby. However, if I were going to develop a sophisticated, powerful IDE, I would likely choose C or C++. In fact, you can even use several languages in one project! You could write the memory or processor intensive routines in C or C++ and do the rest in Python or Ruby.
  4. Language Sexiness That's right-- how a language looks and feels is often a factor. You spend a lot of time staring at that code. How it flows on the screen, how it reads, and the overall development process in a particular language might appeal to you more than another. You should enjoy the programming you're doing. It's great having options isn't it!

A Look at Python vs. C 

I have chosen to fork this tutorial into 2 languages based on the above criteria. It is my humble opinion that C and Python fit the above criteria best. Both have very, very strong community support and are being used for a large portion of the projects developed for Linux and especially GNOME. Furthermore, they sit on sort of opposite ends of the spectrum with regard to the efficiency vs. productivity debate. You could even follow this tutorial down both paths and compare the 2 languages yourself.

If you have no programming experience, or perhaps just a little experience with something like Visual Basic or PHP, I recommend starting with Python. Even if you are an experienced programmer with C, C++, or Java experience you may want to learn Python. It's an exciting modern language, fun to program with, and incredible quick to learn and use. For Rapid Application Development in Linux, Glade and Python make a great team. Learn more about the Python GTK+ binding PyGTK at www.pygtk.org.

If you're an experienced programmer or dedicated student, it may be worth your while to learn C or C++ for GTK+ development--especially if you're already familiar with C or C++. Learning GTK+ in C makes switching to another language such as Python a breeze. Furthermore, you'll have more options for contributing to existing projects. Personally, I do the majority of my GTK+ development in C despite the extra time it takes.

What's Next? 

In GTK+ and Glade3 GUI Programming Tutorial - Part 3 I will talk about setting up your development environment and walk through a minimal implementation of the Glade file we created in part 1 using both C and Python.

If you don't want to read along and would rather just see the final implementations:

Did you enjoy GTK+ and Glade3 GUI Programming Tutorial - Part 2? If you would like to help support my work, A donation of a buck or two would be very much appreciated.
blog comments powered by Disqus
Linux Servers on the Cloud IN MINUTES