Take, for instance, each languages' implementation of GetoptLong. In Perl, the option specifiers are short and precise. In Ruby, they're rather long-winded. Also, Perl has plenty of config options, while Ruby has three: none, optional, mandatory.
Both languages assign the values to a hash...or do they? The Ruby GetoptLong class does not actually seem to be a subclass of Hash. It appears to be some bastard child of Hash, as it does not have all of the methods of the Hash class, while adding some custom methods of its own.
Ruby lacks the convenience I'm used to. For example, if I want to use a debug-print statement in Perl, I could simply do:
if($opt{d}){ print "Debug print\n" }
You would *think* that the equivalent Ruby code would work:
if opt['-d'] # or opt.has_key?('-d')
puts "Debug print"
end
However, such is not the case. In fact, I don't know how to grab a specific option using Ruby. I can iterate over the entire object, I can pull single values in command line order, but I *can't* seem to specify a single value like that. The result is that I must assign values ahead of time in a giant 'case' statement. Yuck.
Oh, and one other thing. The ability to omit quotes in hash keys is something you don't miss until you're forced to do it in another language. Man, that gets annoying *fast*. I seem to recall that feature was added on a lark to facilitate Perl poetry (though perhaps that's a Perl 'urban legend'). Whatever the reason, thank you Larry for adding that!
Of course, it's very possible that I've totally missed something with regards to Ruby's GetoptLong. In any case, I think this is one instance where maturity trumps design.
PS - There is no GetoptStd in Ruby. Perhaps Matz felt it was redundant.
Immaturity (Score:3, Insightful)
You miss CPAN *really* *quickly* when you try to use another language. And you don't realise just how complete modules like LWP and URI really are until you try to use the equivalent for other languages. Heck, even the horrible nasty File::Spec module is more complete than the equivalent in most other languages.
Reply to This
Re:Immaturity (Score:2)
Re:Immaturity (Score:2)
RAA (Ruby Application Archive) is almost there, it's just not automated in the same way.
[*] The point being that Perl is a PITA for some things. Especially OO. And I like OO. I just don't like the whole "my $self = shift" crap that goes with it in perl. Every new OO module I write I feel like I'm re-inventing the OO wheel. Oh, and Perl is dying according to Simon, so I'm getting ready to jump ship.
gratuitous plug for Getopt::constant (Score:3, Interesting)
Or with Getopt::constant [cpan.org], just
D && print "Debug print\n";
And since it's a constant, there's compile-time constant folding!
Reply to This
Re:gratuitous plug for Getopt::constant (Score:1)