Scala,未来的Java(?)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1995953/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Scala, the java of the future(?)
提问by Gilad Manor
I'm trying to figure out the popularity of scala and how many SO users actually use it in the workplace?
我想弄清楚 scala 的流行程度以及有多少 SO 用户在工作场所实际使用它?
- Here are some scala links
回答by oxbow_lakes
I've been using Scala for a year now at work (finance technology) and would not want to move back to Java at all! The things that concerned me most when originally considering the migration were:
我已经在工作(金融技术)中使用 Scala 一年了,根本不想回到 Java!最初考虑迁移时,我最关心的事情是:
- Tool Support (what are the IDE's like?)
- Interop with existing Java libraries and build technologies (
ant, Spring, internally-written stuff) - Talent Pool (where do I find good Scala developers?)
- Transition-time (how long before I'm writing goodScala?)
- 工具支持(IDE 是什么样的?)
- 与现有 Java 库和构建技术(
ant、Spring、内部编写的东西)互操作 - 人才库(我在哪里可以找到优秀的 Scala 开发人员?)
- 过渡时间(在我写出好的Scala之前多久?)
I found that IDEA's Scala plugin (for the now free v9 Community Edition) is excellent: not quite as good as Java's tool support but certainly good enough for our needs. It has basic refactoring and debugging and great syntax-highlighting. My experience with Eclipsehas been extremely disappointing: I'm led to understand that great improvement is expected for Scala 2.8 but I've seen a recent Eclipse-nightly and it was, frankly, awful.
我发现 IDEA 的 Scala 插件(针对现在免费的 v9 社区版)非常出色:不如 Java 的工具支持那么好,但肯定足以满足我们的需求。它具有基本的重构和调试以及出色的语法突出显示。我对Eclipse 的体验非常令人失望:我了解到 Scala 2.8 预计会有很大的改进,但我最近看过一次 Eclipse-nightly,坦率地说,它很糟糕。
The interoperability with Java is first-rate - I have had no problems whatsoever and still make heavy use of Spring and our bespoke (ant-based) build-system. The developer-pool is only a consideration for a large company with moderate-to-high staff turnover; it has not been an issue for us so far and interviewees have expressed interest in using Scala anyway.
与 Java 的互操作性是一流的 - 我没有遇到任何问题,并且仍然大量使用 Spring 和我们定制的(基于蚂蚁的)构建系统。开发人员池仅适用于人员流动中高的大公司;到目前为止,这对我们来说还不是问题,无论如何,受访者都表示有兴趣使用 Scala。
Perhaps the biggest issue is transition-time. I've found this to be 2 weeks to being able to write anything reasonable, 3 months to startto really "get it" and 6 months-1 year to start taking advantage of the functional and DSL-sides of Scala. So, what are the really big gains for me?
也许最大的问题是过渡时间。我发现这是2周能写什么合理的,3个月就开始真正“了解”和6个月的1年开始服用斯卡拉的功能和DSL-双方的优势。那么,对我来说真正的大收获是什么?
- Type inference and co- and contra-variance built in (code is more readable and intuitive - generics just works, unlike Java where it can be extremely painful)
- Functional Programming style and closures (code is more readable and quicker to write)
- The actors concurrency library (simplifies concurrent programming hugely)
- 内置类型推断和协变和逆变(代码更具可读性和直观性 - 泛型可以正常工作,不像 Java 那样非常痛苦)
- 函数式编程风格和闭包(代码可读性更强,编写速度更快)
- Actor 并发库(极大地简化了并发编程)
So to conclude:
所以总结一下:
- Is Scala any good? Yes- it's fantastic
- Is it ready for real enterpriseuse? Yes- there are quite a few compaies using it now, including Twitter, Sony and EDF
- Are the gains worth the adoption cost? Yes - absolutely
- Scala 好用吗?是的-太棒了
- 它准备好供真正的企业使用了吗?是的- 现在有很多公司在使用它,包括 Twitter、Sony 和 EDF
- 这些收益是否值得采用成本?是的,一点没错
回答by Uri
Nobody has a crystal ball, and somebody could come up with something better (or something worse with a powerhouse behind it) anytime.
没有人拥有水晶球,任何人都可以随时想出更好的东西(或者在背后有强者的情况下更糟的东西)。
There's been a lot of articles, podcasts, etc. Here on SO, I suggest you read: https://stackoverflow.com/questions/33744/is-scala-the-next-big-thing
有很多文章、播客等。在这里,我建议你阅读:https: //stackoverflow.com/questions/33744/is-scala-the-next-big-thing
Personally, I think Scala is promising, but may fail to ever attract the crowd. A lot of the production use of Java today revolves around J2EE and I don't see these folks making the transition. For non-Java users, more established languages like Python may provide all the functional features they need even at the cost of not using the JVM.
就我个人而言,我认为 Scala 很有前途,但可能永远无法吸引人群。今天 Java 的很多生产应用都围绕着 J2EE 展开,我没有看到这些人做出转变。对于非 Java 用户,更成熟的语言(如 Python)可能会提供他们需要的所有功能特性,即使不使用 JVM 也是如此。
回答by Brian Agnew
I've just started working with Scala and I'm starting to see more interest in the financial arena.
我刚刚开始使用 Scala,我开始看到人们对金融领域越来越感兴趣。
I'm now getting more people/colleagues showing interest in this. A number of people have asked me to keep them posted as to my progress. I didn't see the same level of interest in Groovy (or other JVM languages post Java itself).
我现在越来越多的人/同事对此表现出兴趣。许多人要求我随时向他们通报我的进展。我没有看到对 Groovy(或其他 JVM 语言发布 Java 本身)的同样程度的兴趣。
So it's definitely the Java language de jour, and I think it has more momentum than anything before it in the Java arena. How this carries forward is anyone's guess, however!
所以它绝对是 Java 语言的de jour,我认为它比 Java 领域中的任何东西都具有更大的动力。然而,任何人都在猜测这将如何发展!
回答by David Crawshaw
I have been programming in Java for many years, and Haskell and OCaml for the last two years. A few months ago I began developing a personal projectin Scala, and it's wonderful. A real type system and all the Java supporting libraries.
我已经使用 Java 编程多年,最近两年使用 Haskell 和 OCaml。几个月前,我开始在 Scala 中开发一个个人项目,这很棒。一个真正的类型系统和所有 Java 支持库。
The ease of mixing Java and Scala means the language definitely has a future. Adoption costs for an existing Java project are very low.
混合 Java 和 Scala 的容易性意味着该语言肯定有未来。现有 Java 项目的采用成本非常低。
回答by Justin W
Not sure if this info helps, but I'm building an online gaming server for a successful and established gaming company, using Scala and Project Darkstar.
不确定此信息是否有帮助,但我正在使用 Scala 和 Project Darkstar 为一家成功且成熟的游戏公司构建在线游戏服务器。
Our design is specced to scale to half a million to ten million users (thanks, Amazon EC2!), and Scala gives me extra confidence in my code for five reasons: 1. I catch more things at compile time. 2. It's easy to make much of my game data immutable. 3. Higher level code means that I'm less likely to get a trivial implementation mistake. 4. Shorter, simpler code makes it easier for me to review and find errors. Implicit conversions are a big part of this. 5. The happier I am writing code (and Scala generally makes me happy), the better job I do.
我们的设计预计可扩展到 50 万到 1000 万用户(感谢 Amazon EC2!),Scala 使我对我的代码更加自信,原因有以下五个: 1. 我在编译时捕获了更多东西。2. 很容易让我的大部分游戏数据不可变。3. 更高级别的代码意味着我不太可能遇到微不足道的实现错误。4. 更短、更简单的代码使我更容易和发现错误。隐式转换是其中的重要组成部分。5. 我写代码越开心(Scala 通常让我开心),我的工作就越好。
Scala isn't a panacea, and it's got plenty of warts (namely lack of any great tool support) but it's by far the most productive language I could be using for this purpose.
Scala 不是灵丹妙药,它有很多缺点(即缺乏任何强大的工具支持),但它是迄今为止我可以用于此目的的最高效的语言。
My only complaint is that I wish it could compile down to C or heavily macro'd assembler, as the limitations of the JVM often irk me (type erasure, lack of stack types and by-value object arrays).
我唯一的抱怨是我希望它可以编译成 C 或大量宏的汇编程序,因为 JVM 的局限性经常让我感到厌烦(类型擦除、缺少堆栈类型和按值对象数组)。
I don't think Scala is that popular yet, the 2.8 conversion is woefully behind and has created a rift in the community, and the tool support just isn't there. But if you're a cowboy coder who's not afraid of algebraic type theory and lack of autocomplete, it's hard to go wrong.
我认为 Scala 还没有那么流行,2.8 转换非常落后并且在社区中造成了裂痕,而且工具支持也不存在。但如果你是一个不惧怕代数类型理论和缺乏自动完成功能的牛仔编码员,那么就很难出错。
If you do decide to use it, do yourself a huge favor and buy Odersky's book. I tried for a while to code in Scala without it, and it was almost impossible to do anything the "scala way" (not that there's consensus on that).
如果您决定使用它,请帮自己一个大忙并购买奥德斯基的书。我尝试了一段时间在没有它的情况下在 Scala 中编码,并且几乎不可能以“scala 方式”做任何事情(并不是在这方面达成共识)。
回答by Carl Smotricz
I heard about Scala some months ago, and was pretty excited to see "a better Java than Java" for the JVM. Scala fixes a number of Java's problems with annoying boilerplate code, adds some functional programming and concurrent programming support. It has good (though not perfect) compatibility to Java's libraries, so all that code is instantly available. It's also possible to mix Scala with Java and possibly other JVM languages in the same project.
几个月前我听说了 Scala,并且很高兴看到 JVM 的“比 Java 更好的 Java”。Scala 通过烦人的样板代码修复了 Java 的许多问题,添加了一些函数式编程和并发编程支持。它与 Java 库具有良好(虽然不完美)的兼容性,因此所有代码都可以立即使用。也可以在同一个项目中将 Scala 与 Java 以及其他可能的 JVM 语言混合使用。
I tried to learn Lift (the Web framework) and found I wasn't smart enough to handle it. Scala syntax is very terse and cryptic in some places (where Java is wordy) and takes some getting used to. I wrote some small projects and they worked well; but bigger projects were no fun with the half-adequate support of the Eclipse plugins available at the time.
我尝试学习 Lift(Web 框架),但发现我不够聪明,无法处理它。Scala 语法在某些地方(Java 冗长)非常简洁和神秘,需要一些时间来适应。我写了一些小项目,效果很好;但是,由于当时可用的 Eclipse 插件的支持不足,更大的项目并不有趣。
Personally, I gave up on Scala and moved on to Clojure, which offers many of the same advantages and is more (sorry to be subjective here) "fun" to program.
就我个人而言,我放弃了 Scala,转而使用 Clojure,它提供了许多相同的优点,而且编程更“有趣”(抱歉这里是主观的)。
My personal conclusion: Scala has a lot of features crammed into it, which raises the learning curve. It feels like the complexity of C++ with the syntax of Java and the FP constructs of Ruby. I think it will be hard to persuade industry that Scala has significant advantages over Java, enough to justify the costs in re-tooling and re-training.
我个人的结论是:Scala 中塞满了很多功能,这提高了学习曲线。感觉就像 C++ 的复杂性与 Java 的语法和 Ruby 的 FP 构造。我认为很难说服业界相信 Scala 比 Java 具有显着优势,足以证明重新工具和重新培训的成本是合理的。
回答by Eran Medan
I heard about Scala in a recent convention (JavaEdge2009) and everyone seemed quite convinced that Scala is a great language. The keynote of the conference was that the future of Java is not just a new JVM Programming language, but rather programming languages ARE the future of Java. Since JDK 7 will have support for dynamic languages built in, the prophets are saying you'll be developing in your own language in a few years, (DSL - Domain Specific Language)
我在最近的一次会议 (JavaEdge2009) 上听说了 Scala,每个人似乎都非常相信 Scala 是一种很棒的语言。大会的主题是Java的未来不仅仅是一种新的JVM编程语言,而是编程语言才是Java的未来。由于 JDK 7 将支持内置的动态语言,预言家们说你将在几年内用自己的语言进行开发,(DSL - 领域特定语言)
On the practical side, I've downloaded Scala Eclipse plugin and was disappointed. The fact that automatic imports doesn't work yet, drew the line for me from an interesting language to a practical language. Although it may sound a bit whiny, being required as in the ancient days to manually add imports is too much for me.
在实践方面,我已经下载了 Scala Eclipse 插件并且很失望。自动导入尚未起作用这一事实为我划定了从有趣语言到实用语言的界限。虽然听起来有点怪怪的,但在古代需要手动添加导入对我来说太过分了。

