Apart from closures (which Java doesn't appear all that close to having), here's a list of features in Scala that are missing from Java. I'll omit libraries here and concentrate on the features of the language itself. This is not comprehensive by any means, but I think it contains the big ticket items.
Even if Java 7 [8,..] will have first-class functions one day, it still lacks for implicits, type inference, powerful Collections library, pattern matching, traits and lots of other things boosting productivity. Not talking about various Actor libraries, rich capabilities of building DSLs,...
发布评论
评论(3)
除了闭包(Java 似乎还没有拥有闭包)之外,这里列出了 Scala 中 Java 所缺少的功能。我将在这里省略库并专注于语言本身的功能。无论如何,这并不全面,但我认为它包含了大件物品。
for
推导val
与var
一样容易声明)这些构建块启用了一些很酷的辅助构造:
最后,我要提到 Scala 有一个 REPL(读取-评估-打印-循环)——实际上并不是语言本身的功能,但拥有它真是太好了!
Apart from closures (which Java doesn't appear all that close to having), here's a list of features in Scala that are missing from Java. I'll omit libraries here and concentrate on the features of the language itself. This is not comprehensive by any means, but I think it contains the big ticket items.
for
comprehensionsval
s are as easy to declare asvar
s)Some cool secondary constructs that these building blocks enable:
Lastly, I'll mention that Scala has a REPL (read-evaluate-print-loop)--not really a feature of the language itself, but it's very nice to have!
即使 Java 7 [8,..] 有一天会拥有一流的函数,它仍然缺乏隐式、类型推断、强大的 Collections 库、模式匹配、特征和许多其他提高生产力的东西。不谈各种Actor库,丰富的构建DSL的能力,......
Even if Java 7 [8,..] will have first-class functions one day, it still lacks for implicits, type inference, powerful Collections library, pattern matching, traits and lots of other things boosting productivity. Not talking about various Actor libraries, rich capabilities of building DSLs,...
我听说的最新消息是,Java 7 中不会出现闭包。
http://www.baptiste-wicht.com/2010/09/jdk-7-features-updated-plan-b-is-apparently-here/
http://openjdk.java.net/projects/jdk7/features/
第二个链接清楚地将 Lambda 项目(闭包)列出为推迟到 JDK 8。
The latest I've heard is that closures won't make it into Java 7.
http://www.baptiste-wicht.com/2010/09/jdk-7-features-updated-plan-b-is-apparently-here/
http://openjdk.java.net/projects/jdk7/features/
The second link clearly lists project Lambda (closures) as deferred to JDK 8.