alexey_rom (
alexey_rom) wrote2010-03-11 02:57 pm
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Откровения Guido van Rossum о функциональных языках
Цитата из Masterminds of Programming:
Перевод:
Python probably has the reputation of supporting functional programming based on the inclusion of lambda, map, filter and reduce in the language, but in my eyes these are just syntactic sugar, and not the fundamental building blocks that they are in functional languages. The more fundamental property that Python shares with Lisp (not a functional language either!) is that functions are first-class objects, and can be passed around like any other object. This, combined with nested scopes and a generally Lisp-like approach to function state, makes it possible to easily implement concepts that superficially resemble concepts from functional languages, like currying, map, and reduce. The primitive operators that are necessary to implement those concepts are built into Python, where in functional languages, those concepts are the primitive operations. You can write reduce() in a few lines of Python. Not so in a functional language.
Перевод:
Считается, что Python поддерживает функциональное программирование, скорее всего из-за включения lambda, map, filter и reduce в язык. Но с моей точки зрения это просто синтаксический сахар, а не основные строительные блоки, которыми они являются в функциональных языках. Куда более фундаментальным свойством, общим для Python и Lisp (который тоже не функциональный язык!), является то, что функции — объекты первого класса, и могут передаваться так же, как и любой другой объект. Это, в сочетании с вложенными областями видимости и в общем близким к Lisp'у подходом к состоянию функций, позволяет легко реализовать возможности, поверхностно напоминающие о таких возможностях функциональных языков, как карринг, map, и reduce. В Python встроены примитивные конструкции, необходимые для реализации этих понятий; а вот в функциональных языках они сами и являются примитивными конструкциями. В Python достаточно нескольких строк, чтобы написать reduce(). В функциональных языках это не так.