LWN.net Logo

XDC2012: Programming languages for X application development

XDC2012: Programming languages for X application development

Posted Oct 4, 2012 6:04 UTC (Thu) by flewellyn (subscriber, #5047)
Parent article: XDC2012: Programming languages for X application development

I've found that, as far as GUI development goes, the really tedious part of coding is laying out the controls using a programming language. That's not really what they're for. I've often wished for something akin in spirit to HTML+CSS for layout and visual appearance, with the ability to tie code to events. It doesn't have to be HTML, of course (although I note the success of "widget frameworks" like Dashboard on OS X that use HTML, CSS, and Javascript on the desktop), but some kind of domain-specific language that is declarative, flexible, and easy to work with, would be great.

If the toolkits had a means of, say, importing a declarative description of a GUI layout, and generated the resulting code to draw the controls, with my own code called from callbacks as defined in the declaration...that would probably speed things up enormously.


(Log in to post comments)

XDC2012: Programming languages for X application development

Posted Oct 4, 2012 8:29 UTC (Thu) by gidoca (subscriber, #62438) [Link]

That sounds exactly what QML is supposed to be, though I haven't tried it yet myself.

XDC2012: Programming languages for X application development

Posted Oct 4, 2012 10:19 UTC (Thu) by boudewijn (subscriber, #14185) [Link]

Qt Designer provides visual laying out of controls. It generates xml that, yeah, is translated into C++ that puts the controls in a layout. I wouldn't call it a code generator, even though it's possible to add some basic signal-slot connections in Designer.

Creating gui's in QML on the other hand is a more manual process. But it's awe-inspiringly productive, even if you have to mix the json-like gui description with little snippets of javascript and backend objects in C++. It feels a bit weird to start with, but after a certain point, QML makes developers really happy.

Then again, calling for application development in high-level languages is not something new in 2012. Python and Qt have been a great option for developing gui apps since 1999 at least, that's thirteen years ago. And it's used today, used for big, commercial applications like Nuke.

Personally, I've found very little difference in developer productivity between Qt/C++ and Python + Qt. Using QML does increase productivity quite a bit. Writing a gui application in Java is a horrible experience -- but I have to admit that my knowledge is not current anymore, I stopped doing that six or seven years ago.

I have the feeling that Bart Massey is maybe a bit too much out of touch with developments in the past decade to present on this topic.

XDC2012: Programming languages for X application development

Posted Oct 6, 2012 5:09 UTC (Sat) by lamawithonel (subscriber, #86149) [Link]

PyQt was my first thought. I've never actually tried it, but I've encountered enough quality applications using it that I would give it a go if I were starting a new project. A few examples I can think of off hand: the Eric IDE, HPLIP, the Calibre ebook manager, and Amarok, the KDE audio player.

XDC2012: Programming languages for X application development

Posted Oct 6, 2012 12:32 UTC (Sat) by hummassa (subscriber, #307) [Link]

Amarok is written in C++...
$ sloccount amarok-2.6.0/
...
Totals grouped by language (dominant language first):
cpp:         213236 (98.15%)
ansic:         2595 (1.19%)
xml:           1267 (0.58%)
ruby:            62 (0.03%)
python:          54 (0.02%)
perl:            27 (0.01%)
sh:              10 (0.00%)
...

XDC2012: Programming languages for X application development

Posted Oct 4, 2012 23:16 UTC (Thu) by dashesy (subscriber, #74652) [Link]

Even Qt widgets support some CSS

XDC2012: Programming languages for X application development

Posted Oct 4, 2012 8:49 UTC (Thu) by pabs (subscriber, #43278) [Link]

If you are using GTK+, then you want to look at GtkBuilder (and the GUI for creating them is glade).

XDC2012: Programming languages for X application development

Posted Oct 4, 2012 14:04 UTC (Thu) by debacle (subscriber, #7114) [Link]

Yes, Glade is really nice, esp. with Python, but also with C. I used it some time back, before the existence of GtkBuilder, but with the obsolete libglade. For cross platform development (= MS compatibility) I think that wxWindows (and wxPython) are easier to deploy.

XDC2012: Programming languages for X application development

Posted Oct 12, 2012 20:00 UTC (Fri) by oak (guest, #2786) [Link]

While Glade is OKish, it forcing the UI creation to happen in the widget hierarchy root -> leaf direction makes the process of creating the UI almost as painful as creating the UI manually and changing of the resulting UI maybe even harder..

Qt GUI design tool has a really nice feature; you can add the basic widgets first and only as last thing drag the containers over their child widgets, in the way that makes the UI most scalable.

XDC2012: Programming languages for X application development

Posted Oct 4, 2012 9:30 UTC (Thu) by alankila (subscriber, #47141) [Link]

Many people seem to agree. Android also has taken this XML-layout model, although to wire up the events you will need to find the controls from the layout tree and add the relevant event listeners that you need.

The key, I think, is that it's much easier to write tools to display and edit such XML documents, so interface designers become relatively sane to write. Contrast, for instance, to the problem of parsing a (possibly) hand-edited source file and working out how the controls are laid out there, and then allowing editing of it. I think it's not going to happen.

Android tools

Posted Oct 5, 2012 12:19 UTC (Fri) by man_ls (subscriber, #15091) [Link]

Exactly, I thought grand-parent was pining for Android tools too. The upside is that the layout design tool uses Eclipse and so it is tightly integrated with your code. The biggest downside is exactly the same: a monolithic IDE is a bit hard to use for graphical designers, and these days it hurts a little bit when people drive me away from my vim. (Also when those damn kids get close to my lawn, and likewise when the weather changes, but so it is with age.)

The idea is cool though, and much easier to use than HTML content creation tools (like e.g. Coda + Chrome). Often it is easier to touch the underlying XML file than delve in the endless lists of attributes, and the visual interface can do weird things; but you get to see the results of the tinkering in almost real time, and both options (graphical and text editing) are available.

XDC2012: Programming languages for X application development

Posted Oct 4, 2012 13:03 UTC (Thu) by dskoll (subscriber, #1630) [Link]

If the toolkits had a means of, say, importing a declarative description of a GUI layout, and generated the resulting code to draw the controls, with my own code called from callbacks as defined in the declaration...that would probably speed things up enormously.

Such technology existed in the early 1990's with the Tk toolkit. Its pack and place and later grid geometry management commands made laying out controls a breeze. Furthermore, as windows are resized, the controls reflow naturally and intuitively.

I did my first GUI programming under Tcl/Tk and it was absolute bliss. When I see the horrible things people need to do to get going with Gtk+ or Qt, I realize how lucky I was that Tk hid all the nasties.

Unfortunately, Tcl/Tk has fallen out of favor. :( Just because Tcl is a bit idiosyncratic doesn't mean we should forget all the great advances made by Tk.

XDC2012: Programming languages for X application development

Posted Oct 4, 2012 20:32 UTC (Thu) by sytoka (subscriber, #38525) [Link]

I used one time tcl/tk and that was horrible... I switch to Perl/Tk and program look quite good.

Tk can be use by many scripting language.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds