5 ms·
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
by civilized 5y ago
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".
- tyingq 5y ago>There was no such thing as just writing f(a,b) to call a function. You had to use something called "$@" or whatever Just so it's clear, you do call a function in that way... some_function($a,$b). It's how the function gets a hold of those arguments that you're talking about..the args are in an array called @_, like: sub some_function { ($first_arg,$second_arg)=@_; } And, like most things in Perl, there's lots of different ways to deal with it. Using shift(), or passing args as a hash, etc.
- civilized 5y agoThanks for clarifying, I edited accordingly.
- DonHopkins 5y agoHaving a lot of different bad ways of dealing with something is not an excuse for not having a single good way of dealing with something, which is kind of the point about why Perl has failed as a programming language.
- tyingq 5y agoI wasn't suggesting it was a good thing.
- _Mask_ 5y agoReadability is really a weak argument. I've seen a lot of unreadable code written by data scientist in Python. And a lot of readable Perl code. It's not about the language, it's about the best practices. The concept behind sigils is very simple and once you've learned it, it's not that threatening. And when talking about data structures, it is a benefit to have it more structured and know that you are dealing with an array or hash or scalar. In my opinion, Perl is not used for data science because it lacks(or people are not aware of) libraries like numpy, pandas, etc.
- deleted 5y ago[deleted]
- civilized 5y ago> Readability is really a weak argument. I vehemently disagree. When choosing among languages today, performance is mostly good enough across all languages and readability becomes the most important consideration. It's "subjective", but human beings are subjects, and subjective things are important to them. > I've seen a lot of unreadable code written by data scientist in Python. And a lot of readable Perl code. It's not about the language, it's about the best practices. This is a bad and cliche argument. Yes, there is well-written code in languages that deprioritize readability and badly-written code in languages that highly prioritize readability. That doesn't mean that any differences in the inherent, built-in readability of X and Y are moot. And "best practices", which are not widely agreed upon or followed, absolutely do not suffice to paper over this. > The concept behind sigils is very simple and once you've learned it, it's not that threatening. "Once you've learned it" or "get used to it" is the biggest programming cliche in the world. People say this about all their favorite languages and language features. I'm sure I could complain about doing data science in Brainfuck and get someone in the comments who would say it's not threatening "once you get used to it". Well sorry, but I don't want to get used to your favorite language's line noise. That's why I choose another language. That's why everyone else chooses another language. > And when talking about data structures, it is a benefit to have it more structured and know that you are dealing with an array or hash or scalar. You can keep track of types in Python with gradual typing. Most people don't bother, so evidently it's not that important in most cases, but you can do it. Other than that, no, I don't need to fill my code with more line noise to constantly remind myself what type of container I'm dealing with. That's obvious enough from the methods I'm using to manipulate the container. > In my opinion, Perl is not used for data science because it lacks(or people are not aware of) libraries like numpy, pandas, etc. No, this is after the horse has already left the barn. Those libraries were developed in Python because the authors of those libraries preferred to work in Python. The authors preferred to work in Python because of the legibility considerations I've already mentioned. Python's design and adoption were both heavily driven by a vision of readability from the very earliest stages in the 1980s/90s. People got into Python because they liked how the code looked: > A friend of mine who knows nearly all the widely used languages uses Python for most of his projects. He says the main reason is that he likes the way source code looks. That may seem a frivolous reason to choose one language over another. But it is not so frivolous as it sounds: when you program, you spend more time reading code than writing it. You push blobs of source code around the way a sculptor does blobs of clay. So a language that makes source code ugly is maddening to an exacting programmer, as clay full of lumps would be to a sculptor. - Paul Graham (http://www.paulgraham.com/pypar.html http://www.paulgraham.com/pypar.html, August 2004)
- kwertyoowiyop 5y agoGreat last sentence, I’m going to steal it!