Archive for the 'Ruby on Rails' Category

This Week in Ruby (June 26, 2008)

Antonio Cangiano June 26th, 2008

This is the 11th episode of This Week in Ruby, please consider subscribing to my feed so as to not miss any weekly installments.

This edition begins with some bad news: Several vulnerabilities that affect the main Ruby implementation have been discovered. There is no reason to freak out, but they are serious. An ill-intended person could take advantage of these vulnerability and execute arbitrary code. Matasano has a few practical examples which illustrate the vulnerabilities in question. To learn more head over to the official advisory. Unfortunately, the suggested upgrades (except those for Ruby 1.8.7) are currently not working for many Rails developers, who’re reporting segmentation faults. The Phusion team has created a patch that was reported to be working, but it would be nice to see the Ruby Core Team verify and incorporate it quickly. If you’re running a version of Ruby that shipped with Mac OS X, don’t upgrade yet. Instead wait for Apple’s Software Update.

RubyGems 1.2 was released and it’s much more responsive than previous versions of it were (no more bulk updates just to install a new gem). To upgrade run: sudo gem update --system (without sudo if you are on Windows). After a substantial refactoring, Mocha 0.9 – a framework for mocking and stubbing – was released this week. A new BitNami RubyStack version was released (1.2 beta) as well, which adds a lot of goodies to the package, including but not limited to NGINX, Thin, Rack, EventMachine and so on. Speaking of EventMachine, check out EventMachine: Fast and Scalable Event-Driven I/O Framework published by InfoQ. Last week they also published an interview with yours truly, in regards to the Ruby Benchmark Suite. I regret that the shootout testing hasn’t started yet as promised, but Murphy’s law got in the way.

For those interested in improving their language-fu, there were a numbers of interesting articles: Using select, reject, collect, inject and detect, Enumerating Enumerable, Macros, Hygiene, and Call By Name in Ruby Eliminating code duplication with Metaprogramming. Also noteworthy, this piece on working with Microformats from Ruby.

A Ruby Community Announcements group was started in order to provide a fast ML for announcements only. It’s for those who’d like to stay in the loop, but wish to avoid the high volume of messages in Ruby-Talk.

The erubycon conference about Ruby and the Enterprise will be held between August 15 and 17 (‘08) in Columbus, Ohio. They still have a few seats available, so if this topic is of interest to you, grab a spot while you still can.

Finally, if you’re hiring Ruby talent or plan to look for a Ruby job any time soon, take a peek at these 15 fundamental questions for Ruby interviews. They’re somewhat basic, but the article is a good staring point nevertheless.

ALT.rb

From the world of alternative implementations and frameworks, I found this article on Rubinius FFI, an introduction to MacRuby as a replacement for RubyCocoa, and the announcement of Merb’s run_later” method for backgrounds tasks, all to be informative.


To keep the good times rolling, the second edition of This Week in Rails is available on the official Rails blog.

This Week in Ruby (June 16, 2008)

Antonio Cangiano June 16th, 2008

This is the 10th episode of This Week in Ruby, please consider subscribing to my feed so as to not miss any weekly installments.

As announced a few days ago, This Week in Ruby is being split into two parts: This Week in Ruby and This Week in Rails. The one you are reading is the Ruby edition, while Riding Rails – the official Rails blog – will host the Rails one. Links to and from each post will be provided, in case you don’t follow both blogs.

Ruby

The Ruby community has shown a clear interest in Behavior-Driven Development (BDD), so if you haven’t taken the plunge yet, check out Ben Emson’s introduction to RSpec Stories. Those who’re already well versed with RSpec, will enjoy an article by another Ben, in which RSpec’s DSL internals are explained in detail so as to cover an example of creating macros with RSpec.

The Pragmatic Programmers published a series of screencasts about The Ruby Object Model and Metaprogramming. So far they’ve received glowing reviews, including my own, hence I highly recommend that you evaluate them.

A couple of weeks ago I announced the creation of a Ruby Benchmark Suite project. The next shootout will take place starting from the 24th and I should be able to get the results up on this blog by the 30th of this month.

While working on modifying his RX Ruby Tokenizer to be included in the Ruby Benchmark Suite, Tim Bray reported a few considerations on the sad status of REXML and Ruby 1.9. It’s definitely an interesting read, and it’s important to increase the awareness about the current pains of working with Ruby 1.9 and REXML.

Yesterday, Tim also had a post titled Deletionist Morons about the controversy surrounding the proposed deletion of Why the lucky stiff’s wikipedia entry. The Ruby community at large vouched for Why, who is clearly one of its biggest, and definitely most original, contributors.

Finally, the fun Ruby article award of the week goes to Ilya Grigorik for his Tumblr, RMagick and a Photo Frame!

ALT.rb

RailConf’s presentation regarding MagLev has been an attention grabber in the world of alternative Ruby implementations. A video of Avi Bryant’s demo is now available online, as well as a somewhat older interview with InfoQ. You can read Chad Fowler’s take as well as mine.

