Archaic Perl
perliscope.blogspot.com
perliscope.blogspot.com
Put another way, when I'm actually working on a project in the language, what's the likelihood that someone who I'm working with or who worked on the project before me has really messed up the code base in ways I'm going to be dealing with for years? And how hard am I going to have to work to not be that guy?
Finally, the article uses an example of parsing LaTeX with Perl vs. Python, and uses a regular expression. Now, I don't know if LaTeX can, in general, be parsed with regular expressions, but writing a parser aside, it's no surprise that Perl wins when dealing with regular expressions. That's a fine thing, and definitely something Perl's got going for it (or possibly against it, depending on how you feel about regular expressions), but Perl just about grew out of being a regexp DSL -- it's not really a fair fight. Put a full Perl TeX parser up against one written in Prolog, and I bet Prolog would win, but it doesn't mean I'd use Prolog over Perl for most things.
Well, the quality of Perl code is very diverse, since a lot of system administrators are mangling the language... :-)
Perl's general community seems to be very good (newbies went with PHP for quite a while). You can arguably see the CPAN as a result of that. (It is common to say -- "Perl is irrelevant, the killer app is CPAN!".)
Another advantage is that Perl doesn't have so many embarrassing fanboys as certain other environments...
(I believe the hype level regarding the scripting languages comes from them being so similar that they compete for the same niche.)
Since Moose seems to standardize a solution to the OO syntax ugliness, the main Perl problem is IMHO the parameter passing to functions/methods. There are advantages and disadvantages to most everything.
Edit: Small syntax/word choices. Removed ":-)" on comment that other environments have too many fanboys, language wars are such a time waste.
Steve Yegge says it best: "Within about 3 days, I was more comfortable with Ruby than seven years had made me with Perl. I was still accidentally sticking "my" in front of variable declarations, typing "sub" instead of "def", little things like that. But I was already starting to think in Ruby, and suddenly I had all this extra space in my brain. You have to learn Perl by memorizing, but you learn Ruby by understanding."
My prediction is that other languages will not build their CPAN equivalents soon. It looks so easy to copy, especially if you believe you have a better language, but what people don't see is the complex network of things that enable CPAN existence. It's not just code repository it is a complex ecosystem.
... prevents bugs.
> ... the disaster than is OOP
Lifted wholesale from Python.
> You have to learn Perl by memorizing....
Some of us learned it by understanding.
Nowadays I use Ruby if I have a choice: most of the best bits of Perl, less of the worst bits. The language actually feels like it was designed, rather than accreted over time.
Perhaps Perl 6 will be better, but I'm guessing scripts and apps written in Perl 5 will be around for a long, long while yet.
It is very good for building complex applications, however.
Why is this news?
In my professional career I've used C, C++, Perl, and Ruby.
I come with no preexisting biases.
...but after having written several programs in Perl until they became unmaintainable (despite my good coding style), and then rewritten them in Ruby in something like 1/10th to 1/20th the lines... I've got no particular interest in spending time reading about how Perl is wonderful.
I've been there.
I gathered my own data.
See Paul's thoughts on blub programmers and blub languages.
Could you please share a sample of code that takes 20 times more lines in Perl than Ruby.
Let's say that there are 40 different types of entities.
I could write custom views for each of these.
Or, using Ruby's reflection, I had them all share common views which then use reflection to figure out the basic data and the relationships between data types.
E.g.:
<% reflections = item.class.reflections.select {|key, val| [ :has_one, :has_many, :belongs_to, :has_and_belongs_to_many ].include?(val.macro) }.to_array
reflections.each do |key,val|
if ! reject.include?(key)
%>
<h1> <%= key.to_s %></h1>
<% bullet_pts = item.send(key).to_array
if bullet_pts.empty?
%>
<span style="padding-left:25px;"><i>none</i></span>
<% else %>
<ul>
<% bullet_pts.sort_by {|x| x.methods.include?(:name) ? x.name : 0}.each do |subitem| %>
<li><%= linktext = subitem.respond_to?(:name) ? subitem.name : (subitem.respond_to?(:text) ? subitem.text : subitem.id )
# TJICFIX P3: this is an ugly way to specify a link. do it better!
link_to(linktext, :controller => subitem.class.to_s.pluralize.underscore, :action=>:show, :id =>subitem.id) + "<br>" %>
<% end %>
</ul>
<%
end # if "none" else "lots!"
end # if ... reject
end # reflections.each
%>
With the above as a partial, and one other that's similar, a full view for a very very complicated object becomes this: <%= render (:partial => 'admin/shared/show_basicdata', :locals => { :item => @item }) %>
<%= render (:partial => 'admin/shared/show_relations', :locals => { :item => @item, :reject => [:category_courses] }) %>
I'm reworking this approach for a new project right now. The new code goes beyond "index" and "show" views to "edit" and "create" views. Also, because most of the controllers are pretty similar, except for business logic, I'm also about to start compressing those down with metaprogramming (except for callbacks, which will vary).In this particular codebase, I think that the expansion to rewrite it in Perl would be much more than 20x. Maybe more like 100x ... or 200x.
What is the Ruby-unique feature not existing in e.g. Moose?
(I'm not a real web programmer these days, but is it still common to template with code PHP-style, like that?)
Edit: Emphasis on my point, since I only got an answer to my humorous note that these days, most languages have reflection functionality.
We were debating PERL vs. Ruby. Java's irrelevant.
I do know Perl thought, and I also know few other languages, including say Groovy.
And while there certain tasks which can be expressed in Groovy better, there are also others who are better expressed in Perl! And I think it would be the same for Ruby!
Ultimately, Perl, Groovy and Ruby all fall under the same category and are more or less the same type of things!
Perl is still a very good choice for code creation and software developed because: 1) It has very competitive feature set 2) Huge library set 3) The best community 4) It is still evolving
I am sure we can almost do a s/Perl/Ruby on this post and it would still make sense.
People who are defending Perl do so, because they want it to grow, and as Perl grow they grow with it. If you have ever been passionate about anything, you should understand where the people who defend Perl come from!
I agree with another poster. I'd love to see the data that you gathered.
I've worked fairly extensively with both Perl and Ruby, and I have a hard time imagining anything which is 10-20x shorter in Ruby than in Perl. I also have to question the maintainability assertion. Ruby and Perl are similar enough that I'm pretty sure I can take a "maintainable" program in either one and port it to the other with minimal changes and no noticable change in maintainability.
Without intending to flame, I can't imagine that you'd say this if you've used some of the more powerful techniques in Ruby.
If you've used techniques X,Y, and Z in Perl, you can find them in Ruby. ... but unless you think in a Lisp-like way, you won't even realize that techniques G' and E''' exist in Ruby, but not in Perl.
So, once again, how about some of that data you say you collected to back up what you're saying? Which "more powerful techniques" are you talking about?
If the same thing happens again terseness, power and flexibility win against ridged ideas of how programs/command-lines should be written.
Perl exploded with the web, however before the web it was widely used. It might not be the web programming language of choice but it it's still great at manipulating information, processing large files and general administration.
I think it is important to know when to use a quick shell script, and when to solve the problem with some Perl (or even some C.) Sometimes it is quicker to throw together a shell script, with a bit of sed, awk, or some simple for loops, automating the command line you just manually ran a moment ago; sometimes it's best to solve the problem by switching to some Perl.