Ruby Weekly News 4th - 10th April 2005


Tim Sutherland

Ruby Weekly News 4th - 10th April 2005

Ruby Weekly News is a summary of the week's activity on the ruby-talk
mailing list / the comp.lang.ruby newsgroup, brought to you by
Tim Sutherland.

Articles and Announcements

* RubyForge at 600 projects and counting...

Richard Kilmer announced that Tom Copeland had just activated the
600th project on RubyForge, after only a year and a half of service.

"We also want to thank our mirrors for handling the true brunt of the

Tom also separately posted a "big thank you" to those providing file
mirrors, including a new one from Evan Webb.

* Slashdot: Ruby On Rails Showdown with Java Spring/Hibernate

Joao Pedrosa saw an article on slashdot comparing the Ruby on Rails
web application framework with Java's Spring/Hibernate.

It was written by Justin Gehtland, the author of
"Better, Faster, Lighter Java" as well as
"Spring: A Developer's Notebook".

He ported a Spring/Hibernate application he'd written to Rails, and
concluded that the Rails solution used less code, much less
configuration, and ran faster. (Justin felt that the better
performance was due to Rails doing good caching.)

Justin: "To me, the eye-opening revelation isn't "Rails is faster than
Java/Spring/Hibernate". It's "Rails can be very fast.""

Ruby Users Groups

* Chicago Area Ruby Group Meetup with DHH

John W. Long declared that the "Chicago Area Ruby Group would like to
extend a warm invitation to Ruby developers everywhere to a meetup
with David Heinemeier Hansson on Saturday, April 23rd." Please RSVP.

* seattle.rb hackfest 2005 planning list now online

Ryan Davis announced a mailing list for the seattle.rb group to plan
their upcoming "hackfest".

* Utah Ruby User Group

Jamis Buck announced the Utah Ruby User Group.

* Montreal.rb ?

Mathieu Bouchard asked if anyone else is interested in setting up a
Ruby User Group in Montréal, Canada.

* Boston Ruby Meetup

This thread invited interest in Boston and Houston groups.

Quote of the Week

Marco Campelo asked "How Ruby is positioned regarding Enterprise

Jay Levitt responded,

"If you're looking for global enterprise solutions to integrate
distributed systems, at the end of the day, Ruby has the momentum to
leverage the dynamic potential of synergies between your skillsets and
its core competencies on Internet time. Achieving best-of-breed,
mission-critical componentization utilizing standards-compliant
scalability, it provides an adaptable, standards-based framework to add
value via a fast-track, result-driven development process.

I hope that helps answer your question."


Interesting threads this week included:

Is there any library that can easily manipulate Bitmap (bmp) file?

sin kanti wanted to turn a bmp image into a 60×40 pixel black-and-white
picture, whose bits would then be stored in an array for processing.

Timothy Hunter pointed out RMagick, a Ruby library that wraps ImageMagick.

Knight's Travails (#27)

Jason Bailey rode out this week's Ruby Quiz.

Given an 8×8 chessboard, write a program that takes a starting position of
a knight, and desired ending position. Additional arguments can be passed
to specify positions the knight is forbidden to land on.

Determine a shortest path from the start to end (if there is one).

method search rule in 2.0?

This topic was mentioned last week, but there has been much discussion
since. Matz has suggested that the way method search works could be
changed in Ruby 2.0.

In imaginary future Ruby, the following code would work as described in
the comments

class C
def process
util # will always call C#util, even if overridden
self.util # will call subclass's #util, if present

def util

Currently, both util and self.util would call the subclass' util if self
corresponded to a subclass.

A problem with the existing behaviour is that accidental overlap of method
names can easily occur.

(The "brittle base class problem" is a phrase used by some developers to
describe one such problem. It happens when a new version of a library is
released which adds a method. If a user of the library had earlier created
a subclass that happened to define a method of the same name, their code
may stop working when they upgrade the library.)

The wiki page Ruby2.0MethodSearchRuleEnglish gives the following example
of two classes that define util methods which are meant to be unrelated.

class C
def process
# ...

def util
# ...

class CC < C
def util
# ...

Currently process calls CC#util when it was intended to use C#util.

David Garamond began a thread saying he was "feeling disturbed about this
new Ruby2 behaviour". Isn't the current behaviour "what people expect in

Peter C. Verhage thought that an alternative change would be to make
private methods only exist in the class in which they were defined. It
would then be possible for C and CC to have different util methods
co-existing peacefully so long as they were private.

David A. Black argued that the default behaviour should not change - "the
case where you don't want overriding should be the one that requires
something extra". He suggested requiring the programmer to write C#util to
force C's version of util to be called. ("Yes, everybody, I do know that
this is comment syntax and would require a parser change".)

Csaba Henk said that C#util could be done in today's Ruby with

"It's sooo long that you can't help remembering the occasion if you use

And I don't remember doing it more that one or two times. That is, my
experience suggests that it's not a particularly frequent pattern."