MacRuby 0.2 was released about 10 days ago. For those not familiar with this project, it’s an Ojective-C based implementation of Ruby 1.9 for Mac OS X. The general idea is to have a Ruby version that lets you write Mac applications that perform reasonably well. In the upcoming shootout we’ll be testing this early release as well.

Those of you still working in Java, but interested in the possibility of using Ruby’s testing tools and frameworks, should pay attention to the release of JtestR 0.3. As you can imagine, this works thanks to JRuby’s interoperability capabilities with Java. If this alternative Ruby implementation for the JVM appeals to you, you should probably also read Thomas Enebo’s interview about the future of JRuby. Speaking of interoperability, at Tech Ed (that’s a Microsoft event), John Lam demonstrated a cool prototype for the integration of IronRuby and ASP.NET MVC.

Readers interested in contributing to Rubinius, should take a look at this write-up about getting started with hacking on Rubinius.

Web Frameworks

At the latest Toronto Rails night (which I didn’t attend, but I soon will be as I’m moving downtown), Rowan Hick presented Merb, and has now made his presentation
available online. Speaking of Merb, Engine Yard Express is a new free product that lets you try out an Engine Yard “slice” wrapped up in a VMware image, and both Merb and Rails are supported.

The 2008.06 version of Ramaze was released last week. Aside from switching from a numeric release scheme to a date-based one (which I personally like much more), this is a major release that introduces over 450 patches and a few changes to the internal API.

To keep the good times rolling, the first edition of This Week in Rails is available on the official Rails blog.

Review of the screencast series The Ruby Object Model and Metaprogramming (episodes 1-3)

Antonio Cangiano June 12th, 2008

Even if you’re new to the Ruby community, you are unlikely not to have heard about the Pragmatic Programmers, who are well reputed for publishing great programming books. You may not have noticed that lately though, they’ve also been releasing several series of screencasts.

Each episode lasts about half an hour and sells for a mere $5. This strategy will work well in their favor because screencasts are a great way to teach programming. So far they’ve put out 5 series: Expression Engine, Core Animation, Erlang by Example, Everyday Active Record and, their latest entry, The Ruby Object Model and Metaprogramming.

If you are reading this blog, I’ll assume you’re mostly interested in the last two topics. I haven’t had a chance yet to watch the Active Record ones, so I can’t say much about them, other than that I have faith in their author, thanks to his magnificent work on the Railscasts.

Today after work however, I spent about an hour and a half watching the first three available episodes of The Ruby Object Model and Metaprogramming. This is a brief review of my thoughts on them. In short: they’re fantastic. But let me provide you with a bit more of a in-depth analysis than that.

These screencasts shine for the simple reason that you feel as though you’re sitting right there, next to a master programmer like Dave Thomas, as he explains Ruby concepts in detail to you. Whenever you’re not very clear about a concept, you can go back and listen to the explanation as many times as you’d like. You can pause, experiment with irb, and then go back to the screencast. After watching the first episode, I though that the $5 price was a steal.

Currently the following three episodes are available:

  1. Objects and Classes (29 mins)
  2. Sharing Behavior (39 mins)
  3. Dynamic Code (31 mins)

The first episode lays the groundwork for the series and introduces a useful diagram that enables you to easily visualize the Ruby object model correctly. Concepts like singleton methods and ghost classes are really well explained. The first episode also covers ‘self’ and the concept of current class, which is often confusing to beginners.

The second episode explores what constitutes good object oriented design, as well as the usage of prototype programming, inheritance (and how not to abuse it), and finally an excellent explanation of modules and mixins. If you are a beginner you may not know the difference between including and extending a module, or the true power of mixins. Fear not, the last part of second episode really covers those subject well.

The third episode starts by defining blocks and their usage, including the difference between lamdba and Proc.new. It then moves on to explore the concept of bindings capturing the execution context, and the importance of closures in metaprogramming. The last 12 minutes or so are spent dealing with the subject of dynamically defining methods, which is at the heart of metaprogramming, and the video includes a nice example of how to create your own version of attr_accessor by defining, in a module, a method that dynamically defines getter and setter methods.

I’d say that aside from the feeling that I was enjoying a “private lesson”, what I liked the most was the coding style recommendations about when to employ a given concept and when to opt for something else. The examples were clear and easy to follow as well.

I can’t recommend this series highly enough to any Ruby programmer with a basic grasp of the language. I feel that intermediate developers will get the most out of these videos, but they’ll also definitely be very beneficial for beginners. Real experts shouldn’t find any alien concepts, at least in the first three episodes; I know I didn’t. Yet, they’ll appreciate, just like I did, the fresh slant when it comes to reviewing some of the illustrated concepts and examples. There will also be a few “ah-ah!” moments here and there, I guarantee you.

Five stars, and I’m certainly looking forward to future episodes.

« Prev - Next »