Live data from Hacker News

Ask HN:Why is Perl so dwarfed in data science by Python?

news.ycombinator.com

31–40 of 120 posts

Re: Ask HN:Why is Perl so dwarfed in data science by Python?

#31
post #19

I love perl for regex scripts, where I need to quickly filter or transform a text file. I never liked it for other kinds of programming projects, for some reason to me it doesn’t feel as well suited to, say, numeric simulations. > Naturally far more efficient What does this mean exactly? One big reason for Python’s success in data science is numpy, which is far more efficient (especially on large data) than vanilla P…

Also data science requires a lot of intermediate/mockup data visualization and python puts matplotlib and scikit-learn right at your fingertips. Hard to find a match Perl side, but I might be wrong.

Add in Pandas and Seaborn and you can make some really great visualizations (of categorical data) with a couple of lines of code.

Re: Ask HN:Why is Perl so dwarfed in data science by Python?

#32
I do love Perl.

However, for data science, the biggest drawback vs Python is how you work with complex data structures. Because everything in Python is an object, (de)referencing things is generally straightforward, like:

  somelist[12]['whatever']="abc"
  mylen=len(somelist)
Where Perl devolves into a mess of sigils, when to use $ vs % vs @, wrapping references with {}, etc.

  $somelist[12]{'whatever'}="abc";
  $mylen=length(@somelist);
This gets more complex as the nesting deepens, or as you add things like objects, want to iterate keys of a dict, and so on.

Edit: A real example from the perl data structures (perldsc) man page:

  print "it turns out that $TV{$family}{lead} has ";
  print scalar ( @{ $TV{$family}{kids} } ), " kids named ";
  print join (", ", map { $_->{name} } @{ $TV{$family}{kids} } );

Re: Ask HN:Why is Perl so dwarfed in data science by Python?

#33
Data scientist here. Readable code is important in data science. People rely on our products to be based on solid numbers and logic, sometimes without any form of external validation. We can't just scribble line noise in a REPL until we get some output that looks vaguely reasonable. We need to be able to actually read the code and know that what it's doing makes sense.

So readability matters. And Python is one of the most readable languages out there. It remains relatively readable even as the code and data structure get very complex. Its syntax resembles math and pseudo-code more closely than other languages. It feels more like a tool of thought, not just a bunch of alien hieroglyphics you have to write to crudely and inefficiently express how you really think about the problem.

Perl, on the other hand, is one of the least readable languages for a general audience. It is not a tool of thought for non-experts. Its syntax is ugly, obscure, overly symbol-laden, and beloved only by gurus. The supposed "feature" of TIMTOWTDI just makes it more obscure.

The thing I can never get over with Perl is that it didn't even have a sane, idiomatic notation for functions until recently (and even today I suspect it's not widely adopted). There was no such thing as just defining a function f(a,b) of multiple named formal arguments. You had to use some special magic variable and people start talking about shift operators or some such nonsense.

This is the point at which I start saying "yes, all the language choices are Turing complete, but that doesn't mean they're all equally effective choices".

Re: Ask HN:Why is Perl so dwarfed in data science by Python?

#36
post #7

Perl had a mis-step with Perl "6" that caused a lot of the userbase to drift off.

That is the historical fact, yes. However have you looked at Raku [0] / Perl6? It is mind boggling. 0, https://www.raku.org/

is it mind boggling? depends on what you mean

Every time I look at an example I am turned off and my mind is in a way "boggled" ...

I just opened the tutorial on the Raku site I see this

   say looks_like_number "foo";
I find this awful,

right from the beginning, the say turns me off, computers do not speak, at least I really hope the computer is not actually speaking when I type that. Then there are the weird rules of quoting to not quoting ... I can't quite tell the rules are

the example is unpalatable, why does the looks_like_number word have underscores? is that a odd variable name that needs underscores? but it looks like a message to the user, what a terrible choice either way!

what does this print? I can't tell ...

Re: Ask HN:Why is Perl so dwarfed in data science by Python?

#38
post #14

Is perl more efficient than python? I don't know perl at all but the head to head performance searches I just did seem to suggest it is not.

In general Perl is faster than Python. But Python has had a lot of performance enhancements when it comes to crunching numbers so Python is faster for 'data science' stuff.

Re: Ask HN:Why is Perl so dwarfed in data science by Python?

#40
I used Perl for LAMP apps in the 90ties. Perl lost webdev to PHP (some Ruby) and science stuff to Python. Fans of OOP/functional style programming went to Ruby.

System administration never fully replaced awk/sed/bash with Perl and the new wave was all configuration management, like chef and puppet.

Python was considered to be a "clean", algol-style language, so universities started teaching it twenty years ago. Only logical after teaching Pascal for decades. Students kept using Python, so now there are lots of data science projects around.

Post reply on HN