The eclectic musings of a bitter software engineer.
Ruby has certainly won me over as far as command-line scripting is concerned, but I want to do more than that. Apart from wanting to write web apps with it (which I'll probably discuss in a later post), I also want to use Ruby to write small, cross-platform GUI applications. So I spent a good deal of my free time last week doing just that, and found it to be at times rewarding and at times incredibly frustrating.

There's a huge selection of GUI bindings for Ruby, allowing you to work with a wide variety of GUI toolkits. Unfortunately, most of these toolkits were intended to be used by C or C++ developers. As a result their APIs tend to be stodgy and, well, C-like, rather than Ruby-like, which is annoying since it can effectively suck the joy out of using Ruby.

That said, they're not all bad; but none of them is all good either. Here's a brief collection of thoughts on each of the toolkits I investigated.

Tk

The crotchety old man of cross-platform GUI toolkits. Took one look and ran away screaming. The API is a badly-documented mess, the widgets are non-native and ugly, and everyone who's used it seems to hate it. Screw that.

FOX

I want to like FOX. Its Ruby API, provided by FXRuby, is good and well-documented, but FOX itself is a young project, and it shows. It seems to be developed primarily by one person, which is okay except that this person doesn't have access to a Mac OS X system and thus can't provide an OS X port. For me, this is a killer: Windows and OS X are my primary targets, followed by FreeBSD and Linux.

wxWidgets

A very stable, very mature toolkit with a good selection of widgets. Its most appealing feature is the fact that it uses native widgets whenever possible, thus ensuring a consistent look and feel with other applications on each platform. Furthermore, wxWidgets has excellent support for all the platforms I care about.

Unfortunately, the API is very C++-oriented, and the bindings provided by wxRuby do almost nothing to make it more Rubyish. What's more, WxRuby has no documentation aside from a virtually useless auto-generated class and function list. They seem to expect developers to use the wxWidget API reference, which is, admittedly, well-written and very complete. However, WxRuby inexplicably leaves out a surprising number of API functions and, even more inexplicably, sometimes uses function signatures and constant names that differ from those of wxWidgets, occasionally even going so far as to change the actual purpose of a function. The result is a muddled mess, even though everything seems to work well if you actually take the time to cross-reference the wxWidgets API documentation with the WxRuby source code to figure out what you should be doing.

GTK+

By far the easiest to use of all the toolkits I looked at, which is due in no small part to Glade, a free UI designer that makes it a piece of pie to throw together a GTK+ GUI quickly with very little effort. The API bindings provided by Ruby-GNOME2 are excellent as well, and mostly do things in the Ruby Way™. The Ruby-GNOME2 project also provides excellent documentation and tutorials.

Unfortunately, GTK+ has its drawbacks. Windows support isn't bad, and even uses native widgets in many places under Windows XP, but it requires a hefty set of runtime libraries. Unix support is excellent, of course, with the sad exception of -- you guessed it -- Mac OS X. It's possible to run GTK+ apps in OS X using the X Windowing System, but this means your app looks inconsistent and ugly compared to the rest of the OS X interface.

To sum up, I'm frustrated. I want to like FOX, but it's useless to me without OS X support. I think wxWidgets is superior to the others in almost every respect, except that it's also useless to me because wxRuby is crap. And GTK+, while easy and painless and an absolute joy to use, has crappy OS X support and requires annoying runtimes on Windows.

Nevertheless, I think I've pretty much decided to use GTK+ for now. I've already developed one complete application with it (which I'll release shortly), and I didn't find it at all painful, especially compared to wxWidgets, which, thanks to WxRuby, makes me want to kill things.

Comments

but there exists a Cocoa framework for doing native osx development in ruby. Basically, it makes all of the regular Cocoa classes and utilties available to one's ruby application, and also lets one use the excellent Interface Builder to do the gui design. Tons of fun- all the joys of working with the Cocoa API without having to worry about Objective-C (a great language, as far as C-derivatives go, but not nearly as much fun to work in as Ruby).

Sunday March 13, 2005 @ 01:27 PM (PST) Posted by bedrick

Sounds like I'd love it, except that it's not cross-platform. That's one more thing to add to my list of reasons why I need a Mac, though. :P

Sunday March 13, 2005 @ 02:34 PM (PST) Posted by wonko

You WANT the Mac. So SHINY. *waves blue LED pendulum-style* You're feeling very hip...

Sunday March 13, 2005 @ 03:24 PM (PST) Posted by Eilonwy

That's what the Mac mini was designed for. Just go pick one of them up. It'd work fine for developement of software while still not giving into their really expensive stuff.

Sunday March 13, 2005 @ 05:05 PM (PST) Posted by electrofreak0110

Qt?

Did you look into Qt? I don't know what the Ruby bindings look like but it has good tools (Qt Designer is like Glade) and it's pretty nice to work with in its native C++. I've lost track of the licensing situation on the various platforms, but I think you should be able to hit your target platforms with one version or another.

And what's wrong with stodgy C[++]-like APIs? They're what make programming fun! Not to mention C toolkit APIs are a completely different beast than C++ (or other object-oriented) toolkits. I think an object-oriented toolkit would take it as a personal affront that you group it in the same judgment about stodginess as a procedural toolkit, and vice versa!
Sunday March 13, 2005 @ 10:15 PM (PST) Posted by Zeus
I develop in Windows and Qt's development tools aren't currently available for Windows. They also have a really convoluted licensing scheme; any software I write using Qt must be released as open source under the GPL, unless I purchase a commercial license. Even though most of the software I write is GPLed, I don't want to tie myself to a restriction like that. What if I decide I want to switch to a BSD-style license? What if I decide I want to sell something I write? That said, I've used the Linux version of Qt Designer and I liked it a lot. I won't be using Qt unless they change their licensing scheme, though.

What's wrong with stodgy APIs? Gods! Use Ruby for a week and then ask me that with a straight face. There's nothing inherently wrong with them if you're using C, but when I'm using Ruby I want my APIs to be Ruby-like! I could have phrased that sentence better though; I didn't mean to imply that the C++ APIs had the same weaknesses as the C APIs, just that neither of them have the elegance of a purely Ruby API.

Sunday March 13, 2005 @ 10:49 PM (PST) Posted by wonko
There's a thread going on on the ruby-talk mailing list (aka comp.lang.ruby) that might be of use to you: http://rubyurl.com/Ji5Od

Personally, my vote's always going to be for a Cocoa solution, but that's just because I'm a rabid mac fan anything but Cocoa just feels... wrong....
Wednesday March 16, 2005 @ 12:01 PM (PST) Posted by Careo
Why don't u try Presenter from HCL Technologies
http://www.presenter5.com

It supports both C and C++
Friday July 22, 2005 @ 12:03 PM (PDT) Posted by Presenter
Have you looked at Ultimate++?

Of course I have no idea if they even have Ruby bindings- I just discovered the thing linked from Wikipedia's Qt entry.
Saturday May 12, 2007 @ 08:47 PM (PDT) Posted by Rob

Take a look at this article http://www.rubyinside.com/jruby-swt-future-cross-platform-ruby-desktop-app-development-298.html Of course,, it depends on jruby implementation :D

Thursday June 07, 2007 @ 01:53 PM (PDT) Posted by Humber

Thanks for the review...I looked into this before, specifically wxRuby, PHP-GTK and Perl-GTK.

wxWidgets sounded the best -- but I have not used it. GTK sucks on OSX, try getting anyone who isn't a geek to use it.

Monday July 23, 2007 @ 02:12 AM (PDT) Posted by Anthony ETtinger

I wonder how the writer feels two years later. I'm on Mac, but RubyCocoa look to complex for this non-programmer. I'm mainly interested in a personal solution so cross platform isn't important. I'm even considering Rails.

Saturday July 28, 2007 @ 10:02 AM (PDT) Posted by 12 34

Two years later, the author hasn't done much with Ruby GUI toolkits because, sadly, not much has changed. :/

Saturday July 28, 2007 @ 10:49 AM (PDT) Posted by wonko

Just came across this useful page, and what you say about wxRuby was true two years ago. But I saw your recent comment that 'nothing's changed' and thought I'd let you know that's not the case about wxRuby.

WxRuby now has a near-stable release with full method coverage within classes, full Ruby class reference documentation (based on the wxWidgets docs, but with the right method signatures and added Ruby examples). The core library remains a fairly straight port of the C++ lib, but there's an add-on package maintained by the same team called wxSugar, which makes the library much more Ruby-ish.

Tuesday July 31, 2007 @ 02:39 AM (PDT) Posted by Alex

I didn't realize that. Thanks for the clarification, Alex. I'll definitely take another look at wxRuby.

Tuesday July 31, 2007 @ 10:02 AM (PDT) Posted by wonko

Also have a look at the new Anvil framework built on top of Wx::Ruby. Check out my blog for examples: http://grasprubyonrails.com and the project at http://anvil.rubyforge.org. It's a very new framework, but holds a lot of promise. Also checkout the demo application being written on top of anvil: http://hamr.rubyforge.org.

Friday August 17, 2007 @ 09:06 AM (PDT) Posted by Lance Carlson

Tk isn't ugly. It's very practical to use. It's *very* easy to build a GUI without a GUI builder with it. It's just under Ruby that it looks ugly. Try Tk with the right language ( Tcl ) and it's a lot more integrated and has native look 'n feel using the theming extension Tile.

Wednesday August 22, 2007 @ 08:50 AM (PDT) Posted by anonymous

Wonko, Did you get a chance to look at wxRuby again? I'm interested in what it would take a write a cross platform Ruby app for Windows, Mac and maybe even Linux. Alan Sawyer

Monday September 10, 2007 @ 06:32 PM (PDT) Posted by Alan Sawyer

I did play around with wxRuby and wxSugar after Alex's comment, and it's improved tremendously since I wrote this blog post. wxSugar is absolutely lovely. The biggest weak point is still the documentation, but in spite of that, wxRuby is now my primary choice for writing cross-platform GUI apps in Ruby.

Monday September 10, 2007 @ 08:07 PM (PDT) Posted by wonko

Do you or anyone have an example of a GUI app running under Ruby via wxRuby, that I can play with to see how it functions under Windows and under Mac? I am pretty new to Ruby, so I'm trying to see if it makes sense for me to move from RealBasic to Ruby. Thanks for any help. Alan

Tuesday September 11, 2007 @ 05:12 AM (PDT) Posted by Alan Sawyer

Alan Sawyer: Why would you want to move from REALbasic?

All: Is it possible to create stand-alone wxRuby applications for the three major platforms: Windows, Linux and Mac OS X? For Python there is py2exe and other tools. Is there anything as good for Ruby?

Wednesday September 12, 2007 @ 08:05 AM (PDT) Posted by Alexei Vinidiktov

Not moving from it, but I want something that I can work on websites also with, and if I choose to go with RoR, why not learn and also use Ruby on Desktop. I like RealBasic at this point, but I really need something that I can do some website stuff in also. Alan

Wednesday September 12, 2007 @ 05:18 PM (PDT) Posted by Alan Sawyer

OK, I see your point, Alan. I'm more into Python and wxPython but I'm also keeping an eye on wxRuby. wxRuby appears to be greatly inspired by wxPython.

Sunday September 16, 2007 @ 08:54 AM (PDT) Posted by Alexei Vinidiktov

i think you need to reevaluate on the windows stuff

yes, you need ruby binary and ruby-gnome binaries, but other than that, once you HAVE this, it really works like a charm!

Wednesday January 02, 2008 @ 02:22 AM (PST) Posted by she

thanks for the really helpful analysis. It saved me a ton of time.

Friday February 15, 2008 @ 11:51 PM (PST) Posted by j

The poster of the comment that Tk is not ugly under Tcl is a fool. Tk is a piece of crap, just like this post says. There are plenty of better looking GUI toolkits around. Trash Tk, not worth the trouble.

Sunday March 02, 2008 @ 05:09 AM (PST) Posted by anonymous
I agree with this guy, Tk sucks. It might be easy to code but from all the apps that I’ve seen written in it (aMSN, tkgate, couple others that I can’t remember off-hand).

GTK+ is alright, Glade makes it much better but I find that I’m limited by it when I want to do certain things. When I Google for how to do it, sometimes I found forums saying I can’t.

wxWidgets is quite nice to work with, especially with programs like DialogBlocks.

Alexei: Ruby2Script might be what you’re looking for.
Wednesday March 26, 2008 @ 12:34 PM (PDT) Posted by IllegalCharacter

Forgot to finish my first paragraph. I meant to say mos tof the apps I’ve seen written in Tk don’t look so great. aMSN has started to look better, but I still find it’s not as good as even GTK.

Wednesday March 26, 2008 @ 12:36 PM (PDT) Posted by IllegalCharacter
Post a comment

Basic XHTML (including links) is allowed, just don't try anything fishy. Your comment will be auto-formatted unless you use your own <p> tags for formatting. You're also welcome to use Textile or Markdown.

Don't type anything here unless you're an evil robot:


And especially don't type anything here:

Copyright © 2002-2008 Ryan Grove. All rights reserved.
Powered by Thoth.