Distinctive traits of the functional languages

后端 未结 7 1793
时光取名叫无心
时光取名叫无心 2021-01-30 14:45

It is known that all functional languages share some basic properties like using functions as basic building block for programs with all the consequences like using recursion in

7条回答
  •  萌比男神i
    2021-01-30 15:40

    There are many differences but only two differences I'd categorize as fundamental in that they make a big difference to your development:

    1. Dynamically typed vs static, polymorphic type system with algebraic data types and type inference. A static type system restricts code somewhat, but has many advantages:
      • Types are documentation that is checked by the compiler.
      • The type system helps you choose what code to write next, and when you're not sure just what to write, the type system helps you easily and quickly rule out many alternatives.
      • A powerful, modern, polymorphic type system is unreasonably good at detecting small, silly, time-wasting bugs.
    2. Lazy evaluation as the default everywhere vs lazy evaluation restricted to carefully controlled constructs.
      • Lazy vs eager has tremendous implications for your ability to predict and understand the time and space costs of your programs.
      • In a fully lazy language, you can completely decouple production of data from decisions about what to do with data once produced. This is especially important for search problems as it becomes much easier to modularize and reuse code.

提交回复
热议问题