various things i don’t like about Ruby, a compendium

by janedotx7

0. Procs versus blocks versus lambdas–really, 3 options for doing
basically the exact same thing?
1. The syntax is a little too loose–e.g. you could end up typing “foo
bar 1, 2, 3″ when you really meant “foo(bar(1,2),3)”.
2. Some bizarre names for the built-in functions. Enumerable#inject?
Array#shift? I can sort of understand “shift”, but “inject”?
3. Blocks are confusing, and there’s multiple ways of passing them in.
   def foo(&block)
      yield
   end

   def spam(block)
      block.call
   end

   foo { puts ‘hi’ }
   spam(Proc.new{ puts ‘hi’})

It just occurred to me that it’s really annoying that the syntax for
passing in blocks bans parentheses, when parentheses are valid for
every other kind of parameter. I.e. foo( { puts ‘hi’} ) will throw an
error, but add(1,2) won’t.
4. “and” versus &&, and “or” versus ||. Jesus, what is this?
5. [1,2,3][0..1] versus [1,2,3][0…1]. It looks like a typo. I
remember _why vividly described “…” as a velvet rope, but one that
sags in the middle, but despite his poignant guidance I still can
never remember which is freaking which.

In general, Ruby has a lot of weirdly redundant syntax and concepts.
Also I’m not sure how I feel about the following:
   class Array
      def sort(&block)
         #bizarre jane sorting method
      end

    end

I’ll probably decide I don’t like it. Imagine using some gem from some
dumbass who overrides “+”. Enjoy debugging that, suckers.

Advertisements