Tuesday, March 3, 2009

What do Rubyists like about Ruby?

I put together a totally unscientific gimpy little web poll and posted it to the ruby-talk mailing list, asking Rubyists what their favorite Ruby features are. I received a little over 60 responses. Here are the top 10 (at the time this was posted):
  1. Blocks (71%)
  2. Lambdas / Procs (57%)
  3. Mix-ins / Modules (55%)
  4. Open classes / monkeypatching (53%)
  5. Duck-typing (53%)
  6. First-class regexps (49%)
  7. Metaprogramming (49%)
  8. Syntactic sugar e.g. val ||= x; array <<>
  9. Optional parens / English-like readability (44%)
  10. Object#method_missing (42%)
There's no real surprises here. Rubyists love their blocks, but perhaps even more than that, Rubyists love closures. Talking to some other people about lambdas / procs being so high, the general sentiment was that they were a feature which was used somewhat infrequently but was very handy when needed.

The mixin approach to inheritance is also quite popular. This lies alongside open classes and monkeypatching. Rubyists really seem to enjoy the ability to manipulate code inside the runtime environment, and we also see metaprogramming not too far down the list.

First class regexps have always been one of my favorites and I was glad to see they fared well. Beyond that, the type system, syntactic sugar, and method_missing were also popular.

I've left the poll open if you'd still like to vote:

  • Creating Domain Specific Languages
  • Ternary expressions e.g. foo ? bar : baz
  • Object#class / Object#is_a?
  • Object#method(s) / Module#instance_method(s)
  • Reflection
  • Lambdas / procs
  • Mix-ins / Modules
  • Object#instance_eval / Object#instance_exec
  • Redefining the behavior of core types
  • Standard library (and its use of blocks)
  • Instance-specific behavior / metaclasses
  • First class regexps
  • Optional parens / English-like readability
  • Definable MyObject#method=
  • Module#module_eval / Module#class_eval
  • Use of operators by core types (e.g. Array#*)
  • Object#method_missing
  • Operator overloading (in novel ways)
  • RubyGems
  • Open classes / monkeypatching
  • Syntactic sugar e.g. val ||= x; array << val
  • Code in class body (and metaprogramming with it)
  • Duck typing
  • Enumerators (Ruby 1.8.7+/Ruby 1.9)
  • Embedding code in strings with "#{mycode}"
  • Definable MyObject#[] and MyObject#[]=
  • Enumerable
  • Blocks
  • Singleton classes
  • Module#define_method
  • Splats e.g. method(*args)
  • ObjectSpace
  • Metaprogramming
  • Object#instance_variable_get / Object#instance_variable_set
  • Continuations e.g. callcc
  • MyObject#method? and MyObject#method! idiom

1 comment:

Eltiare said...

I was going to actually take your poll, and then I realized that I would check almost every one of the boxes! I <3 Ruby.