Ruby has no types
This might be hailed by people doing quick prototyping, but for anyone whose first language is strongly typed, you feel like your walking stick is taken away. "Er..., am I supposed to use an integer or a float here?", then it's time to look up doc (if there's no doc, then you'll need to read code).
This coupled with the implicit declaration of variables can catch you sometimes.
Some IDEs might help you solve this issue (since Ruby is interpreted, there's no compiler to help you with type checking), but I'm still trying them out at this moment.
For example, blocks and Lambda are very similar ideas, but are treated differently.
Here the block is passed in directly and is invoked using "yield" keyword.
This coupled with the implicit declaration of variables can catch you sometimes.
Some IDEs might help you solve this issue (since Ruby is interpreted, there's no compiler to help you with type checking), but I'm still trying them out at this moment.
Ruby has unusual functional style
I am a Haskell and Scala user, so I am familiar with the idea of high order functions and closures. What I find strange with Ruby is that it comes with different rules of doing similar things.For example, blocks and Lambda are very similar ideas, but are treated differently.
Here the block is passed in directly and is invoked using "yield" keyword.
def open_and_process(file) f = File.open(file) yield f f.close() end open_and_process("readme") { |file| ... }
And here we pass in a Proc.
def open_and_process(file, &process) f = File.open(file) process.call(f) f.close() end open_and_process("readme") -> file { ... }I don't see the need to treat a block differently from a Lambda, apart from being more readable.
And here is what the similar code would be in Scala
def open_and_process(file: String, process: File => Unit) val f = new File(file) process(file) f.close() end open_and_process("readme", f => { ... })IMO, I feel the Scala syntax more readable. Also Scala treats methods as objects, so a method can be passed into other high order functions as parameters.
TBC