Moving to Source Matters

I've started a new blog called Source Matters. I've moved the one post that I had here from 2012--In My Toolkit: Midje--but have not yet decided whether to migrate the older posts. In the mean time, they will remain available here.

Thank you for reading this blog and I hope to see you at Source Matters.

Relative Performance of Symbol#to_proc in Popular Ruby Implementations

When Rails 1.1 introduced <> in 2006, many people, including me, embraced the convenience and elegance of being able to write code such as this:


instead of the equivalent standard Ruby syntax:


Others pointed out that the <> approach was much slower than using an explicit block. A commenter on this post on Josh Susser's blog, for example, shows a benchmark revealing <> to be 3.4 times slower on one example. Continue reading ...

Release Announcement: has_enumeration 1.0.0

This month marks five years since I left a career in embedded systems software development in a quest to reignite my passion for programming. I began my love affair with Ruby shortly thereafter. It was elegant and expressive. It was object-oriented and had closures. It was everything that I had been yearning for while programming in C for all those years.

There are times, though, when I have flashbacks to my C days. Continue reading ...

Arbitrary Reordering of Ruby Arrays

Reordering an array in Ruby is easily accomplished with <> as long as you can provide a block that can compare two elements of the array and indicate their relative ordering. But, what if determining the relative ordering of the elements is not as simple as using the equivalent of the <> operator on the two elements? What if, say, you wanted to reorder an array of ActiveRecord objects to reflect the order in which their IDs were returned by your search engine? Continue reading ...

Rujubu's View is now Greg's Blog

This blog started its life as Rujubu's View in 2007 when my consulting company, Rujubu Consulting, was actively seeking business. When I relaunched the blog last month after a long period of inactivity (see Relaunching Rujubu's View), I was contemplating returning to active consulting. In preparation for that, I kept the blog's name and its URL on the domain.

Last week I decided to keep Rujubu Consulting on ice for the foreseeable future and accepted a new full-time position at a company (more on that later, perhaps). I am very interested in keeping this blog going, but no longer have a need to promote my consulting business. So, I have renamed it to "Greg's Blog" and have moved it to my personal domain.

Lazing: Lazy Enumerable Methods for Ruby 1.9

The <> approach I wrote about in Selecting Only What You Need addresses the need for a lazy version of <> in a very specific use case. It solved the problem, but left me wanting a general solution.

I found a few blog posts and gems providing lazy versions of a subset of the methods defined in <>. I was unsatisfied with them, though, primarily because of their clunky method names. I strongly believe that code should be easy to read aloud and names like <>, <>, and <> do not roll off the tongue. Continue reading ...

Selecting Only What You Need

A couple of weeks ago I was investigating a performance problem. New Relic RPM narrowed the search and code inspection identified the culprit. With the names changed a bit, the problem was:


It looks innocuous, but, it turns out that <> is expensive to compute and <> has many members. In the common case where the first five super cool items are found within the first six or seven candidates, a lot of computation is wasted determining whether the other candidates are also super cool. Continue reading ...

Relaunching Rujubu's View

The former incarnation of this blog was stagnate. After more than a year and a half without any new posts, I took it down until I had something new to say. That was preferable to letting it become another neglected site collecting dust on the shelves of the World Wide Web.

As of today, Rujubu's View is back. Continue reading ...