←back to thread

317 points est | 1 comments | | HN request time: 0.205s | source
Show context
amelius ◴[] No.17448876[source]
If they add anything to Python, it should be the ability to do functional-style programming without hassle. Right now it's almost impossible to compose functions in an inline style such as used in functional programming languages. Yes, there's lambda, but it doesn't extend into multiple lines, and applying a function to a bunch of lambdas directly leads to line-width overflow. Even JavaScript has better support for functional-style programming. Perhaps Guido should spend a year writing Haskell :)
replies(8): >>17448904 #>>17448927 #>>17448972 #>>17449048 #>>17449482 #>>17450517 #>>17450691 #>>17451251 #
sametmax ◴[] No.17449482[source]
Haskell has always officially inspired Python tooling. But Python does things in it's own way, and they are not random, they are the result of an opinion.

First class citizen functions, short lambdas, comprehension lists, generators, map(), filter(), itertools, operator and functools are quite a rich toolbox already. But you won't have more. It's a choice.

The idea is to have enough to be productive, and not enough to be dogmatic. The experience of Guido, and it's one that I share, is that too much functional tooling drives a style that favors expressive writing at the expense of ease of reading.

It's not by chance that LISP and Haskell are considered hard languages to get into, while Python is considered easy to start with.

It has a cost, since no language is perfect, but that's the path this language follows and requesting a snake to fly will only bring you disappointments.

Python tries to strike the balance between the importance of a rich expressiveness and the non negotiable necessity of keeping the code readable: you read a line much more often that you write it, after all. It's a key philosophy of the language. It shaped and will shape numerous decisions around it.

This PEP is a perfect example : it tooks years for the concept to be integrated in Python, and the last debate about this concrete implementation took months. The result is a carefully crafted feature with a lot of details to discourage abuse and remove the needs for pondering when to use it or not.

replies(4): >>17451047 #>>17453462 #>>17453721 #>>17461155 #
1. marcosdumay ◴[] No.17453721[source]
Map, filter and a lot of the itertools contents lose most of their possible power if you let easy lambdas and function composition out.

The only dogmatic position here is the Python one, that based on opinion alone, and is leaving a lot of good structures out for no gain at all.