4 ms·
Is there any point for new programmers to learn Perl, when they have the choice of Ruby (which supposedly is inspired from Perl) ?
by manish_gill 13y ago
Is there any point for new programmers to learn Perl, when they have the choice of Ruby (which supposedly is inspired from Perl) ?
- timr 13y agoPerl is very different than Ruby. It's also very different than Python. It's also faster and more concise than both. You should learn Perl because you're likely to encounter a lot of Perl code in the wild, and because you can learn something from it. Knowing how to generate a Perl one-liner that does something incredible will take your CLI skills to a new level in a way that knowing Ruby will not. Perl is still one of my go-to languages for sysadmin scripts, because it's so concise and powerful. It's a long-beard language.
- protospork 13y agoThank you, that's a better-written answer than anything I could get down. I'd just like to add that (as the article does a pretty good job of saying) perl is /unparalleled/ as a text-processing language. There is no other language that even comes close to perl's ease and utility for string manipulation.
- sliverstorm 13y agoThis is why Perl is my main workhorse. I process text almost exclusively.
- timr 13y agoThat's a good point. When I think over what I use Perl for in practice, it's usually some form of text processing. Perl is just the swiss army knife of I/O munging.
- obviouslygreen 13y agoThe only part of this I'm going to take issue with is "You should learn Perl because you're likely to encounter a lot of Perl code in the wild." "...because you can learn something from it" is a far better reason, because it's actually valid. Now, specifying what you're suggesting could be learned would be a good step, but I'd take it as-is without a problem. The former, though? No, Perl is no longer occupying visible roles to the point where any new programmer can assume they'll be seeing it at all, much less "encounter a lot of Perl in the wild." It's out here, sure, but it's hidden in commands we use or scripts invoked by background tasks non-systems-programmers have absolutely no reason to touch. Learning to do irresponsibly illegible things in Perl will teach you some great regex and... Perl. Learning Ruby (or Python, or Java, or even PHP) will get you actual work -- that doesn't involve being sequestered in backwards academia -- far more often now than Perl.
- PySlice 13y agoWhat one can learn from Perl: When programming in a language you hate, don't take naming arguments for granted. It could be worse: you could be programming in Perl, where all arguments come in a flattened array.
- kbenson 13y agoThis is really not much of an issue, if you bother to learn the language. If you don't, then yes, things will be confusing. sub named_params { my %P = @_; # named params in hash %P my $foo = $P{bar} + $P{baz}; return $foo * $P{multiplier}; } my $rvalue = named_params( foo => 1, bar => 2, multiplier => 3 ); Or, some people prefer to just pass in a hash reference: sub named_params_hashref { my $P = shift; my $foo = $P->{bar} + $P->{baz}; return $foo * $P->{multiplier}; } my $rvalue = named_params_hashref({ foo => 1, bar => 2, multiplier => 3, }); But of course, why bother letting common sense, and a single line of code stand in the way of your chance to deliver a pithy remark?
- berntb 13y ago"PySlice" with karma 25 is probably your trolling account. If not, ASK about stuff you have no clue about. It is better than looking like a little troll kid, having "fun" lowering the quality of HN by stupid language war comments. >>where all arguments come in a flattened array That is optional, through the power of CPAN (and kbenson's methods, of course). Examples of alternatives: http://search.cpan.org/~barefoot/Method-Signatures-20130222/lib/Method/Signatures.pm http://search.cpan.org/~barefoot/Method-Signatures-20130222/... http://search.cpan.org/~flora/MooseX-Declare-0.35/lib/MooseX/Declare.pm http://search.cpan.org/~flora/MooseX-Declare-0.35/lib/MooseX... http://search.cpan.org/~ether/MooseX-Method-Signatures-0.44/lib/MooseX/Method/Signatures.pm http://search.cpan.org/~ether/MooseX-Method-Signatures-0.44/... (Depending on if you use Moose or not.) One of the cool parts of Perl is that the language is extensible, that is why it e.g. has a better OO than Python, Ruby, etc. (Or simple typing of parameter arguments, see the modules above. Or why MooseX::Declare has ... ah, look yourself, troll.)
- 13y ago