功能语言的独特特征 [英] Distinctive traits of the functional languages

查看:173
本文介绍了功能语言的独特特征的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知,所有功能语言共享一些基本属性,例如使用函数作为具有所有后果的程序的基本构建块,如使用递归而不是迭代。然而,也存在一些根本性的差异。 Lisp使用Lisp代码和数据的单个表示,而ML没有ML代码的标准表示。 Erlang具有内置的基于actor的并发功能。哈斯克尔有单子。 Haskell在静态类型系统中区分纯粹和不纯的功能; ML没有。



其他功能语言(Clojure,F#,Arc,any other)之间有什么独特的基本区别?根据本质,我的意思是影响你在这种语言中发展的方式,例如,不是,不管它是否与一些广泛的运行时集成。

解决方案

离开我的头顶:




  • 懒惰 eager (aka non-strict vs. 严格 call-by-need vs. call-by-value ):是函数应用程序前评估的函数参数,以后,还是永远不会?

  • em> vs. impure :语言是否允许功能有副作用?是否有可变引用?

  • static 动态 :编译时或运行时的语言检查类型是否正确?

  • 代数数据类型 :语言支持模式是否匹配变体类型?

  • metaprogramming :该语言是否提供强大的代码生成系统?

  • 并发 parallelism :是线程/进程的一级抽象?该语言是否同时运行多个计算容易?

  • 异国情调类型:静态类型系统的表现力如何? GADTs?依赖类型?线性类型系统F?



只有前两个项目对于功能语言才是真正独一无二的(即几乎所有的命令式语言都是渴望和不纯的)。


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 instead of iteration. However, some fundamental differences also exist. Lisp uses a single representation for both Lisp code and data, while ML has no standard representation of ML code. Erlang has a built-in actor-based concurrency. Haskell has monads. Haskell makes a distinction in the static type system between pure and impure functions; ML does not.

What are the distinctive fundamental differences between other functional languages (Clojure, F#, Arc, any other)? By fundamental I mean something which influences the way you develop in this language, and not for example, whether it is integrated with some wide-spread runtime.

解决方案

Off the top of my head:

  • lazy vs. eager (aka non-strict vs. strict or call-by-need vs. call-by-value): are function arguments evaluated before the function application, or after, or never?
  • pure vs. impure: does the language allow functions to have side effects? Does it have mutable references?
  • static vs. dynamic: does the language check types at compile time or runtime?
  • algebraic datatypes: does the language support pattern matching over variant types?
  • metaprogramming: does the language provide a powerful code generation system?
  • concurrency and parallelism: are threads/processes a first-class abstraction? Does the language make it easy to run multiple computations at the same time?
  • "exotic" types: how expressive is the static type system? GADTs? Dependent types? Linear types? System F?

Only the first two items are really unique to functional languages (i.e., almost all imperative languages are eager and impure).

这篇关于功能语言的独特特征的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