This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Have you found any common obstacles that newcomers to Ruby routinely face?
In your opinion, are there any language features that seem more difficult to grasp?
Do you find certain patterns that developers with prior OO experience exhibit when first tackling Ruby?
When I've taught developers who have come from languages like PHP and Cold Fusion, there has been a confusion over the flexibility of the syntax in many cases. One key example is stuff like:
puts "x is even" if x % 2 == 0
Versus the more traditional (but lengthier and less idiomatic):
if x % 2 == 0
puts "x is even"
Another stumbling block is the "pure" object oriented nature of Ruby. A lot of developers seem to be used to arbitrarily mixing procedural ideas with object oriented ones. In Ruby you can do this but in reality you'd try to avoid it as much as possible. Even in a similarly dynamic language like Python, there's a heavy reliance on functions.. such as using len(str) rather than str.length, or similar.
I find that most of the stumbling blocks come from assuming Ruby is as inconsistent or "mixed" as other languages, when really the standard is to try and keep things as simple as possible. Ruby tends to assume it's easier to learn operators than structural syntax, so while you won't see so much "structural" definitions or endless initiators as in Java, you'll instead see operators or shortcuts.
Consider this Java-ish example (I know this isn't Java, but it's a similar style):
arr = Array.new
Versus the more Ruby-esque:
arr = 
arr << 10
arr << 20
You *can* write Ruby in the former, more Java-esque way, but you'd tend to write more idiomatically as in the second example.
Regarding certain patterns that existing OO developers find tough, I'd say that from certain languages (such as Java), the lack of multiple inheritance can be "interesting" to start with The existence of modules that are then mixed in to classes can also provide a little bit of a learning curve, but it's mostly about changing expectations than learning anything hard.
Interesting. I've found many of my Java peers to be deeply offended at "multiple ways" to do the same thing. I've found passing blocks/closures to be a new challenge simply because I haven't done a lot of it.
I found this code: arr << 20 to read well after using Ruby a bit, though from the outside it looks "Perlish" to my peers.