News for hackers. Stuff that matters.
Re:How to Learn Perl by vtail on Thursday September 29, 2011 @06:19AM (#3051847)
An honest question: are there any reasons to learn Perl these days (as opposed to Ruby/Python/name your favorite scripting language)? Some people need to maintain existing Perl codebases for sure, but they should know Perl already?
Re:How to Learn Perl by jbert on Thursday September 29, 2011 @06:41AM (#3051900)
It's an interesting question.

I would hazard a guess (with nothing really to back me up other than a quick google search and my memory of the data I have seen presented on this subject in the past) that perl has a slight performance edge (cpu and memory) over python and more so over ruby. That isn't a great argument though, since they are all in roughly the same performance class.

I think the main difference between those three languages is cultural, rather than technical.

So to answer your question I guess I'd say: "Because you find the perl culture and community (and it's technical mores - such as it's approach to testing, documentation) more to your taste than the other languages". Basically if you prefer "TIMTOWTDI" to "pythonic".

But practically speaking, given the similarity between them, I'd guess you're likely to stick with the first of those you learn thoroughly, unless you change job or are swayed by "Perl is dead!/Perl is ugly!", "Ruby is slow!/Monkey patching is evil!" or "Whitespace-sensitivity is bad!/Broken lexical scoping is broken!" or whatever other clarion call washes through various blogs.

Personally, I really like the partial static checking perl does with strict mode on and I feel a little horrified that python doesn't provide that safety net (I don't know if Ruby does).

Re:How to Learn Perl by danssig on Thursday September 29, 2011 @06:55AM (#3051942)
I'm not sure there's even a slight edge in performance these days and even if there were, you have more options with Ruby/Python (e.g. IronRuby/IronPython for the JVM, etc.).
Re:How to Learn Perl by jbert on Thursday September 29, 2011 @07:11AM (#3051973)
One data pt - micro benchmark on the default versions of perl/python/ruby on ubuntu 11.04. Sum the numbers up to 10,000,000 using a straight while loop. Run several times on idle system, took representative value. Runtime includes startup time.

I know this is a dumb benchmark, but I think it backs up my general pt about performance above. (JVM/CLR implementations are interesting - are they widely used?)

    python2.7.1: 2.0s
    perl5.10.1: 1.3s
    ruby1.8.7: 4.3s
python code below (perl+ruby are direct transliterations. Yes, there may be a more idiomatic way to write it in all languages, I'm trying to do a very simple apples-to-apples comparison of each languages dominant production VM implementation):

    total = 0
    i = 10000000
    while (i > 0):
        total += i
        i -= 1
    print "total is ", total
Re:How to Learn Perl by danssig on Thursday September 29, 2011 @07:36AM (#3052031)
I meant to say "in general performance", i.e. of a complete application. Micro benchmarks mean less than nothing in that case.

Python is obviously plenty fast: Blender (3D modeling application) is written in it. There is also Twisted and all that other stuff.

>are they widely used?

My impression is that they are. The JVM is everywhere these days.

Re:How to Learn Perl by jbert on Thursday September 29, 2011 @08:10AM (#3052107)
> I meant to say "in general performance", i.e. of a complete application. Micro benchmarks mean less than nothing in that case.

Could you give me some info on why you think there isn't a performance edge "these days"?

Or are you making the point that all these languages are "fast enough" and so a perf difference between them isn't important for real-world use?

> Blender (3D modeling application) is written in it.

I'm surprised that the performance-critical parts are in python. Do you know if the rendering etc is in python or is it at python UI on a C core?

Re:How to Learn Perl by danssig on Thursday September 29, 2011 @08:50AM (#3052215)
>Or are you making the point that all these languages are "fast enough" and so a perf difference between them isn't important for real-world use?

I'm saying perl might be faster at some loop that adds 1s together, but ruby might be faster at networking and python might be faster at method calls, etc. When you weight it all together it equals out.

In other words, if you wrote a big enterprise trading application in all 3 languages (i.e. write it 3 times with the best practices of each language) and then only looked at charts showing various performance benchmarking results of the application I think you'd find all 3 very close in performance.

>Do you know if the rendering etc is in python or is it at python UI on a C core?

I thought it was last time I looked but I'm not certain.

Re:How to Learn Perl by DrPheltRight on Thursday September 29, 2011 @07:43AM (#3052043)
I believe IronRuby and IronPython are actually for .NET whereas JRuby and Jython are for the JVM.
Re:How to Learn Perl by danssig on Thursday September 29, 2011 @08:55AM (#3052238)
You're right, of course. So that means that while perl runs on every major OS, python and ruby run on every major OS, the JVM and the CLR (and can use the libraries from each of these).
Re:How to Learn Perl by code4pay on Thursday September 29, 2011 @06:59AM (#3051951)
We started a new project a year or two ago and evaluated using Perl,Python Ruby and the main factor in the reason to use Perl was that the libraries for our particular usage cases where better in Perl than the others at that time. For LDAP and SNMP in particular there exists Pure Perl Libraries that are very mature, at the time similar libraries for Ruby and Python where just wrappers around C classes and not as mature (Might be different now).

Java might have been a good choice in this regard as well but our team was used to using Dynamic languages.

I would suggest that anyone looking at a particular language should consider what they want to achieve and then investigate the existing libraries etc to complete that task.

Having committed to using Perl we have had no regrets things like Moose and roles IMHO put it on par with Languages like Python and Ruby. Edit: Formatting

Re:How to Learn Perl by singingfish on Thursday September 29, 2011 @07:18AM (#3051992)
Perl probably creates about 75% of my income. That's working on current modern projects. Mostly we don't have to do too much wheel-reinvention because of CPAN. Yes it's worth learning perl.
Re:How to Learn Perl by danssig on Thursday September 29, 2011 @08:52AM (#3052225)
This was the case years ago but by now with all the people working in python and ruby I don't believe for one second that CPAN has some commonly needed library that they don't.

And if your only consideration is the size of the library, don't bother with perl. Java's library collection dwarfs it easily.

Re:How to Learn Perl by chromatic on Thursday September 29, 2011 @01:04PM (#3053296)
Java's library collection dwarfs it easily.

I've seen (and track) CPAN's numbers. Where can I see similar statistics for Java's library collection?

Re:How to Learn Perl by danssig on Friday September 30, 2011 @07:51AM (#3056580)
Are you seriously challenging this? Java was the number 1 language for years with all kinds of big businesses throwing people at it. Java easily has more libraries than any other language. No matter how obscure the subject, I've never had trouble had trouble finding a Java library for it (usually several).

No, I'm not aware of a central CPAN-like repo for Java, so what?

Re:How to Learn Perl by chromatic on Friday September 30, 2011 @02:26PM (#3058059)
Are you seriously challenging this?

If what you say is true, you should easily be able to provide hard numbers.

Re:How to Learn Perl by danssig on Monday October 03, 2011 @05:33AM (#3065615)
Fine, you caught me. I'm indeed to lazy to go look this up for you just to prove that Java has more libraries than some dead (as in COBOL-dead) programming language.
Re:How to Learn Perl by berntb on Thursday September 29, 2011 @07:07PM (#3054723)
>>CPAN has some commonly needed library that they don't.

There is a long tail for libraries, too. That is, the sum of all seldomly needed libraries is big. So you will often find yourself in need of libs where you'll get a better hit rate on CPAN.

Re:How to Learn Perl by danssig on Friday September 30, 2011 @07:52AM (#3056584)
Not than Java, no way.