功能Java和番石榴之间有很好的比较吗?

我想在我将要教的课程中使用功能Java或番石榴(或不太可能的Scala).虽然在JVM上运行的功能语言很多,但我希望坚持使用尽可能多的Java,即与Java 8中预期的功能特性最相似的概念和语法.

看起来像Functional JavaGuava是最好的候选人.在能力,易用性,与Java直观的概念接近等方面,我还没有找到任何比较它们的东西.有人知道这些图书馆之间的良好比较吗?

最佳答案
番石榴的目标不是在Java中提供功能性的成语.从Functional Explained Guava维基页面:

Excessive use of Guava’s functional programming idioms can lead to
verbose, confusing, unreadable, and inefficient code. These are by far
the most easily (and most commonly) abused parts of Guava, and when
you go to preposterous lengths to make your code “a one-liner,” the
Guava team weeps.

Please be sure, when using Guava’s functional utilities, that the
traditional imperative way of doing things isn’t more readable. Try
writing it out. Was that so bad? Was that more readable than the
preposterously awkward functional approach you were about to try?

由于开销太高,所以对功能性成语的重视过多对Java 7来说不太了解(参见vertical problem).这将随Java 8而改变,这将改变Java库和程序在详细级别上的设计方式.在Java 7中,在Java中有意义的事情将在某种程度上在Java 8中被阻止.这将激发新版的Effective Java和许多新的API.

如果你想教功能性编程,最好坚持一个(或多或少)纯粹的功能语言.每种语言是FP和OOP的混合(或仿真)将是一种分心.

转载注明原文:功能Java和番石榴之间有很好的比较吗? - 代码日志