From: timsuth@... (Tim Sutherland) Date: 2005-01-30T17:35:51+09:00 Subject: Ruby Weekly News 24th - 30th January 2005 http://rubygarden.org/ruby?RubyNews/2005-01-24 Ruby Weekly News 24th - 30th January 2005 ----------------------------------------- A summary of the week's activity on the ruby-talk mailing list / the comp.lang.ruby newsgroup. This summary is brought to you by Tim Sutherland (TimSuth). Articles and Announcements -------------------------- * [Francais] Mathieu Bouchard let readers know that a French-language mailing list for Ruby discussion is available. Send an email to ruby-Fr-ctl@ruby-lang.org whose contents are only the word "subscribe" (without the quotation marks!) The forum itself is then ruby-fr@ruby-lang.org. There are more than 60 people subscribed so far, although there is not yet much discussion. Mathieu also wants to form a Ruby Montr�al Users Group and [asks] interested users to email him. * [RedHanded interviews chromatic (ONLamp site editor)] whytheluckstiff informed us that "Curt Hibbs' [Rails article] at [ONLamp.com] has been a hit. Curious as to the perspective of ONLamp staff, I [staged an interview] with its editor, chromatic." * [Looking for some help] Dave Thomas warned that "[i]t's looking as if the success of the Bookshelf venture is severely cramping the amount of time I can dedicate to RDoc. That's to it's detriment." With this in mind, Dave's looking for a new maintainer of this important documentation tool. * [Bangalore rubyists?] If you're a Rubyist living in Bangalore then Martin DeMello would like you to add your name to this thread. The IndiaGroup wiki page has some names as well. Quote of the Week ----------------- why the lucky stiff made the following disturbing [disclosure]: "Early on, long ago, I had a dream that Matz came over in his little painter's outfit and started to wallpaper my house with lettuce. But I think my dream was influenced by the fact that when I first met Matz he was holding salad tongs. I speak the unimpeachable truth." Threads ------- Interesting threads this week included: [Ruby for mobile phones?] ------------------------- cyberco wrote: "I've been doing a lot of work with Java J2ME and one thing that bars real innovation is waiting for new API's that open up the phones functionality. And if these API are finally released it takes years before they are sufficiently spread to build applications with them. NOKIA realized this and started to port PYTHON to Symbian (a popular OS for mobile terminals). This allows programmers to easily access the phones native functionality. Unfortunately this is still a project in its pre-alpha state. But maybe that's fortunate for the Ruby community. Wouldn't it be great if Ruby was ported to mobile (aka limited) terminals as well?" Kero reported that he had Ruby working on an iPaq and thought that phones running Linux would be easier to port Ruby to. Palm Pilot support was also discussed. As far as supporting phone-specific APIs, using OPL (BASIC-like language for Symbian) could be the way to go - either by translating a subset of Ruby to OPL or (your editor suggests), extracting API information from OPL source code / documentation, or writing a bridge to allow Ruby to call OPL code. [Self and Ruby Comparisons] --------------------------- If you've ever wondered about the differences between Ruby and the [Self] programming language then this thread has some insight. Self is based around a prototype-based object model where objects arise from cloning and modification, whereas Ruby has a class-based object model in which objects are usually created by calling the new method of a class. Martin DeMello quipped "for one, self doesn't have a ruby keyword". On a more serious note, Csaba Henk said "In Self really everything is message passing. Unlike Ruby and unlike Smalltalk! Assignment is a special thing even in Smalltalk. In Self, you are free to add/modify slots of objects from outside, and assignment is in fact just a message which does this. (I think so.)" Csaba also showed how Ruby can be used like a prototype-based language thanks to the ability to add/modify methods on single objects. Ideas for how to change an object's class from out underneath it were discussed, with Florian Gross mentioning that [Evil Ruby] adds an Object#class= method. (Evil Ruby is a library that provides support for doing strange and sometimes dangerous things to the Ruby runtime.) [nuby threading on threads] --------------------------- Pe�a, Botp was using threads in Ruby for the first time and wrote the following program. The idea is to have 10 threads doing work, and as each thread dies a new one should be launched. LIMIT= 10 tlist = [] loop { if tlist.size< LIMIT tlist << Thread.new { p "test" } else sleep 5 end } This didn't work properly - tlist became filled with dead threads. Pe�a wanted to know the best way of removing dead threads from the list. Eric Hodel said that tlist should be a ThreadGroup instead of an Array. "ThreadGroups automatically drop Threads that are no longer alive. Use tlist.list to get the list of threads currently in the ThreadGroup." [RubyConf '05] -------------- Brian McCallister wondered if any decisions had been made regarding RubyConf 2005 - location, date, etc. Chad Fowler and his [RubyCentral] "co-conspirators" have a date and location in mind and will be making an announcement soon. Harry Ohlsen thought Sydney would make a good location one year and Premshree Pillai thought likewise for somewhere in India, to which there were a couple of "+1"s. Michael Neumann had the same question about EuRuKo '05 (European Ruby conference). Stephan K�mper suggested "I raise my voice to locate it in wonderful Hamburg this year - or somewhere in Northern Europe (Denmark perhaps)." The thread somehow turned into a discussion on black holes and Minkowski-Einstein principles with Michael Neumann calculating that there are at least 2.3501502e+14 Rubyists in the universe. [A Rubyist's Dream] ------------------- Benjamin Stiglitz was driven to join the list by a dream about Matz coming to his door with New Years greetings. This induced whytheluckystiff into sharing his own dream, see Quote of the Week above. Hal Fulton: "In all seriousness, have you ever dreamed the exact location and cause of a bug? I have on three occasions. Once I was on contract to IBM and working very hard. I woke up thinking, "Man, I should put that on my timesheet..."" Matz confessed "Often. Furthermore, sometimes I jumped up from the bed and turned on my PC to find that the bug was already fixed by myself sometime ago.". [Array::uniq { block } ?] ------------------------- Belorion wanted to use Array#uniq but with a block so the following could be done: a = [ [1,2], [3,4], [1,3] ] b = a.uniq { |x,y| x[0] == y[0] } # -> [ [1,2], [3,4] ] This is similar to the behaviour of Enumerable#sort when given a block. Martin DeMello suggested uniq_by, to behave analogously to sort_by, so that the example would be written as "b = a.uniq_by { |x| x[0] }". As a more general concern, there were questions as to whether it was necessary to add even more blocks to the Ruby standard library with responses ranging from "Where does it all end?!" to thinking that it would be a good idea to look for other methods which don't yet have blocks. [Ten Things Every Java Programmer Should Know About Ruby] --------------------------------------------------------- Jim Weirich is going to be introducing Ruby to the XP (Extreme Programming) user's group in Cincinnati next week and wanted to prepare a list of "Ten Things Every Java Programmer Should Know About Ruby". The responses have been [summarised] (well, listed anyway). [[SUMMARY] Paper Rock Scissors (#16)] ------------------------------------- James Edward Gray II summarised last week's [Ruby Quiz] - to write a bot to play the rock-paper-scissors game. (Solutions were posted under the [quiz announcement].) Bill Atkins started something when he posted class Cheater < Player def initialize opponent Object.const_get(opponent).send :define_method, :choose do :paper end end def choose :scissors end end In response, Jannis Harder posted a player that will always beat Bill's bot - not only does it redefine the opponent's choose method, but it retores its own method each time in case the opponent tried to cheat too. [[QUIZ] To Excel (#17)] ----------------------- James Edward Gray II came up with a realistic task for [Ruby Quiz] this week - extract useful information from a report and import it into Excel (alternatively, produce a CSV file). "Years ago, on a job developing custom reporting software, this was one of the side tasks. Parsing a report may sound boring, but I urge you to at least download this report and peek inside. It's a tragic example of database output gone wrong." [how do i turn an object into a binding?] ----------------------------------------- Bret Pettichord wanted to replace code like foo.bar foo.baz(1) foo.bagaloo('didoo') with with (foo) do bar baz(1) bagaloo('didoo') end Florian Frank gave a solution using instance_eval. When foo.instance_eval is called with a block, the block is evaluated but with self being foo. For example, foo.instance_eval do bar baz(1) bagaloo('didoo') end Note that if we have code like "foo.bar = 5" then it cannot be replaced with "foo.instance_eval { bar = 5 }" since in the latter code, bar will be interpreted as a local variable. Instead, foo.instance_eval { self.bar = 5 } must be used. [Ruby WikiDocs?] ---------------- Warren Brown had an idea for improving Ruby documentation: "Ruby WikiDocs would basically be a Wiki containing Ruby documentation that anyone (after registering?) could add to, change, or simply make comments about." This would solve the current problem where people have to post patches to documentation, and its not always clear where to send the patch. James Britt said that this had been discussed in the past and was on his growing ToDo list for [ruby-doc.org]. There were also ideas for making it easy to backport the Wiki information into the source code. (Currently, classes and methods are documented via comments in source code. The rdoc tool then extracts this data.) [Current state of Ruby i18n?] ----------------------------- James Britt wanted to build a website that presented content in multiple languages using Ruby. Eric Hodel suggested adding $KCODE = 'u' require 'jcode' to his program, to "make string functions multibyte-capable". Then the web pages simply need to set the content-type to UTF-8. New Releases ------------ * [Ruby 2.0!] Chris Pine announced that "Ruby 2 (a.k.a Ruby Secunda Kathrine Pine) was released January 22, 2005 at 1:51:42 pm (PST) after a few hours of intense, last-minute debugging and deployment. We've been working on this project for just over 9 months and are quite pleased with the results! (Well, my wife really did most of the work, though I *did* play a seminal role in the initial project conception phase.)" Her older brother's name is "C Maximus Pine". Chris later added "[w]e needed a theme, so we decided to name our kids after programming languages. Yeah, my wife is pretty cool. :)" * [DBus/Ruby 0.1.10] leon breedt removed [DBus/Ruby]'s dependency on Ruby-GNOME2. DBus/Ruby is a Ruby interface to [D-BUS] ("D-BUS is a message bus system, a simple way for applications to talk to one another"). * [JRuby 0.8.0] Thomas E Enebo released a new version of [Jruby], a project to implement a Ruby interpreter in Java. Threading support and Java interaction have been improved, many bugs were fixed, the rubicon test suite can be run and the Ruby 1.8 grammar is fully supported. * [aeditor-2.2 (future release)] Simon Strandgaard added new keybindings and colour rendering to [AEditor], a cross-platform console editor designed for use by programmers. * [win32-changenotify 0.3.0] The Win32Utils team was "proud" to annouce win32-changenotify 0.3.0, an interface for monitoring file and directory changes on the Win32 platform. It now provides more detailed information on what the change was. * [io-extra 0.1.0] Daniel Berger was "happy" to release io-extra 0.1.0, a collection of extra methods for the IO class. Methods for closing or iterating over all file descriptors were added, along with directio support. * [Rails 0.9.5: A world of fixes and tweaks] David Heinemeier Hansson and co-conspirators have been busy polishing the [Rails] web application framework. Highlights include improvements in reloading source code when an application is in development and improved support for collections. * [WWW::Mechanize 0.1.0 available as Gem] Michael Neumann packaged [WWW::Mechanize] for RubyGems. This is a port of the Perl library by the same name, used to help write Ruby programs that extract data from websites, click links etc. * [ruby-dl2-0.0 for Ruby 1.8 and Ruby 1.9] It was Takaaki Tateishi's "pleasure" to inform the group that the first version of [Ruby/DL2] has been released for inspection. This will soon replace Ruby/DL in the current unstable branch of Ruby (1.9). DL provides an easy way to interact with C code from Ruby. Takaaki is very interested in people's opinions at this stage. * [Arachno Ruby IDE 0.4.0] Lothar Scholz was "pleased" to announce a new release of [Arachno Ruby IDE], a commercial, proprietary development environment for Ruby. A 60 day trial version is available. Context-based completion has been added, indentation improved and more. * [Wee 0.5.0] Michael Neumann updated his web application framework Wee to include enhancements like support for live-updates and Og scaffolding (object-relational mapper). * [Logtails 0.4 : the time saving release] Bauduin Raphael added save-session support to [Logtails], a graphical tool (Qt) for watching log files.