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


当前回答

一些想法:

The debate between FP and imperative programming (OO, structured, etc), has been raging since Lisp versus Fortran. I think you pose excellent questions but recognize that they are not especially new. Part of the hoopla over FP is that we seem to be recognizing that concurrency is very difficult, and that locks and other mechanisms in OO (e.g. Java) are just one solution. FP offers a refreshing sea change with ideas such as Actors and the power of stateless computing. To those wrestling with OO, the landscape seems highly appealing. Yes, schools teach FP. In fact, the University of Waterloo and others offer Scheme in first year classes (reference here). Regarding the average programmer, I'm sure that the same arguments were given against C++ back in the early 1990s. And look what happened. If businesses can gain an advantage via a technology, you can bet that people will receive training.

这并不是说这是板上钉钉的事,也不是说在3-5年内不会出现反弹(一如既往)。然而,朝着计划生育的趋势是有好处的,值得关注。

其他回答

如果一个人看不到其他艺术的价值,他就无法理解他所选择的艺术的完美和不完美。遵循规则只允许在技术上发展到一定程度,然后学生和艺术家必须学习更多,进一步探索。在学习战略艺术的同时,学习其他艺术也是有意义的。

谁没有通过观察别人的活动来更多地了解自己呢?要学剑,就要学吉他。要学商业,先学商业。只学习刀剑会使你心胸狭窄,不能向外成长。

——宫本武藏《五环之书》

为什么函数式编程很重要

我不认为函数式语言能解决任何问题,这只是管理层试图推销的一种炒作,记住唯一的事实:

没有灵丹妙药。

其余的都是胡扯,他们还说OO会解决我们的问题,Web服务会解决我们的问题,Xml会解决我们的问题,但最后上面的真理适用了,一切都失败了。而且,20年后,谁说我们还会使用二进制计算机呢?为什么不是量子计算机呢?没有人能预测未来,至少在这个星球上不能。(这是第二条真理)

我同意第一点,但是时代变了。公司会做出回应,即使他们是后期采用者,如果他们看到有一个优势。生活是动态的。

90年代末,他们在斯坦福教授哈斯凯尔和ML。我相信卡内基梅隆大学、麻省理工学院、斯坦福大学和其他一些好学校正在向学生们展示它。

我同意大多数“在网络上公开关系数据库”的应用程序将在很长一段时间内继续这样做。对于这个问题,Java EE、. net、RoR和PHP已经演化出了一些非常好的解决方案。

您发现了一些重要的问题:这可能是其他方法无法轻松解决的问题,而这些方法将促进函数式编程。那是什么?

大规模多核硬件和云计算会推动它们向前发展吗?

I don't know whether it will catch on or not, but from my investigations, a functional language is almost certainly worth learning, and will make you a better programmer. Just understanding referential transparency makes a lot of design decisions so much easier- and the resulting programs much easier to reason about. Basically, if you run into a problem, then it tends to only be a problem with the output of a single function, rather than a problem with an inconsistant state, which could have been caused by any of the hundreds of classes/methods/functions in an imparative language with side effects.

FP的无状态本质更自然地映射到web的无状态本质,因此函数式语言更容易让自己更优雅,更RESTFUL的web应用程序。与JAVA和. net框架形成鲜明对比的是,它们需要在本质上无状态的功能平台(如web)上使用VIEWSTATE和SESSION键来维护应用程序状态,并维护有状态命令语言的抽象(有时相当容易泄漏)。

而且,应用程序越无状态,就越容易进行并行处理。如果你的网站很受欢迎,这对网络来说非常重要。向站点添加更多硬件以获得更好的性能并不总是那么简单。