Technology solutions for Ruby?
vasudevram at gmail.com
Mon Jul 16 19:25:39 CEST 2007
[ Though the OP posted his message to comp.lang.ruby, I'm cross-
posting it to comp.lang.python, since he mentions Python as a possible
alternative he's looking at, and also because I've recommended Python
for his stated needs. Also, interested to see what other Pythonistas
have to say in response to my reply.
> On Jul 16, 2007, at 2:21 AM, Michael Reiland wrote:
> At the heart of the issue is the fact that I refuse to use Java for this
project, I prefer not to use .Net because of the portability issues,
I'd like to get away from C++ for obvious reasons.
> To me this means Ruby, Python, or, as mentioned above, Perl. If anyone
can tell me of a way to meet the above requirements in either Python
Perl, I'm all ears (I just prefer Ruby).
Yes, I think it would be really great for the Ruby community and for
the growth of the language if wxRuby was more mature as a GUI toolkit.
(Not knocking the wxRuby developers at all, its great that they've
even done what they have - I know that creating other language (like
Ruby) bindings to a C++ lib is a non-trivial task).
My suggestion: Python + wxPython + Python DBI + (Py2Exe + InnoSetup)
*might* meet all your needs. (As with any decision about what software
technologies to use, you'll have to evaluate the suggested options to
see if they fit your needs.)
Note: I've used and like both Ruby and Python (saying this after using
many, though not all, language features and libraries of both
languages), and am not trying to discourage you from using Ruby for
your needs; its just that, based on your needs as described, it looks
to me as if Python meets them better than Ruby at present:
> 1. GUI - Native Look and Feel. According to wxRuby the bindings aren't
mature enough for production use. Does anyone have any experience
this and/or can you offer alternatives that provide a native look and
I don't know enough about wxRuby to comment.
wxPython has this (Native Look and Feel), I think (used it some, a
while ago), not 100% sure, you can check on the site - http:/
- to make sure. The site does say that it is cross-platform:
"wxPython is a cross-platform toolkit. This means that the same
program will run on multiple platforms without modification. Currently
supported platforms are 32-bit Microsoft Windows, most Unix or unix-
like systems, and Macintosh OS X.
but that doesn't necessarily mean that it will have native look and
feel on all supported platforms. (The two are not the same thing.)
That's why you will need to check.
wxPython pros: Its fairly easy to learn, at least for simple GUI apps
(e.g. a few widgets / controls and a file dialog or two). I was able
to build these simple ones - see the code, article and screenshots
available here (or from links from here):
- in quite a short time, starting from zero knowledge of wxPython (I
did know some Python from before), just by looking at the sample apps,
and some reading of the docs.
See the quotes about wxPython: http://www.wxpython.org/quotes.php
>2. Databases - contemplating using ActiveRecord, but I would like to use
ODBC to support multiple types of DB's in a uniform way (if you know
alternatives to ODBC or ActiveRecord, please let me know).
I think, but again, not sure, that Python DBI + appropriate database
drivers, may meet this need. Basically Python DBI is similar to ODBC
(roughly), and to Perl DBI + DBD, as I understand. There's also ODBC
support in the Win32 extensions package for Python - IIRC, Google for
'win32all' to get it. Its also available as a link from the Python for
Win32 MSI installer on python.org.
I've used Python ODBC some, it works and is easy to use.
See this for a simple example:
(See the second post at that page, titled "Publishing ODBC database
content as PDF
". The code shown in the post is not indented as per proper the Python
syntax (LiveJournal messed up the indentation), sorry about that, but
its trivial to correct if you know Python indenting rules). Also read
the Python ODBC docs and examples, of course.
>3. Binary - Are there any utilities for compiling Ruby into a binary
executable? The issue is twofold, speed, and not handing the
the source :)
For Python, there is py2exe (for Windows only). I used py2exe recently
and it works well enough for the simple cases that I tried. (I tried
building EXEs for a simple Python hello-world program, and for a
simple wxPython GUI app based on my xtopdf toolkit. Both worked ok.)
For cross-platform (Windows and Linux, IIRC), there is PyInstaller
(Google for it), haven't tried it out yet, just downloaded it
I don't think you'll gain much speed by this compiling step, though
(over and above what Python gives you itself, when it compiles
your .py files to .pyc files). The purpose of py2exe is more to hide
the source code than to speed it up, as I understand (could be wrong).
Note: py2exe only creates an EXE and DLLs needed, from your source and
its required Python modules. To create an installer, try InnoSetup
(for Windows only). I recently tried it out, version 5, again, it
worked well. Could create Windows SETUP.EXE-type installers for the
two EXEs described above. Worked ok.
I first learned Python, have been using it for some time for various
projects, and then learned Ruby, and have done some projects with Ruby
I've been reading both the Ruby Cookbook and the Python Cookbook
rather thoroughly in the last few weeks (and trying out and modifying
many of the recipes), and what I've observed is that the two languages
are roughly similar in features. For basic features common to most
languages (constants, variables, arrays, hashes/dictionaries, file I/
O, classes, objects, modules/libraries, etc. - they work roughly in
the same fashion - though syntax obviously differs, you can mostly do
what you can in one of them, in the other as well. (Note that I'm not
talking about libraries here - this will obviously differ as each
language will have its own set of libraries for doing various tasks,
like networking and other areas - though even here there is a good
amount of overlap/similarity.)
For more advanced language features related to object-orientation,
metaclasses / metaprogramming, both have some support, but you might
or might not be able to do in one, what you can do in the other.
PDF toolkit (in Python): http://sourceforge.net/projects/xtopdf
More information about the Python-list