Trans thought this topic was related to some work he had been doing in the
AOP (Aspect-Oriented Programming) world. "My solution was to have another
scoping mechinism akin to public, private, protected, called "local". It
differs in that methods defined in the local scope are always called
locally in the context of that module, but not in the context of any

Seven new VMs, all in a row

Peter Suk announced a project to write a Ruby implementation using a
Smalltalk Virtual Machine (VM).

"Ruby and Smalltalk are very similar under the covers, so Smalltalk VMs
are a very good match for the language."

Not only would this provide fast execution of Ruby, but also features like
a powerful debugger and a meta-level that would allow you to easily change
Ruby semantics.

R. Mark Volkmann said it would be "really cool" if Peter would do this
using the Sqeak VM (a Free / Open Source Smalltalk VM). Peter Suk agreed
that it would be good, except that he needs the Namespaces Smallktalk
feature in order to implement Ruby features like modules. Squeak does not
(yet) support Namespaces. "The VMs I am targeting first are commercial
ones, but they have free versions/licenses."

Avi Bryant thought that the Squeak VM would have no problem supporting
Namespaces - it's an "image-level thing, not a VM-level thing".

Later on, Peter pointed out that Smalltalk VMs typically have very little
that is Smalltalk specific. The language-specific portions are handled by
a different layer, which would be replaced with a layer for Ruby.

He also wrote, "A way I can help Pure-OO development is to vastly increase
the power of the Ruby community by giving it access to the great
technology developed for Smalltalk."

why aren't declarations just syntactic sugar?

Lionel Thiry asked why

class MyClass

didn't just get translated into

MyClass = do

Bill Kelly said that one problem was that the block form doesn't fit
nicely with "re-opening" the class. (For example, when you add a method to
an existing class.)

nobu added that the class Foo definition hides the outer scope, for

x = 1
class MyClass
p x # => Name Error

The above code would work if the class is created using the block form,
but that may not be desirable.

Accessing SVN through Ruby

Bob Aman wanted to write a kind of CMS (Content Management System) that
uses the Subversion version-control tool as a backend.

"However, the only simple interface to Subversion I seem to have available
to me is to call out to the Subversion command line client, which is
rather less than optimal."

He found Ruby bindings that were created using SWIG, but couldn't figure
out how to get them going. (SWIG is a tool that makes it easy to wrap C
and C++ libraries from a number of languages, including Ruby.)

Kouhei Sutou noted that the INSTALL file for the bindings includes
instructions on building them on Windows, the platform Bob was using.

Forcing FCGI headers

Tony Targonski had written a Rails application. One of the pages did a lot
of work and took several minutes to complete. FastCGI timed out after 30
seconds and didn't return anything to the client. What to do?

David Heinemeier Hansson said that one solution was to increase the
FastCGI timeout. "The default is a meager 30 seconds. Way too low for a
bunch of applications, including Basecamp. We use 600 seconds (to allow
for file uploads which are shuttled on to the users on FTP server)."

"Alternatively, you can have your action trigger an external service of
some sorts that complete the computation asynchronously. Then you could
have some other way of alerting the users, like using Ajax".

Quick start to acessing Oracle

Ross Parker was looking at moving from Perl to Ruby and wanted to quickly
get Ruby talking to his Oracle database. "Can anyone direct me to a quick
start resource for accessing Oracle with Ruby?"

Jason Sweat suggested the OCI8 library, and Ross was able to successfully
use this with DBI. (DBI is an abstraction layer which provides a uniform
interface for accessing different database systems.)

There is also a library called Ruby9i for use with newer versions of

My threading concern.

Aaron Rustad asked "When two theads enter a method that can change a value
of an instance variable, does the possiblity exist that one thread's
changes will clobber the other's?"

Kirk Haines explained that yes, this possibility does exist, just like in
other languages that use threads.

"If there is a section of code that should only be accessed in a serial
fashion, control that access with a Mutex", e.g.

m =
m.synchronize do
@bar.count += 1

"Ruby provides a rich set of support beyond mutexes for dealing with
threading issues, should you need them."

