Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

jplindstrom (594)

jplindstrom
  (email not shown publicly)

Journal of jplindstrom (594)

Tuesday November 27, 2007
05:31 PM

Ruby -- first impressions

[ #34989 ]

I did some Ruby work at work today. Initial impressions:

  • It's very Perlish. Mostly in a good way. No value sigils, but overall tighter syntax. No ugly dereferencing brace fest, and methods on basic datatypes makes for clean code if you are willing to make an effort.

    I remember someone saying Ruby is Perl's younger, hotter sister. Well, they are clearly related. And she is hot.

  • The block syntax is really nice.
  • Very sparse documentation of method definitions in this app. Not sure whether that's a project thing or a general Ruby/library thing. I mean, It's not like I have been spoiled rotten with well documented Perl enterprise source code historically.

    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).

  • In Ruby, local variables are created on first use. No declaration of these seems... well, insane. This already bit me, and I've been using Ruby for, what, a day?

    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.

  • There seems to be two kinds of exceptions, those you "raise" and those you "throw". There is a distinction, I haven't quite figured out what it is yet though :) Right now I just find it interesting. Off to the manuals.
  • Lanuage documentation is decent. Usually a quick Google for anything yields useful results. Same seems to hold for ActiveRecord and friends, but I haven't been doing anything interesting with it yet.

All in all, a pleasant experience.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Not having an option to force declaration of variables is a mistake and is one of my main complaints about the language.

    Another is the semi-optional semi-colons. That fights with how I'd like to format code.
  • 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?

    I think you are forgetting something: you can write Perl without the vars stricture! 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 declarations

    • Well, I agree. I was just reflecting on the mindset and attitude of the static typer.

      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]).
  • Very sparse documentation of method definitions in this app. Not sure whether that's a project thing or a general Ruby/library thing.

    Sounds like a person-who-developed-the-app thing.

    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.

    Sounds like a documentation problem again. BTW, you may be interested in Python's function annotations [python.org].

    I'm a bit curious about the phenomenon

    • It’s one of the things I can’t stand about Perl and one of the reasons I switched.

      You mean use strict 'vars' wrote itself into your Perl programs no matter how hard you tried to erase it? Weird.