sábado, 19 de octubre de 2013

libgtk flavours

libgtk is one of the most known and used widget libraries. As the base of the GIMP drawing toolkit, as well as the base of the GNOME desktop environment, it has been a very active Open Source project in the last years.

In general, GNOME platform, together with glib, libgtk and many other libraries, it is not only a mechanism to implement graphic applications for GNOME desktop, but also a complete tool set to implement very different applications in top of varied purpose programming languages. Some examples of this kind of different libraries are:

- Pango: for text rendering
- Cairo: for 2D graphics rendering
- GStreamer: as Multimedia library for audio and video reproduction
- PulseAudio: as proxy for sound applications

Back to libgtk, this is basically a C library that allows programming widget base applications. However, there is a whole bunch of bindings to another languages that help on using and expanding the library to a wider set of programmers. Regarding this bindings, there are two well differentiated groups [1]:

- GNOME supported bindings:

Language2.102.122.142.162.182.202.222.243.03.23.43.6
C++ O [#][#][#][#][#][#][#][#][#][#][#][#]
C# O [#][#] _  _  _  _  _  _  _  _  _  _ 
Java O [#][#][#][#][#][#][#][#][#][#][#][#]
Python O [#][#][#][#][#][#][#][#][#][#][#][#]
Javascript O [#][#][#][#][#][#][#][#][#][#][#][#]
Vala O [#][#][#][#][#][#][#][#][#][#][#][#]
Perl O [#][#][#][#][#][#][#][#][#][#][#][#]

Legend

  •  O  Official GNOME Binding
  • [#] Supported
  •  @  Partially Supported
  •  _  Unsupported

Among the languages supported by GNOME, several of the most used programming languages are found, as C++, but also Java, Javascript, Python and Perl and C# (all of them are included among the 12 first places of the Tiobe programming language ranking).  It is somehow surprising that a minority language as Vala is also supported, indeed very well supported, from 2.10 to 3.6 versions, all GTK released versions are supported.

- GNOME unsupported bindings:

Ruby[#][#] @  _  _  _  _  _  _  _  _  _ 
Pascal[#][#][#][#][#][#][#][#] _  _ [#][#]
PHP[#][#][#][#] _  _  _  _  _  _  _  _ 
R[#][#] _  _  _  _  _  _  _  _  _  _ 
Lua[#][#][#][#] _  _  _  @ [#][#][#][#]
Guile[#][#] @  _  _  _  _  _  _  _  _  _ 
Ada[#][#][#][#] @  @  @  @  @  @  @  @ 
OCaml[#][#][#][#] _  _  _  _  _  _  _  _ 
Haskell[#][#][#][#][#][#][#][#][#][#][#][#]
FreeBASIC _  _  _  _  _  _ [#][#][#][#][#][#]
D _ [#][#][#][#][#][#][#][#][#][#][#]
Go _  _  _  _  _  _  _  @  _  _  _  _ 
Fortran _ [#][#][#][#] _  _  @  @  @  @  @ 


Legend

  •  O  Official GNOME Binding
  • [#] Supported
  •  @  Partially Supported
  •  _  Unsupported

Among unsupported languages, it is surprising that Ruby and PHP languages (13th and 5th most popular languages according to Tiobe programming language ranking [3]) are not supported bindings.

But, apart from the C++ binding, which is indeed the main development programming language on this project, which is the most popular binding ? Not much information is provided regarding this on the Internet, but initially, as one of the most popular programming languages, C++ and Java should be two of the most popular bindings. However, as an starting GTK developer, another binding always appears when looking on the Internet for information regarding GTK. That binding is pyGTK, So, from my ignorance, I would dare to assert that C++, Java, and Python should be the most used GTK bindings.

But why also Python? Well, as also a newbie in this programming language, I consider that the ease of programming with this programming language, as well as its increasing popularity in the Open Source scene, (obviously apart from Java, C/C++), help on this binding to be one of the most active ones.

But is Python on GTK really so easy? Well, a good example of this fact is the comparison of a GTK hello world provided by Tom Lee on his blog [4], Compared to other languages, it is shown that languages as Ruby, Perl or Python allows coding a "Hello World" application in much less words and lines that in other languages such as C:

- libgtk "Hello World" on C programming language:

#include <gtk/gtk.h>

int main (int argc, char **argv) {
  GtkWidget *window;
  gtk_init(&#038;argc, &#038;argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Hello, World");
  g_signal_connect (G_OBJECT (window), "delete-event", gtk_main_quit, NULL);
  gtk_widget_show_all (window);

  gtk_main();
  return 0;
}

- libgtk "Hello World" under Python programming language:

import pygtk
pygtk.require('2.0')
import gtk

window = gtk.Window()
window.set_title('Hello, World')
window.connect('delete-event', gtk.main_quit)
window.show_all()
gtk.main()

So, an eye must be kept on Python language binding, as it seems to be one of the most used and alive GTK bindings nowadays.

To summarize, no excuses around programming language used allowed to start programming visual interfaces on top of GTK, A wide bunch of  bindings are supported, and several of them around the most used and easy programming languages.

References:
[1] http://www.gtk.org/language-bindings.php
[2] http://tomlee.co/2008/01/gtk-hello-world-in-six-different-languages/
[3] http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
[4] http://tomlee.co/2008/01/gtk-hello-world-in-six-different-languages/

No hay comentarios:

Publicar un comentario