Javascript 是函数式编程语言吗? [英] Is Javascript a Functional Programming Language?

查看:35
本文介绍了Javascript 是函数式编程语言吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅仅因为函数是一等对象,有闭包,还有高阶函数,Javascript就配得上函数式编程语言吗?我认为它缺少的主要内容是 Pure Functions,它感觉"不像其他函数式语言,如 lisp(尽管这并不是它不是函数式语言的真正原因......)

Just because functions are first class objects, there are closures, and higher order functions, does Javascript deserve to be called a Functional Programming language? The main thing I think it lacks is Pure Functions, and it doesn't 'feel' like other functional languages, like lisp (although thats not really a good reason for it not to be a functional langauge...)

推荐答案

重复 我自己对类似问题的回答

没有公认的定义函数式编程语言.

There's no accepted definition of functional programming language.

如果你将函数式语言定义为支持一流的语言函数和 lambdas,然后是的,JavaScript *是 *函数式语言.

If you define functional language as the language that supports first class functions and lambdas, then yes, JavaScript *is* a functional language.

如果您还考虑以下因素支持不变性,代数数据类型,模式匹配,部分应用程序等然后不,JavaScript*不是*函数式语言.

If you also consider the factors like support for immutability, algebraic data types, pattern matching, partial application etc then no, JavaScript *is not* a functional language.

我鼓励你阅读关注相关博客文章(以及他们下面的评论):

I'd encourage you to read the following related blog posts (and also the comments below them):

Erlang 无法运行

Reddit 上关于Erlang 不起作用"的讨论

这篇关于Javascript 是函数式编程语言吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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