I did some Ruby work at work today. Initial impressions:
I remember someone saying Ruby is Perl's younger, hotter sister. Well, they are clearly related. And she is hot.
But wearing the maintenance hat, exploring a code base with zero prior knowledge clearly reveals the need to document what kind of objects are being passed around in a dynamic language. I wonder if the type inferring statically typed languages (Haskell) have the same kind of issues compared to explicitly typed languages (Java).
I'm a bit curious about the phenomenon. In Perl there's "use strict" and then lexicals are declared with "my". That's such an obvious life saver and such a strongly encouraged practice that it's mind boggling to see people not using it. Not being able to use it. But at the same time... is this the way people using statically typed languages all day look at dynamic languages, not believing it's possible to live without type declarations all over the place?
There are obvious benefits for understanding the code (see above) to have e.g. type information available in method signatures (not the least the ability to do static analysis of the code for refactorings and command completion, etc), just as there are obvious benefits to not having to care about it until the latest possible moment (late binding). So there's a trade-off there. And you can keep it somewhat sane by documenting as needed (folks, more true laziness, please).
I can't see the potential advantage of not declaring lexicals. Maybe I'm missing something. Maybe I'll come around. But I'm guessing not, this seems like a genuine misfeature.
All in all, a pleasant experience.
I have the same complaint (Score:1)
Another is the semi-optional semi-colons. That fights with how I'd like to format code.
Declaring types and names: not the same thing (Score:1)
I think you are forgetting something: you can write Perl without the
varsstricture! If living without name declarations was like living without type declarations, wouldn’t we be doing that in Perl too? Yet community experience is that this is clearly unwise. Obviously, all kinds of declarationsRe: (Score:1)
BTW, I think this image [blogger.com] as a comment on non-inferring static type systems is a) hilarious, and b) insightful (from a Steve Yegge essay [blogspot.com]).
Ruby (Score:2)
Sounds like a person-who-developed-the-app thing.
Sounds like a documentation problem again. BTW, you may be interested in Python's function annotations [python.org].
Re: (Score:1)
You mean
use strict 'vars'wrote itself into your Perl programs no matter how hard you tried to erase it? Weird.