未来投资:Erlang 与 Scala
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6820195/
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
Future investment: Erlang vs. Scala
提问by Mark
since concurrent programming becomes constantly more important, I was wondering what you think about Erlang vs. Scala in that respect. It seems to me that Scala has a larger user base and potentially a brighter future than Erlang. Furthermore, Scala is kind of java.
由于并发编程变得越来越重要,我想知道您在这方面如何看待 Erlang 与 Scala。在我看来,Scala 拥有更大的用户群,并且可能比 Erlang 拥有更光明的未来。此外,Scala 是一种 Java。
I know these questions are alway a bit subjective, but what would be the better future investment: Erlang or Scala. Or even another language?
我知道这些问题总是有点主观,但未来投资哪个更好:Erlang 或 Scala。或者甚至是另一种语言?
回答by romusz
Erlang has been designed for concurrent, fault-tolerant communication systems. You can easily write servers that handle large number of network connections and (thanks to one garbage collector per Erlang process) the servers can retain soft real-time characteristics (i.e., the whole server is not paused until GC finishes). You can also hot-swap Erlang code, distribute it across several nodes, etc. That's why (arguably) the most-scalable XMPP server (ejabberd) is written in Erlang. Yaws (a web server) is another example where Erlang excels, see: http://www.sics.se/~joe/apachevsyaws.html. Riak/Couch are examples of NoSQL DB build with Erlang. These are the problems where Erlang is a great choice.
Erlang 是为并发的、容错的通信系统而设计的。您可以轻松编写处理大量网络连接的服务器,并且(由于每个 Erlang 进程有一个垃圾收集器),服务器可以保留软实时特性(即,整个服务器在 GC 完成之前不会暂停)。您还可以热交换 Erlang 代码,将其分发到多个节点等。这就是(可以说)最可扩展的 XMPP 服务器 (ejabberd) 是用 Erlang 编写的原因。Yaws(网络服务器)是 Erlang 擅长的另一个例子,请参阅:http: //www.sics.se/~joe/apachevsyaws.html。Riak/Couch 是使用 Erlang 构建 NoSQL DB 的示例。这些都是 Erlang 是一个很好的选择的问题。
But Erlang VM is not as fast as JVM in terms of raw computations, so as soon as you need to do something computationally intensive (e.g. financial modeling) JVM will be your preferred platform. Moreover, Erlang's concurrency model (actors) is baked in the language. If that doesn't fit the problem you're trying to solve, then you won't be happy with Erlang.
但是 Erlang VM 在原始计算方面不如 JVM 快,所以一旦你需要做一些计算密集型的事情(例如金融建模),JVM 将是你的首选平台。此外,Erlang 的并发模型(actors)是在语言中烘焙的。如果这不适合您要解决的问题,那么您将不会对 Erlang 感到满意。
Scala is more 'general' language in a sense that concurrency, horizontal scalability, or fault-tolerance is not part of the language. It is solved at the level of libraries (that's why there are at least 3 implementations of actors in Scala). The good thing is that you can pick concurrency model that fits your domain. For example if you need software transactional memory (STM), just pick Akka and you're good to go (http://akka.io/).
从某种意义上说,Scala 是更“通用”的语言,因为并发性、水平可伸缩性或容错性不是该语言的一部分。它是在库级别解决的(这就是为什么在 Scala 中至少有 3 个 actor 实现)。好处是您可以选择适合您领域的并发模型。例如,如果您需要软件事务内存 (STM),只需选择 Akka 即可(http://akka.io/)。
Plus there is the whole argument that with Scala you can leverage your "JVM investments" and multitude of JVM libs.
此外,还有一个论点是,使用 Scala,您可以利用您的“JVM 投资”和大量 JVM 库。
You didn't give any info on what kind of software you want to write with either of those languages so it's hard to give you a definitive answer. Having said that, given all the above, Scala may be "safer" investment than Erlang (not bashing Erlang/OTP at all, it's a fine language/platform).
您没有提供任何关于您想用这两种语言编写哪种软件的信息,因此很难给您一个明确的答案。话虽如此,鉴于上述所有内容,Scala 可能是比 Erlang 更“安全”的投资(根本不抨击 Erlang/OTP,它是一种很好的语言/平台)。
BTW. If a single-machine concurrency is important to you Clojure (http://clojure.org/) should not be overlooked (also JVM language).
顺便提一句。如果单机并发对您很重要,那么 Clojure ( http://clojure.org/) 不应被忽视(还有 JVM 语言)。
UPDATE1: If you like what Erlang offers but not its syntax, take a look at elixir-lang.org
UPDATE1:如果你喜欢 Erlang 提供的东西但不喜欢它的语法,看看elixir-lang.org
UPDATE2: STM has been removed from Akka - now you have a choice (mix/match) between actors (untyped or typed) and streams.
更新 2:STM 已从 Akka 中删除 - 现在您可以在演员(无类型或有类型)和流之间进行选择(混合/匹配)。
回答by Robert Greiner
It doesn't matterJust pick one and stick with it for a while. Learn some stuff, make some cool things and either keep going with that language or move on to another one.
没关系,随便挑一个,坚持一段时间就好了。学习一些东西,制作一些很酷的东西,然后要么继续使用这种语言,要么转向另一种语言。
With respect to learning concurrent programming, either will be fine. The key here is that you will be learning something new and unless there's a job opening that you are trying to get hired for that uses Erlang specifically, it really doesn't matter. Plus, even if that opening did require Erlang, you would still likely have a good chance if you knew Scala really well.
关于学习并发编程,两者都可以。这里的关键是你将学习新的东西,除非有一个职位空缺,你正试图获得专门使用 Erlang 的职位空缺,否则这真的无关紧要。另外,即使那个开口确实需要 Erlang,如果你真的很了解 Scala,你仍然可能有很好的机会。
Just think, all of the time you have spent trying to pick a new language could have been better spent if you just picked one and already started learning it by now.
试想一下,如果您选择一门新语言并且现在已经开始学习它,那么您花在尝试选择一门新语言上的所有时间本可以更好地度过。
回答by Diego Sevilla
Both languages, at the core, are not that hard to learn, and also to learn the concurrency features they provide. In fact, Scala actors are influenced by Erlang actors. I would go to both of them, take your time looking at their construct, do some tests in concurrency problems, etc.
这两种语言,从本质上讲,都不是很难学习,而且还可以学习它们提供的并发特性。事实上,Scala actor 受 Erlang actor 的影响。我会去他们两个,花点时间看看他们的构造,做一些并发问题的测试,等等。
If you know Java, Scala will be more natural, as Erlang is more like prolog. If, on the contrary, you're more oriented towards mathematical or logical type of languages, start with Erlang.
如果你懂 Java,Scala 会更自然,因为 Erlang 更像 prolog。相反,如果您更倾向于数学或逻辑类型的语言,请从 Erlang 开始。

