Ruby/Tk or mod_ruby or what?

Dear All,

 I am writing to ask if someone among the Ruby user base can address an

issue for me. I have begun to review Ruby after learning Java/Swing.
I found Java to be good enough, but alot of code to get things done. It
was not too painfull to learn. I read 3 books on Java / SWING and came
away able to write basic apps with a GUI. I decided that I wanted
something simpler, and cleaner to use. Something that I could also teach
to others in my group [ mostly Bourne Shell scripters ]. Ruby is nice in
the regard that it has a similar feel to shell scripting. Then I decided
that since Tk was the default GUI for Ruby - sort of - and I remembered
that I made some simple Tcl/Tk gui’s before, I would use Tk again. Fine.
But then I find out that the “interface” to Tk is very
different…8-(. Then I start to look for docs on how to use it
… you know, like a tutorial.
I apologize in advance - a good tutorial is not a small project…
but the “tutorials” for Ruby/Tk are SAD. In fact, it would be more
accurate to say that there aren’t any. Maybe I should look at using some
sort of ruby-to-web-browser interface… But to tell someone to “go read
a Perl/Tk book” is doing Ruby a disservice. Some people will think
"…I might as well use Perl then". Below is an approximation of what I
think would be a help. If some of you more experienced with Ruby/Tk,
maybe we can band together and put out the beginings of a
tutorial…like what is below:

[ This is a shade long but I want to show the kind of progression that is
needed - please be patient ]

One that ( like other GUI tutorials ) starts out by saying - Ok. Here is
the root window. It does this.
you put things in the root window. Here is a window with a button.
Notice that when you run in Unix / X , that even though you copied the
example WITH a title:
#!/usr/bin/env ruby

require 'tk’
root = TkRoot.new() { title “Click the Button” }

Tk.mainloop

you will not see the title. Here is WHY: Yada Yada Yada.
Here is the same code with x y z.

A button usually has an action associated with it. Sometimes people will
refer to the ACTION as a "CALLBACK."
Here is how it works.

Now let’s talk about a script that has a text entry. When you enter a
word into the text entry widget, it will convert the word to UPPER CASE.
Here is the code… WITH COMMENTS 8-). Notice that we put the
widgets in a Frame. A frame is for …

Now let’s make it a 2 field Name - Phone number type of GUI - no lookup
features - that is the Next version in Chapter 3.
For now we will just add another text field and OK & Cancel buttons.
[End]

  With Tk so prevalent,  why isn't there something like this for Ruby.

Every BOOK I have seen on Amazon got ONE chapter for Tk. Not even 15
pages. Most Tcl/Tk books have 50+ pages…

Ok, guys… I’m done for now. I will help produce one if I can get
the help I need to learn it… no sense in just complaining… :sunglasses:

Thanks,
Greg

Dear All,

 I am writing to ask if someone among the Ruby user base can address an

issue for me. I have begun to review Ruby after learning Java/Swing.
I found Java to be good enough, but alot of code to get things done. It
was not too painfull to learn. I read 3 books on Java / SWING and came
away able to write basic apps with a GUI. I decided that I wanted
something simpler, and cleaner to use.

And something that will run with less than a gigabyte of memory, maybe?
(sorry … for some reason I just can’t pass up a chance to mention
Java’s bloatedness)

