Getting Ruby approved

J

Joao Pedrosa

Hi,

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. :)

Cheers,
Joao
 
D

Douglas Livingstone

Anyway, I think people would be better off by using their own custom
Ruby library for GUI programming. :)

I would love to make GUI in Ruby as easy as Rails :)
 
R

Richard Cole

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.
 
R

Richard Dale

Richard said:
I've found Ruby Qt pretty good, although it often produces a segfault if
you have bugs,
Do you mean QtRuby, and which version have you tried? I fixed quite a few
bugs relating to programming errors giving seg faults some months ago.

-- Richard
 
B

Booker C. Bense

[1]- instead of everything being a list, everything is a string.
This is both TCL's strength and weakness.

cameron laird can correct me if i'm wrong but i think the 'everything
is a string' description hasn't applied to tcl for awhile now...(v8.0+
?)
http://home.cogeco.ca/~tsummerfelt1
telnet://ventedspleen.dyndns.org

_ That's true and I really haven't bothered to keep current with
tcl. Mea Culpa...

_ Booker C. Bense
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top