我在这里看到很多关于函数式语言的讨论。为什么你要使用传统语言而不是传统语言呢?他们在哪些方面做得更好?他们更不擅长什么?理想的函数式编程应用程序是什么?


当前回答

除了其他答案之外,用纯函数术语来描述解决方案可以迫使人们更好地理解问题。相反,用函数式的思维方式会培养出更好的解决问题的能力。

*要么是因为功能范式更好,要么是因为它可以提供额外的攻击角度。

其他回答

大多数应用程序都可以用[此处插入您最喜欢的语言、范例等]来解决。

尽管如此,不同的工具可以用来解决不同的问题。函数只是允许另一种更高层次的抽象,当正确使用时,它允许我们更有效地完成工作。

对我来说,主要的优点是它固有的并行性,特别是当我们现在从更多的MHz转向越来越多的内核时。

我不认为它会成为下一个编程范式并完全取代OO类型方法,但我确实认为我们将会达到这样的境地:要么我们需要用函数式语言编写一些代码,要么我们的通用语言将会发展到包含更多的函数式结构。

我一定是糊涂了,但我还是不明白。是否有像f#这样的函数式语言编写的小型应用程序的实际例子,你可以查看源代码,并了解如何以及为什么使用这种方法比c#更好?

FP无疑是下一个最佳范例。现在哪种语言可能是下一步,这是很难的东西,但我相信可能是Haskell, f#, Clojure, Ocaml或Erlang。或者是带有更多FP结构和更好的并行性/性能支持的Python,或者是带有parrot的Perl 6,看起来非常有趣。

我一直对“下一件大事”持怀疑态度。很多时候,下一个大事件纯粹是历史的偶然,无论技术好坏,它都在正确的时间出现在正确的地点。例如:c++, Tcl/Tk, Perl。所有的技术都是有缺陷的,都非常成功,因为它们被认为要么解决了当时的问题,要么与根深蒂固的标准几乎相同,或者两者兼而有之。函数式编程可能确实很棒,但这并不意味着它会被采用。

But I can tell you why people are excited about functional programming: many, many programmers have had a kind of "conversion experience" in which they discover that using a functional language makes them twice as productive (or maybe ten times as productive) while producing code that is more resilient to change and has fewer bugs. These people think of functional programming as a secret weapon; a good example of this mindset is Paul Graham's Beating the Averages. Oh, and his application? E-commerce web apps.

自2006年初以来,也有一些关于函数式编程和并行的讨论。因为像Simon Peyton Jones这样的人至少从1984年开始就一直在担心并行性,所以在函数式语言解决多核问题之前,我不会屏住呼吸。但它确实解释了目前一些额外的话题。

In general, American universities are doing a poor job teaching functional programming. There's a strong core of support for teaching intro programming using Scheme, and Haskell also enjoys some support there, but there's very little in the way of teaching advanced technique for functional programmer. I've taught such a course at Harvard and will do so again this spring at Tufts. Benjamin Pierce has taught such a course at Penn. I don't know if Paul Hudak has done anything at Yale. The European universities are doing a much better job; for example, functional programming is emphasized in important places in Denmark, the Netherlands, Sweden, and the UK. I have less of a sense of what's happening in Australasia.