4 ms·
Python has always been adversarial to the PL communities, as seen in Guido's decision to limit the usefulness of the lambda function. He just didn't like the co
by xpressvideoz 5y ago
Python has always been adversarial to the PL communities, as seen in Guido's decision to limit the usefulness of the lambda function. He just didn't like the concept of long anonymous functions. I guess it is the inevitable characteristic of the typical "non-academic" languages, because I've also faced similar atmosphere in PHP and JavaScript too.
- Jasper_ 5y agoLanguage design is a different field and specialty than implementation. Whether lambdas are multi-line or not has no bearing on the compilers and VM runtime specialists I know who tell others to stay away. Maybe the language designers feel similarly about the direction of Python, I don't know, but that's a separate community I have much less insight into.
- Mawr 5y ago> He just didn't like the concept of long anonymous functions. And rightfully so. If a function is long enough to need multiple lines, it's also long enough to be named. Complaints about this seem to come from the functional language circles, where chaining 10 .filter()'s, .map()'s, etc. together in a single line is considered not only normal, but desirable and idiomatic. Why bother naming the intermediate results, right? The ability to stuff a million operations on a single line that, for whatever reason, seems so coveted by many is quite clearly one of the least important aspects of language design. Vertical space is cheap and plentiful. Human brain capacity is tiny. Therefore, optimize for readability not clever one-liners. This is the big benefit of a BDFL, having single a person with good taste be able to veto bad ideas. Guido, for the most part, has good taste so Python's ended up quite well designed.
- toqy 5y agoI don’t think it’s a strong argument coming from a language that will happily allow some gnarly nested list comprehensions
- School-Cotton 5y ago> If a function is long enough to need multiple lines, it's also long enough to be named. As a user of other languages, but only occasionally of Python, this type of reasoning (arbitrary limits because we think if you exceed them you’re probably structuring your code wrong) is totally alien to me. Why should the language have opinions about how I should or shouldn’t structure my code? Imagine if Rust or C++ had an arbitrary rule that you couldn’t have more than 10 functions in a class/impl; maybe it’d usually be correct style but people would still think the language making it a hard restriction was ridiculous.
- ghshephard 5y ago"Why should the language have opinions about how I should or shouldn’t structure my code?" Isn't that what attracts so many people to Python in the first place - that it does have strong opinions, and often enforces them on how people should structure their code. Python, in many places, optimizes for readability, rather than flexibility, and there is a community of users that really appreciate that. Not to say the feeling is universal (clearly isn't) - but it's at least an answer to the "why?"
- staticassertion 5y ago> Isn't that what attracts so many people to Python in the first place - that it does have strong opinions, and often enforces them on how people should structure their code. I seriously doubt it. What attracts people to Python is that: 1. It has a big standard library and until the last ~10 years installing 3rd party packages was beyond the capabilities of your average CS student. 2. It is easy to write relative to C++. If you're in data science, those are your two options, so you choose Python. Python is an extremely loose language - it's not restrictive at all in ways that matter. Is "you can't use two lines (unless you use a \)" restrictive when your language lets you arbitrarily replace functions at runtime? It's not at all a readable language imo. It is very much write-optimized. It has tons of code golfing and one liners.
- fault1 5y ago
- matheusmoreira 5y ago> This is the big benefit of a BDFL, having single a person with good taste be able to veto bad ideas. Guido, for the most part, has good taste so Python's ended up quite well designed. Good taste would be having proper lambdas. Python is a very inconsistent language and among the last things I am reminded of when I think "good taste".
- gpderetta 5y ago> Complaints about this seem to come from the functional language circles, where chaining 10 .filter()'s, .map()'s, etc. together in a single line is considered not only normal, but desirable and idiomatic. To go full circle, pandas, an extremely popular python library, forces you to do exactly that, because the straightforward imperative loop is slow as a glacier.
- earthboundkid 5y ago> If a function is long enough to need multiple lines, it's also long enough to be named. I once believed that, but I now think it’s a terrible mistake. Python ends up encouraging classes instead but classes are a much worse abstraction than an anonymous function.