I have just recently read an old paper by Wirth "On the Design of
Programming Languages", which started me thinking about dynamic typing.
One of the lessons he enumerated:
"Design languages such that most checking operations can be performed at
compile time, and need not be deferred until execution. The concept of
static data types of variables is essential in this respect, and enhance
both programming security and system efficiency."
Hoare also has similar comments about static typing.
Now, given that ruby is interpreted, much of the efficiency and type
safety aspect might not matter (though, if/when it gets bytecode
compiled, I can see that static typing can improve both).
However, it seems that dynamic types can be more error prone and harder
to read, since we can't be sure what type of object a variable holds. I
guess what I'm asking is: given the advantages of a statically typed
language, does dynamic typing offer any benefits? What is the reason
behind ruby's dynamically typed variables?