that I made some simple Tcl/Tk gui’s before, I would use Tk again. Fine.
But then I find out that the “interface” to Tk is very
different…8-(. Then I start to look for docs on how to use it
… you know, like a tutorial.
I apologize in advance - a good tutorial is not a small project…
but the “tutorials” for Ruby/Tk are SAD. In fact, it would be more
accurate to say that there aren’t any. Maybe I should look at using some
sort of ruby-to-web-browser interface… But to tell someone to “go read
a Perl/Tk book” is doing Ruby a disservice. Some people will think
“…I might as well use Perl then”. Below is an approximation of what I
think would be a help. If some of you more experienced with Ruby/Tk,
maybe we can band together and put out the beginings of a
tutorial…like what is below:

I’m interested in working on this–in fact I made a start at writing one
myself–though I was aiming at a bit more advanced level, because I
thought the Tk chapter in the pickaxe book was a good introduction. But
perhaps a raw-beginner tutorial would be useful, too.

Now I have to confess that I haven’t done a lot of work with Ruby/Tk per
se, because I’m fairly new to Ruby, but I have been working with Tk in
its Tcl and Python incarnations (mostly the latter) for 4 years or so.
I’m also now the maintainer of the Ruby/Tk Demos package; the former
maintainer, Jonathan Conway, suggested to me that they might make a good
basis for a tutorial. I’m undecided about that. For one thing, I find
their look and feel to be very “old school”–that’s a purely intuitive
statement that just popped into my head, so don’t ask me to explain–but
I find them a bit ugly. I guess that means it’s up to me to make them
less ugly ;-). They’re also designed to showcase the capabilities of
the toolkit, which is a somewhat different problem from teaching people
how to program with it.

So anyway, I agree there should be a tutorial, and I’m more likely to
actually do something about it if I don’t have to do all the work
myself. What role would you see yourself taking on this project?

···

On Fri, Sep 27, 2002 at 02:43:26AM +0900, GBanschbach@sandata.com wrote:


Matt Gushee
Englewood, Colorado, USA
mgushee@havenrock.com

Hi,

I think this is because unlike Tcl, with its definite Tk companion, there
is currently no concensus on the GUI tool for Ruby. Someone has brought
this up before. Tk seems not the first choice of GUI for Ruby.

In fact, if we all Rubyist’s can agree on the GUI tool for Ruby and make
it really good, some people have committed that they will totally
leave Java and its Swing… :slight_smile:

Regards,

Bill

···

===========================================================================
GBanschbach@sandata.com wrote:

   I apologize in advance - a good tutorial is not a small project....

but the “tutorials” for Ruby/Tk are SAD. In fact, it would be more
accurate to say that there aren’t any. Maybe I should look at using some
sort of ruby-to-web-browser interface… But to tell someone to “go read
a Perl/Tk book” is doing Ruby a disservice. Some people will think
“…I might as well use Perl then”. Below is an approximation of what I
think would be a help. If some of you more experienced with Ruby/Tk,
maybe we can band together and put out the beginings of a
tutorial…like what is below:

GBanschbach@sandata.com wrote:

But then I find out that the “interface” to Tk is very
different…8-(. Then I start to look for docs on how to use it
… you know, like a tutorial.
I apologize in advance - a good tutorial is not a small project…
but the “tutorials” for Ruby/Tk are SAD. In fact, it would be more
accurate to say that there aren’t any.

You don’t explicitly state which Ruby/Tk tutorial(s) you looked at, but
if I read between the lines it sounds like you’re only considering the
Ruby/Tk chapter in “Programming Ruby”. Here is one set of Ruby/Tk
tutorials by Kero that might be good for you:

http://httpd.chello.nl/k.vangelder/ruby/learntk/index.html

Hope this helps,

Lyle

Hi, I think this is because unlike Tcl, with its definite
Tk companion, there is currently no concensus on the
GUI tool for Ruby. Someone has brought this up before.
Tk seems not the first choice of GUI for Ruby.

> In fact, if we all Rubyist's can agree on the GUI tool
> for Ruby and make it really good, some people have
> committed that they will totally leave Java and its
> Swing.... :)

A suggestion could be to have Ruby interact with a widget server,
i.e. a seperate process, linked to a widget toolkit library, and
recieving high level widgets request and replying with high level
widgets events. [oldtimers might remember that NeWS worked this way
around 1993]

