Ruby vs. TCL/TK?

I actually have used Tcl/Tk a lot more than Ruby. I’m actually starting to
use Ruby some more to see how I like it compared to Tcl/Tk. I can give you
my preliminary pro/con list with a few qualifiers: (1) I am not an expert
programmer, (2) I am still pretty new at Ruby, (3) I am not very
experienced, nor a huge fan of OO programming.

With those points in mind, here are IMHO some pros/cons:

Tcl/Tk

···

-----Original Message-----
From: christopher.j.meisenzahl@citicorp.com
[mailto:christopher.j.meisenzahl@citicorp.com]
Sent: Monday, August 19, 2002 10:36 AM
To: ruby-talk@ruby-lang.org
Subject: Ruby vs. TCL/TK?

I’ve just started playing w/ Ruby and like it quite a bit so far.

But I was wondering, I know that TCL/TK has a large following
out there. Is
anyone here a convert from TCL/TK to Ruby? If so, why? What
do you consider the
relative advantages/disadvantages of each?

Is it a fair comparison?

Can GUI apps be created with Ruby as easily as with TCL/TK?

Interested in your thoughts,

Christopher

Christopher J. Meisenzahl CPS, CSTE
Senior Software Testing Consultant
Spherion
christopher.j.meisenzahl@citicorp.com


Pros:

  • Has very mature, portable, built-in GUI library.
  • Has lots of additional libraries for just about everything you could want
    (smtp, database, COM, etc.) that are usally available in binary form for the
    two platforms I use most (Windows and Linux).
  • Has the ability to package code into a fairly small exe on Windows using
    GREAT tools like Freewrap and Tclkit.

Cons:

  • Syntax is quirky.
  • Can’t pass arrays (hash in Ruby) to functions.
  • When building Guis, sometimes I feel the code gets kind of cluttered with
    tons of widget commands followed by tons of pack commands. This is probably
    more due to my deficiencies as a programmer than any inherent fault of
    Tcl’s. One reason I am trying Ruby is to see if it’s built-in OO lets me
    produce cleaner code when I am building moderately complex Guis.

Ruby

Pros:

  • Very clean syntax that seems to be pretty intuitive.
  • Built in support for lots of libraries (smtp, ole, os level, etc.). To
    me, it strikes a good balance between the “kitchen sinkness” of Python and
    the “minimalist model” of Lua.
  • Can pass different code structures to functions and back.
  • OO layer makes more sense to me than in any other language I have looked
    at (remember I don’t know much about OO).

Cons:

  • Sometimes hard to find additional libraries that are precompiled with the
    matching compiler (mingw, cygwin, etc.) of your Ruby interpreter.
  • Gui libraries are not as well integrated into the language as Tcl/Tk, nor
    as well documented.
  • Not as easy to create a small exe on Windows of your completed app.

So those are my initial thoughts on the comparison. I am attempting to
duplicate a Gui Windows app in Ruby that I wrote in Tcl/Tk. I am using the
compiled mingw ruby that you can find at ruby-lang.org. You can find
additional libraries there like ruby-gtk and sqlite that are already
compiled for mingw. I would like to thank WATANABE Hirofumi for maintaining
these. When it comes time to distribute my app, I intend to slowly delete
files from the ruby distribution until I come up with the bare minimum of
files (hopefully not much more than a couple of mb) that I need to include
in my distribution. It’s crude and not as pretty as creating an exe, but it
should work.

Anyway, sorry for the long post.

Jamey.

CRIBBSJ wrote:

(I replied to this, but didn’t notice that it went to OP only.
So, this is my attempt to recreate my comments.)

Tcl/Tk

  • Syntax is quirky.

To me, the syntax is regular and constant:

command  arguments

Group things with { }
Evaluate things with [ ]
No need for dots, parens, commas, semicolons, quotes, double-quotes,
indenting white space, etc. to mess it up. (Although some of those
can be used.)

  • Can’t pass arrays (hash in Ruby) to functions.

But, we can pass the name of the array, and use ‘upval’ to access it.

  • When building Guis, sometimes I feel the code gets kind of cluttered with
    tons of widget commands followed by tons of pack commands.

I think this would happen with any toolkit.
I tend to write helper procs to generate things for me
(a labeled slider with annotated value and entry box),
and then use those procs. Bunch of samples on my web page.

Ruby

Pros:

  • Very clean syntax that seems to be pretty intuitive.

Yes! (but we can drop the “seems to be” phrase)

  • Built in support for lots of libraries (smtp, ole, os level, etc.). To
    me, it strikes a good balance between the “kitchen sinkness” of Python and
    the “minimalist model” of Lua.

Yes!!

  • OO layer makes more sense to me than in any other language I have looked
    at (remember I don’t know much about OO).

YES!!! This is where Ruby really shines!

···


Mike Hall
http://www.enteract.com/~mghall