官术网_书友最值得收藏!

The stack of turtles

When we use Python for functional programming, we embark down a path that will involve a hybrid that's not strictly functional. Python is not Haskell, OCaml, or Erlang. For that matter, our underlying processor hardware is not functional; it's not even strictly object-oriented, CPUs are generally procedural.

All programming languages rest on abstractions, libraries, frameworks and virtual machines. These abstractions, in turn, may rely on other abstractions, libraries, frameworks and virtual machines. The most apt metaphor is this: the world is carried on the back of a giant turtle. The turtle stands on the back of another giant turtle. And that turtle, in turn, is standing on the back of yet another turtle.

It's turtles all the way down.
- Anonymous                    

There's no practical end to the layers of abstractions.

More importantly, the presence of abstractions and virtual machines doesn't materially change our approach to designing software to exploit the functional programming features of Python.

Even within the functional programming community, there are both purer and less pure functional programming languages. Some languages make extensive use of monads to handle stateful things such as file system input and output. Other languages rely on a hybridized environment that's similar to the way we use Python. In Python, software can be generally functional, with carefully chosen procedural exceptions.

Our functional Python programs will rely on the following three stacks of abstractions:

  • Our applications will be functions—all the way down—until we hit the objects
  • The underlying Python runtime environment that supports our functional programming is objects—all the way down—until we hit the libraries
  • The libraries that support Python are a turtle on which Python stands

The operating system and hardware form their own stack of turtles. These details aren't relevant to the problems we're going to solve.

主站蜘蛛池模板: 进贤县| 镶黄旗| 苏尼特右旗| 青州市| 温泉县| 楚雄市| 阳信县| 酒泉市| 信宜市| 长丰县| 平南县| 清苑县| 嘉荫县| 崇仁县| 苍梧县| 兴仁县| 平谷区| 东阳市| 蓬安县| 安远县| 耒阳市| 宾川县| 涞水县| 肃宁县| 马鞍山市| 南昌县| 新余市| 根河市| 土默特右旗| 封丘县| 德格县| 奉节县| 贵溪市| 苏尼特左旗| 东台市| 罗城| 桂东县| 汾阳市| 年辖:市辖区| 康定县| 荣成市|