Ruby 与 Scala - 各有利弊
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7753271/
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
Ruby vs Scala - pros and contras of each one
提问by Andrei Petrenko
What benefits and limitations has Scalalanguage comparing to Ruby, especially from the web applications developer point of view? Comparison charts and proof-links are strongly welcome.
与Ruby相比,Scala语言有哪些优点和局限性,尤其是从 Web 应用程序开发人员的角度来看?强烈欢迎比较图表和证明链接。
P. S. This is not a holy war question (-:
PS 这不是圣战问题(-:
回答by Jakub Arnold
I've been working with Ruby and Rails for over 2 years and I'm just about a month into learning Scala and Lift, so my opinion is probably biased, but here it is.
我已经使用 Ruby 和 Rails 超过 2 年了,而我才刚刚学习 Scala 和 Lift 一个月,所以我的观点可能有偏见,但就是这样。
Ruby makes you feel amazing. Every new thing I discovered about the language made me giggle like a little schoolgirl. Working with gems is really simple and with Bundler and Gemfilesit is probably the best library management system I've came across.
Ruby 让你感觉很棒。我发现的关于语言的每一个新事物都让我像个小女生一样咯咯地笑。使用 gems 非常简单,使用Bundler 和 Gemfiles,它可能是我遇到的最好的图书馆管理系统。
There are loads of gems for everything, from API wrappers, to complex authentication/authorization.
从 API 包装器到复杂的身份验证/授权,所有东西都有大量的 gem 。
Ruby also has amazing community that will make learning the language really really easy. Take RailsCasts by Ryan Batesfor example. If you watch them, you will learn how to do web development with Ruby and Rails.
Ruby 还拥有令人惊叹的社区,这将使学习这门语言变得非常容易。以Ryan Bates 的 RailsCasts为例。如果您观看它们,您将学习如何使用 Ruby 和 Rails 进行 Web 开发。
For me, Ruby is probably the best thing I've discovered in my whole programming life, because the way the community works made me change my whole approach to programming.
对我来说,Ruby 可能是我整个编程生涯中发现的最好的东西,因为社区的工作方式让我改变了我的整个编程方法。
On the other hand, I don't see this in the Scala world. I don't want to raise a flame war, but this is just my impression after just starting to learn the language. In Ruby community, everything felt so engaging and made me wanna learn more and more. But with Scala, I tend to run into a lot of obstacles and not as much documentation and tutorials, that would help me overcome them.
另一方面,我在 Scala 世界中看不到这一点。我不想挑起火焰War,但这只是我刚开始学习语言后的印象。在 Ruby 社区,一切都让人觉得很吸引人,让我想学习越来越多。但是在使用 Scala 时,我往往会遇到很多障碍,而没有那么多文档和教程来帮助我克服它们。
There are tons of books devoted to very specific topis on Ruby, be it scripting, deployment, testing, and bunch of other stuff (yes Pragmatic Programmers rule). The best thing is, that the whole community feels like a family, it's not the same as in the Java world, where everything is distributed and nobody talks to eachother, at least that's my impression.
有大量书籍专门讨论 Ruby 上非常具体的主题,无论是脚本、部署、测试还是其他一些东西(是的实用程序员规则)。最好的事情是,整个社区感觉就像一个家庭,这与 Java 世界不同,Java 世界中的一切都是分布式的,没有人互相交谈,至少这是我的印象。
So what this comes down to, at least for me, is how easy and engaging it is to get into the world of the language and start doing something, and Ruby is definitely a winner here, at least for me.
因此,至少对我而言,这归结为进入语言世界并开始做某事是多么容易和引人入胜,而 Ruby 在这里绝对是赢家,至少对我而言。
On the performance side, Scala is faster, no doubt about it. That's one of the reasons I'm getting into Scala, as it has really great concurrency model and allows you to do things that Ruby just can't do. But for most web applications, you won't need to do this.
在性能方面,Scala 更快,这是毫无疑问的。这就是我进入 Scala 的原因之一,因为它具有非常棒的并发模型,并且允许您做 Ruby 无法做的事情。但是对于大多数 Web 应用程序,您不需要这样做。
Ruby is slow, that's the only downside there is. It is getting faster and faster, and for 98% of the cases you won't see it as a problem. But Scala is faster.
Ruby 很慢,这是唯一的缺点。它变得越来越快,在 98% 的情况下,您不会将其视为问题。但是 Scala 更快。
Ruby community also embraces testing and beautiful code, which naturally leads to better apps.
Ruby 社区也支持测试和漂亮的代码,这自然会导致更好的应用程序。