For example, my opensource [GPL-ed] GUIS gtk2 server (which actually
is currently using lua scripts for input [widget requests] -but I
might switch to Ruby- and XML or Sexpr lispy syntax for output [widget
event replies].

It is not only to push my little GUIS, but I really think that GUIs
don’t necessarily belong to interpreters. (this is also the way
CommonLisp interfaces to Motif or GTK, thru a widget server).

I just switched hosting company and updated my DNS for my domain, so
both my email & home pages might not work till tomorrow.

Guis is described on Best Open Source Mac Software Development Software 2024 and I put a
mirror on http://www.tunes.org/~basile/guisdoc.html with software on
http://www.tunes.org/~basile/guis-0.2.tar.gz - however after october
1st 2002 be nice to use the usual adress
GUIS - a GUI widget server release 1.6 on Thu, 30 Dec 2004 14:14:05 +0100 prcsproj 1.62 and not the mirror I
mentioned before.

Of course one could write a Qt3 widget server, and several alternative
approaches (XUL, PicoGui, etc…) are referenced on my guisdoc.html
page.

Should people consider writing other widgets server, please take into
account that they should be usable from several languages, not only
Ruby!

Regards.

PS: use my alias below to reply by email

···

Basile STARYNKEVITCH Basile STARYNKEVITCH
email: basilestarynkevitchnet
alias: basiletunesorg
8, rue de la Faïencerie, 92340 Bourg La Reine, France

Matt Gushee mgushee@havenrock.com wrote in
news:20020926180906.GD6382@swordfish:

So anyway, I agree there should be a tutorial, and I’m more likely to
actually do something about it if I don’t have to do all the work
myself. What role would you see yourself taking on this project?

I once asked in .java.advocacy if someone could demonstrate a
GUI java app that wasn’t painfully slow… I was recommended two, one of
which was jEdit, which I have since tried and its just as slow as
anything else I’ve seen :frowning: from my beginner pov, since at the
fundamental, machine code level, there is no concept of a class, anything
that is compiled down should have such concepts removed - since java
still has a class concept post-compilation, the compilation stage doesn’t
seem to have much purpose…

Does the concept of a class exist in ruby, once a program has been
reduced to the decision-tree level? (apologies if I have this ludicrously
wrong)

···


Jonathan Dowland

Hi,

No problem, Basile, someone has written an interface between Ruby and Lua
:slight_smile: (http://domingo.dad-it.com/ruby-lua.whtm) But I don’t know the
details in interfacing Ruby, Lua, and GUIS.

Regards,

Bill

···

=======================================================================
Basile STARYNKEVITCH <basile+NO@spam+starynkevitch.net.invalid> wrote:

For example, my opensource [GPL-ed] GUIS gtk2 server (which actually
is currently using lua scripts for input [widget requests] -but I
might switch to Ruby- and XML or Sexpr lispy syntax for output [widget
event replies].

That’s an interesting idea. How would it affect performance? Or more
precisely, responsiveness to user-generated events? Sluggish GUIs seem
to be acceptable to many developers (or perhaps they don’t notice
because they have high-end workstations), but can make end users’ lives
miserable. That’s why, for example, I don’t use jEdit, despite its
magnificent feature set. It’s just too damn slow; even with JDK 1.4, its
performance is barely adequate on a Celeron 400 with 192 Megs of RAM.

···

On Fri, Sep 27, 2002 at 04:36:21AM +0900, Basile STARYNKEVITCH wrote:

> In fact, if we all Rubyist's can agree on the GUI tool
> for Ruby and make it really good, some people have
> committed that they will totally leave Java and its
> Swing.... :)

A suggestion could be to have Ruby interact with a widget server,
i.e. a seperate process, linked to a widget toolkit library, and
recieving high level widgets request and replying with high level
widgets events. [oldtimers might remember that NeWS worked this way
around 1993]


Matt Gushee
Englewood, Colorado, USA
mgushee@havenrock.com

“Jon Dowland” jon@frag.ord wrote in message
news:Xns9297C6A9D5FE7jonfradorg@193.38.113.46

Matt Gushee mgushee@havenrock.com wrote in
news:20020926180906.GD6382@swordfish:

So anyway, I agree there should be a tutorial, and I’m more likely to
actually do something about it if I don’t have to do all the work
myself. What role would you see yourself taking on this project?

I once asked in .java.advocacy if someone could demonstrate a
GUI java app that wasn’t painfully slow… I was recommended two, one of
which was jEdit, which I have since tried and its just as slow as
anything else I’ve seen

Eclipse isn’t painfully slow - it’s just painfully large. 18MB compressed
download no source, no java dev. support. Just the eclipse basic framework.
(But then MS Dev.Studio is also large).

Mikkel

Hi, No problem, Basile, someone has written an interface
between Ruby and Lua :slight_smile:
(http://domingo.dad-it.com/ruby-lua.whtm) But I don’t
know the details in interfacing Ruby, Lua, and GUIS.

Actually I could even make it simpler: the glue between Lua (or maybe
Ruby) and my GUIS is a big 76KLOC C file machine generated (by a
generator which I coded in about 1200 lines of CommonLisp). So I would
only have to change the generator to use Ruby (and interface it to
most of the big GTK2 API). However, the interpreter (and the C glue
code) is embedded inside a C program (which calls gtk_input_add_full
on the request pipe and then gtk_main_loop, waiting for requests on
the pipe; then it calls the interpreter for each request line).

So I could (and actually I probably would like to) replace Lua by Ruby
in GUIS if I knew exactly how to reliably embed Ruby inside a C
program. The whole point of GUIS is to listen for highlevel widgets
requests which actually are strings passed to an interpreter
(glued to the GTK2 toolkit).

The main issue for me in switching in GUIS from Lua to Ruby is that I
don’t fully understand how to embed reliably Ruby inside an
application (and I asked on this newsgroup). I also would like Ruby to
avoid needing any external initial script file, so that GUIS continue
to be self contained.

Another issue in switching from Lua to Ruby in GUIS is: is such switch
worth it? Are there really developers interested in having a GTK2
widget server capable of understanding requests as Ruby commands? If
someone is actually interested in this (a Ruby listening GUIS GTK2
widget server), please email me (use the alias email below please
until 1st of october 2002).

···

Basile STARYNKEVITCH Basile STARYNKEVITCH
email: basilestarynkevitchnet
alias: basiletunesorg
8, rue de la Faïencerie, 92340 Bourg La Reine, France

Is there a way to invoke a method when references to an object have gone
out of scope?

I did use and code with NeWS around 1993 on a Sun3/160 [or perhaps a
Sun4/110] computer (which is much slower than your Celeron400). It was
a bit slow (the Sun was slow for todays’ standards) but it was usable.

Today we use Javascript in web pages, and it usually run ok. (and
Javascript is usually slower than Ruby or Lua interpreters).

So I think that for the usual interfaces that people use, an
interpreted approach is acceptable. After all, most of the used code
is the widget toolkit coded in C. And emacs is acceptable even on a
low range computer (provided you’ve got enough memory for it).
I even heard that Microsoft Word (which I didn’t use since 10 years
ago, except on one occasion) is internally interpreted.

I did not try jedit (because there is no debian package for it, and I
am lame to download it). I heard that Swing is a slow toolkit.

Actually, I do think that the ideal solution could be a widget server
with an incremental compiler (like JIT) in it. But I don’t have the
resources to code it.

On a more general topic, I do less and less understand why in 2002
developers still type their code in ASCII textual files under
Emacs. They should type into a more fancy -perhaps hypertextual-
system, with incremental syntax & semantic checks. (Why are today
programming languages still file & Ascii based, and not using more
fancy and interactive interfaces? You might read interesting dreams on
www.tunes.org…)

(If people want to reply be private email please use the alias below
till october 1st 2002).

···

On Fri, Sep 27, 2002 at 04:36:21AM +0900, Basile > STARYNKEVITCH wrote:

“William” == William Djaja Tjokroaminata
billtj@z.glue.umd.edu writes:

In fact, if we all Rubyist’s can agree on the GUI tool
for Ruby and make it really good, some people have
committed that they will totally leave Java and its
Swing… :slight_smile:

>  A suggestion could be to have Ruby interact with a widget
> server, i.e. a seperate process, linked to a widget toolkit
> library, and recieving high level widgets request and replying
> with high level widgets events. [oldtimers might remember that
> NeWS worked this way around 1993]

> That's an interesting idea. How would it affect performance?
> Or more precisely, responsiveness to user-generated events?
> Sluggish GUIs seem to be acceptable to many developers (or
> perhaps they don't notice because they have high-end
> workstations), but can make end users' lives
> miserable. That's why, for example, I don't use jEdit,
> despite its magnificent feature set. It's just too damn
> slow; even with JDK 1.4, its performance is barely adequate
> on a Celeron 400 with 192 Megs of RAM.

Basile STARYNKEVITCH Basile STARYNKEVITCH
email: basilestarynkevitchnet
alias: basiletunesorg
8, rue de la Faïencerie, 92340 Bourg La Reine, France

That’s an interesting idea. How would it affect performance? Or more
precisely, responsiveness to user-generated events?

X terminals have existed since much slower processors and networks.

Microsoft Remote Desktop works amazingly well over an ADSL VPN connection. I
could actually use a Wacom drawing tablet. Network roundtrip best case 40
ms, avg. 100 ms.

Sluggish GUIs seem
to be acceptable to many developers (or perhaps they don’t notice
because they have high-end workstations)

I agree - but it’s down to crappy code, not the network connection.

Networked or not, it is important that the widgets are implemented
efficiently and can handle a lot themselves.

Notice how FreeRide has separated GUI componets from GUI renderers. The
FreeRide databus connection to rendering objects could be networked.

Mikkel

That’s an interesting idea. How would it affect performance? Or more
precisely, responsiveness to user-generated events?

X terminals have existed since much slower processors and networks.

That’s true, but in those days people were using Athena widgets or raw
Xlib, weren’t they? ‘Modern’ GUI toolkits like GTK and Qt are
considerably heavier. But I don’t know how much difference that makes.

Microsoft Remote Desktop works amazingly well over an ADSL VPN connection. I
could actually use a Wacom drawing tablet. Network roundtrip best case 40
ms, avg. 100 ms.

Is that a good example? Microsoft, I hear, uses a lot of
platform-specific hacks to optimize their GUI performance.

Not trying to pick a fight, just wondering.

···

On Fri, Sep 27, 2002 at 05:37:04AM +0900, MikkelFJ wrote:


Matt Gushee
Englewood, Colorado, USA
mgushee@havenrock.com

Not immediately, I guess, as Ruby uses mark-and-sweep gc instead of
reference counting. If you can wait, and write Ruby in C, you can just
put the “destructor” in the corresponding free() function.

Regards,

Bill

···

==================================================================
Stathy G. Touloumis stathy.touloumis@edisonaffiliates.com wrote:

Is there a way to invoke a method when references to an object have gone
out of scope?

Microsoft Remote Desktop works amazingly well over an ADSL VPN
connection. I
could actually use a Wacom drawing tablet. Network roundtrip best case
40
ms, avg. 100 ms.

Is that a good example? Microsoft, I hear, uses a lot of
platform-specific hacks to optimize their GUI performance.

Not trying to pick a fight, just wondering.

I actually think it is a good example becuase it does illustrate what can be
accomplished by having a good local widget engine running against remote
application logic. A dedicated widget server would do an even better job
because the application knows it is being remoted. I have no recent
experience, but I reckon X-Windows should also work well over a VPN/ADSL
network setup.

When I saw Remote Desktop I said “Finally MS made something that is really
really cool which actually works all the time” A month later it stopped
working of course - but now I got a service pack and it rocks again - so in
terms of typical Microsoft network performance it is not a good example.

If take you VNC, Microsoft platforms do not work very well. X supposedly
works a lot better because VNC hooks into X while it must bitmap copy
Windows. So I guess X / VNC is comparable to Windows Remote Desktop in terms
of native platform hooks. (BTW: its quite fun to hook three VNC sessions up
in a circular fashion - as expected you get infinite windows :slight_smile:

What would happen if you created a QT widget server and published this under
GPL - then you both get a Ruby API to QT and the applications need not
conform the QT free license because the app is not a part of the widget
server app. Dowside is that QT doesn’t have a Windows licence that works.

Anyway - a widget server would make it easier to make both cross platform
GUI and croos toolkit GUI.

I believe the future applications will not be browser based but server
controlled desktop GUI applications. In this light I think a widget server
is a really good idea. Just make the protocol fast and light - no bloated
XML. Would be nice with some ASN1 protocol logic.

Mikkel