Ryan Leavengood
4/29/2005 4:57:00 PM
Robert Klemme wrote:
>
> Folks, please once and for all drop the idea of static typing in Ruby.
> Thank you!
I agree. Let me segway into a story related to this that I hope you will
find interesting:
During college I took an Artificial Intelligence (AI) class. In this class
the language we used for solving AI problems was Lisp. This was my first
exposure to Lisp, having previously only used Java or C in my other
classes. Other students in the class were similar.
Once I learned we would be using Lisp I took it upon myself to learn more
about the language and it's idioms, etc. This is just a habit of mine that
has proved very useful over the years as I've tried new languages.
Our main project for the class was an AI to solve a fairly simple game. I
was able to complete this project fairly easily and had fun. I used Lisp
idioms (tail recursion, simple functions, etc.) and in the end I had a
well-written, fairly small program that solved the problem well. Others
who also learned the Lisp idioms faired similarly. But there were several
students in the class who, for whatever reason (laziness,
close-mindedness, naivete) decided to write their Lisp AI program using a
style reminiscent of Java (essentially procedural, even though Lisp is a
functional language.) In one example the resulting program was probably 3
times as large as mine, ugly, hard to read, and to make matters worse, it
didn't even solve the game correctly! Now maybe this was just a bad
student, but I think the biggest problem was his inability to learn and
use Lisp idioms.
The moral? When developing in a certain programming language, the most
efficiency and ease of use can be had when following the languages design
and idioms. Ruby is dynamically typed, and trying to force it to a static
typing paradigm is going against the language and its idioms.
When coding Java, use the Java Way.
When coding C++, use the C++ Way.
When coding Ruby, use the Ruby Way.
Simple as that :)
Regards,
Ryan