Aaron's question came up because he was developing a Rails web application
and noticed that Rails was handling requests with a method that has access
to instance variables of ApplicationController ("session, request,

Nicholas Seckar said that there was no problem in this case, since Rails
uses a new ApplicationController instance for each request.

Detecting thread exit immediately

Martin DeMello was busy developing his fxirb application (a GUI wrapper
around IRB), and had some code that started a Thread whenever it needed to
launch an IRB session. How could he tell as soon as the Thread had ended?

"Is there any way I can have FXIrb pass in `self' to the thread so that it
can call methods on it?"

He later reported that the helpful people in the #ruby-lang IRC channel
had provided him with the solution,

@irb = {

Ruby/DL - assigning to global variables?

Andrew had code like

module Foo
extend DL::Importable
dlload ''
@@bar = symbol 'bar'

... "where `bar' is a variable in libquux. How do I assign a value to

Takaaki Tateishi explained that "@@bar is considered as a pointer to a
value. If its type is int, you can assign an integer value as follows."

IntValue = struct ["int value"]
obj =
obj.value = 1

Interfacing with C executable

Joe Van Dyk had a C program that was part of a complex system which uses
shared memory for communication.

Currently he was using message queues for communication between the C
program and Ruby, but this was cumbersome because he had to do too much
work every time he added a new data type.

Aredridel suggested using his ruby-packstruct library, which "lets you
define binary-accurate structures in Ruby, similar to but independent of
ruby/dl", "and see if you can't do the shared memory interface yourself".

(Note: There are Ruby libraries that let you access both mmap and System V
shared memory.

See the shared memory example thread for an example using SystemVIPC.)

New Releases

* Fico 0.1.0

Urban Hafner announced the first version of Fico, a Ruby
implementation of the board game Havannah. The aim of Fico is to
develop a good AI.

Edgardo Hames mentioned that the game's inventor has offered 1000
Euros to anyone who can write a program that beats him at least 10% of
the time.

The thread discussed the idea of Havannah being the topic of a future
Ruby Quiz.

* cmd 0.7.0: Library for Line-Oriented Command Interpreters

Marcel Molina Jr. was "very pleased to announce" the initial release
of Cmd. Cmd is a library for building line-oriented command
interpreters, inspired by the Python library of the same name.

* fxirb 0.2.0 - Multiline Edit (and request for help) Martin DeMello
added proper multi-line editing to fxirb, a GUI wrapper around IRB.

He also requested some help in implementing gets support - he doesn't
know enough of either IRB or FOX to know what needs to be done.

* Bayesian Classification for Ruby

Lucas Carlson announced a new library called Classifier. You train it
on input text (`this text is interesting', `this text is
uninteresting'), and then ask it to classify new text as interesting
or uninteresting.

* RForum 0.1

Andreas Schwarz introduced the first beta of RForum, a web forum built
with Ruby on Rails. It is developed by Andreas and Alexey Verkhovsky.

It will be used for Ruby Forum when it's ready.

* Rake 0.5.3

Jim Weirich released a new version of the Rake build tool. FileLists
have had many improvements. "In particular, operations on FileLists
that return a new collection (e.g. collect, reject) will now return a
FileList rather than an array."

There were a number of other changes.

* Shallow Parser for t-SQL

Shashank Date let out an alpha version of a library that parses the
t-SQL procedural language (used in Microsoft SQL server).

* Nitro + Og 0.15.0, Localization, Parametrized mixins, Morphing,

George Moschovitis announced new versions of Nitro and Og. Nitro is a
web application framework and Og is an object-relational mapper.

"A great release. Many cool new features and tons of subtle
improvements. We also welcome a new core developer, Anastastios
Koutoumanos, who's first contribution is the new SqlServer adapter."

Localisation has been enhanced. "Parameterised mixins" are another
interesting new feature. Scaffolding was also improved.

* Wee 0.8.0

Michael Neumann updated the Wee web application framework. Highlights
include Ajax support (live updates) and a FastCGI adaptor.

* r43

Pat Eyler uploaded a pre-alpha release of r43 - a library that
implements the 43things API.

* Syck 0.54-typing compatibility, improved output

why the lucky stiff improved the development branch of Syck, Ruby's
YAML parser, by making it more compatible with the stable version.

* Simple scene graph engine in OpenGL

Ilmari Heikkinen put together a scene graph engine using ruby-opengl,
glut and ruby-imlib2.

* Iotaz 0.1.0

Peter Wood gave out the initial release of Iotaz, an object-relational
mapper that initially only works with the Firebird relational database
management system. (Using the FireRuby client library.)

Martin DeMello

Tim Sutherland said:
Detecting thread exit immediately

Martin DeMello was busy developing his fxirb application (a GUI wrapper
around IRB), and had some code that started a Thread whenever it needed to
launch an IRB session. How could he tell as soon as the Thread had ended?

"Is there any way I can have FXIrb pass in `self' to the thread so that it
can call methods on it?"

He later reported that the helpful people in the #ruby-lang IRC channel
had provided him with the solution,

@irb = {

My bad - I mixed the two methods up when posting:

@irb = {
self.quit_method # using the fact that the block is a closure with
# self in scope


@irb = {|obj|
obj.quit_method # explicitly passing in self as a parameter


David Moreno Garza

Ruby Weekly News is a summary of the week's activity on the ruby-talk
mailing list / the comp.lang.ruby newsgroup, brought to you by
Tim Sutherland.

RWN rocks :)

Tim Sutherland

My bad - I mixed the two methods up when posting:

@irb = {
self.quit_method # using the fact that the block is a closure with
# self in scope


@irb = {|obj|
obj.quit_method # explicitly passing in self as a parameter

Thanks, I've updated the website with the the first version.

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

Latest member

Latest Threads