[ale] Why Ruby? [was Pyhon syntax]

fletch at phydeaux.org fletch at phydeaux.org
Wed Jan 26 19:24:30 EST 2005


I think the main thing I like about Ruby is that it's very close to a
blend of Perl and Smalltalk (both of which 'rock', as the hep kids
say; I'm also liking ObjC on OS X with its Smalltalky flavour).  It's
not a large jump to get from how I normally think of doing something
in Perl to getting something equivalent working with Ruby (and then
tweaking however to get it more idiomatic).  Python never 'clicked'
the way Ruby did very quickly, and then there were the bleh things
that irritated me[0] so I never did much more than get fluent enough
to be able to read code with a manual at hand.


As for module support, 1.8.2 has a whole bunch of handy stuff in the
core.  There's an (SG|X)ML parser, there's a 'perldoc' analogue (rdoc
and ri), there's an HTTP server, there's SOAP and XML-RPC support,
there's a complete unit testing framework, . . . .  Check the stdlib docs:

http://www.ruby-doc.org/stdlib/

As for aftermarket stuff there's no CPAN yes, but rubygems is pretty
interesting and probably will be shipping with 1.8.3 I believe.  There's
also a good number of things available as source (and pointed at from
either raa.ruby-lang.org or rubyforge; but again granted it's not CPAN).


There's open-uri which overloads open() so that it handles URLs as
well as filenames.  This snippet (from http://redhanded.hobix.com/)
uses it to grab the font size for the different categories and shows
their relative popularity on del.icio.us:

require 'open-uri'
t = open("http://del.icio.us/tag/").read
l = %w(c c++ java javascript perl php python ruby)
l.map do |lang|
  [$1.to_f, lang] if t =~
    %r{/#{Regexp::quote lang}"  style="font-size: (\d+\.\d{2})}
end.compact.sort {|a,b|b<=>a}.each do |score, lang|
  puts "#{lang}: #{score}"
end


Rails is what's gotten me to look at Ruby again.  I've been poking at
it since ~0.7.0 and it's really spiffy how quickly it "just works"
(I'd looked at Maypole for Perl but never got it to behave as well as
Rails did straight out of the box).


[0] Actually poking at python2.3 it looks like a couple that I
    remember actually may have gotten fixed (lambda actually makes a
    real closure now, for instance); but indicating block structure by
    indentation is still broken :)

-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org|  Vincent, you should cease askin'          \ o.O'
                      |  scary questions." -- Jules                =(___)=
                      |                                               U



More information about the Ale mailing list