Distinctive traits of the functional languages

后端 未结 7 1709
时光取名叫无心
时光取名叫无心 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条回答
  •  一生所求
    2021-01-30 15:24

    1. Non-strict vs strict evaluation.

    2. Static vs dynamic typing.

    3. Structural vs nominal static typing. OCaml is the only language I can think of with structural typing (in both objects and polymorphic variants), which closes the gap with dynamic typing by removing the need to define many types (e.g. variant types).

    4. Hindley-Milner derivatives vs other static type inference algorithms. SML, OCaml, Haskell and F# use type inference algorithms based upon Hindley-Milner whereas Scala has only local type inference (like C# 3) and requires many more annotations to compile. (Haskell code is often full of type annotations at the function level but most are unnecessary and are added for documentation and to help the compiler in the presence of errors).

    5. Pattern matching vs manual deconstruction. SML, OCaml, F#, Haskell, Mathematica and Scheme automate the deconstruction of values.

    6. Closed sum types vs only open sum types. SML, OCaml, F# and Haskell allow closed/sealed algebraic types to be defined to strengthen static typing by conveying more specific constraints implicitly. OCaml and F# also allow open sum types whereas SML does not and Haskell requires an elaborate workaround (described by Oleg Kiselyov).

    7. Bounded-time patterns. Pattern matching is very fast in SML and (vanilla) OCaml but has unknown performance in F# due to active patterns and even unknown asymptotic complexity in Mathematica.

    8. On-the-fly compilation to native code. F#, Lisp and Scheme allow code to be generated, compiled and executed efficiently at run-time.

    9. Macros. OCaml, Mathematica, Lisp and Scheme are extensible languages.

    10. Standardized vs proprietary. SML, Haskell 2010, Common Lisp and Scheme are standardized languages whereas OCaml, Erlang, F# and Mathematica are proprietary.

提交回复
热议问题