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


当前回答

函数式编程将很可能成为工程师和科学家用来解决他们所面临的问题的工具。它不会像早期的语言那样占领世界。然而,最难打败的产品是Excel,如果我是一名工程师,需要做计算,Excel是很棒的。

However, F# is going to be another source and will likely fill design needs by the non-Computer Scientists. Let's face it, Computer Scientists have done a great job of creating a WHOLE new way of doing things. Object Oriented Programming is GREAT. But sometimes you just need a way to solve an equation, get a solution and graph it. That's it. Then a language like F# fills the bill. Or maybe you want to build a finite state machine, F# again could be one of the solutions, but then C could be a solution as well.

但是当涉及到并行处理时,Excel大放异彩,f#也会及时出现。但是要以友好的方式,F#= friendly。

其他回答

你最近有关注编程语言的发展吗?所有主流编程语言的每一个新版本似乎都从函数式编程中借用了越来越多的特性。

Closures, anonymous functions, passing and returning functions as values used to be exotic features known only to Lisp and ML hackers. But gradually, C#, Delphi, Python, Perl, Javascript, have added support for closures. Its not possible for any up-and-coming language to be taken seriously without closures. Several languages, notably Python, C#, and Ruby have native support for list comprehensions and list generators. ML pioneered generic programming in 1973, but support for generics ("parametric polymorphism") has only become an industry standard in the last 5 years or so. If I remember correctly, Fortran supported generics in 2003, followed by Java 2004, C# in 2005, Delphi in 2008. (I know C++ has supported templates since 1979, but 90% of discussions on C++'s STL start with "here there be demons".)

是什么让这些功能吸引程序员?这应该是显而易见的:它帮助程序员编写更短的代码。如果想要保持竞争力,未来所有的语言都将至少支持闭包。在这方面,函数式编程已经成为主流。

大多数应用程序都很简单 可以用正常的面向对象方法解决

谁说不能用函数式编程来处理简单的事情?并不是每个函数程序都需要是编译器、定理证明器或大型并行通信交换机。除了更复杂的项目外,我还经常使用f#来编写临时脚本。

我敢打赌,当你使用以下方法时,你并不知道你在进行函数式编程:

Excel公式 石英的作曲家 JavaScript Logo(海龟图形) LINQ SQL js(或Lodash), D3

因为FP在生产力、可靠性和可维护性方面有显著的好处。多核可能是一个杀手级应用程序,最终让大公司在大量遗留代码的情况下转换。此外,即使是像c#这样的大型商业语言,也因为多核问题而呈现出一种独特的函数风格——副作用根本不适合并发性和并行性。

我不认为“普通”程序员不能理解它。他们会的,就像他们最终理解了面向对象编程一样(它同样神秘和怪异,如果不是更神秘的话)。

此外,大多数大学都教授FP,许多甚至将其作为第一门编程课程。

呃,很抱歉,我是一个学究,但它已经流行起来了——我们称之为Excel。

http://research.microsoft.com/en-us/um/people/simonpj/papers/excel/

在计算机上运行的绝大多数程序都是用Excel或其众多流行克隆版本之一编写的。

(有许多程序运行多次,而用Excel编写的程序往往不是其中之一-大多数Excel程序都有1个运行实例)

微软正在Visual Studio上大力推广f#的下一个版本。它是一种像Scala一样的混合语言,并且可以很好地与。net框架的其余部分集成。我认为许多微软公司将使用它来加速高度并行的数据处理应用程序和功能的开发。