From: Richard Cole Date: 2005-04-04T09:28:39+09:00 Subject: Re: Getting Ruby approved >>>I see. What do you consider the most difficult (GUI-wise) to do in >>>Ruby that is easy in Tcl/Tk? Maybe a little list with 3 items? :-) >>> >>> >>i guess if you know the api in question nothing is 'difficult' in >>ruby. >> >>with tcl/tk it how little typing i have to do. the tkblog interface is >>about 20 mostly short lines of code. which took me about two minutes >>to type up. >> >>with the example i posted before: >> >>button .b -text "quit" -command{exit} >>pack .b >> >>it puts up a window, with one button. click on the button it exits. >>what's the equivalent of that in the various ruby gui api's? >> >> > >In my own library I use something like: > >require 'gr/gtk_rules' >GR.app{|w| w.hpack GR::GRButton.new('quit').sc{ GR.quit } } > >I think this could be reduced even further to > >require 'gr/gr' >app{|w| w << button('quit'){ quit } } > >Or something like that, but I'm not going to do it yet. I have a new >project starting tomorrow and after that I have so much to work on >still -- like developing one thing or two for the Wee Web-Framework... >Anyway, I think people would be better off by using their own custom >Ruby library for GUI programming. :-) > > I don't quite understand that last point. Do you mean that everyone would be better off writing their own GUI library because currently the current public offerings are unlikely to match application requirements? I've found Ruby Qt pretty good, although it often produces a segfault if you have bugs, and I hadn't seen the GR/Gtk example before :) That's a nice couple of examples. Both examples show the use of blocks/lambda expressions/closures (whatever those funky things are are in Tcl) for GUI programming. Once you've seen blocks you can't live without them. They make writing GUI's using Java and SWT painfull by reflection on how much easier it could be if you didn't have to make anonymous innner classes just to create a block. I sometimes end up coding in TclTk because that's the library that I know better and there's a great book by Matt Welch that explains the API in details. What are the best books for Ruby GUI programming? Many programming environments, e.g. TclTk and Ocaml create man pages to document the core library. Has anyone done this Ruby? But I must admit that I prefer Ruby to Tcl because Ruby has more powerful abstractions (the whole smalltalk thing it has going) while Tcl is largely a really cool trick involving string manipulation. I regard them as both pretty clean languages (Ruby's going to get better with Ruby 2.0 isn't it), but they are also both pretty expensive in terms of execution time. Ruby is so nice that I'd like to code matrix stuff in it, but its just way too slow, so you have to use a C-wrapper for matrix manipulation :( regards, Richard.