Ruby VM 之间的差异

发布于 2024-07-05 23:22:49 字数 123 浏览 14 评论 0 原文

主要 Ruby VM 的优点/缺点是什么(例如功能、兼容性、性能和怪癖?)我知道还有一些额外的功能,例如也可以通过 JRuby 使用 Java 接口。 注意到这些也会有所帮助。 目前是否有任何虚拟机具有明显的优势?在什么情况下?

What are the advantages/disadvantages of the major Ruby VMs (things like features, compatibility, performance, and quirks?) I know there are also some bonus features like being able to use Java interfaces through JRuby, too. Those would also be helpful to note. Does any VM have a clear advantage at this point, and in what contexts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寂寞清仓 2024-07-12 23:22:49

以下是我在主要虚拟机上找到的一些信息:Ruby MRIRuby 1.9 (YARV), JRubyXRubyRubiniusIronRuby

有一个 去年的性能基准,比较了主要的虚拟机,但也对比了虚拟机开发的速度今天它可能不再那么重要了。 我相信,Ruby 1.9 通常是最快的,并且目前仍然比 JRuby 具有优势。

目前有四个虚拟机能够运行 Ruby on Rails:Ruby MRI、Ruby 1.9、JRuby 和 Rubinius。

XRuby 与 JRuby 一样在 JVM 上运行,并将 Ruby 源文件编译为 Java .class。

IronRuby 在 .NET 上运行,利用其 DLR,并允许您将 Ruby 与 .NET 库和基础设施集成。 它还无法运行 Ruby on Rails。

还有一个名为 HotRuby 的 VM,可让您在浏览器或 Flash 中运行 Ruby 源代码。

Here's a bit of info I scrounged up on the main VMs: Ruby MRI, Ruby 1.9 (YARV), JRuby, XRuby, Rubinius, and IronRuby

There was a performance benchmark last year that compared the major VMs, but with how quickly VM development has been it probably is not as relevant today. Ruby 1.9 was generally the fastest, and still has the edge over JRuby for now, I believe.

Four VMs are currently capable of running Ruby on Rails: Ruby MRI, Ruby 1.9, JRuby, and Rubinius.

XRuby runs on the JVM, as does JRuby, and compiles the Ruby source files to a Java .class.

IronRuby runs on .NET, making use of their DLR, and allows you to integrate Ruby with the .NET libraries and infrastructure. It cannot yet run Ruby on Rails.

There is also a VM called HotRuby that lets you run Ruby source code in the browser or in Flash.

我ぃ本無心為│何有愛 2024-07-12 23:22:49

我使用过 Matz 的 Ruby 和 JRuby,它们解决了不同的任务。 如果您正在开发直接的 Ruby 或 Rails 应用程序,那么这可能就足够了,但如果有一些功能强大的 Java 库可以提供很大帮助,那么 JRuby 可能是值得的。

我没有做任何过于复杂的事情,但 JRuby 似乎匹配得很好,至少在实现核心语言功能方面(我还没有遇到任何差异,但它们可能存在)。

我想分享一个小轶事...我正在编写一个与 DB2 数据库交互的脚本。 Ruby 中的 DB2 支持很糟糕...您必须安装整个 DB2 Express 版本才能编译 Ruby 驱动程序,这对我来说甚至不起作用。 我厌倦了,转而使用 JRuby,使用 JDBC 和一些小的 DB2 JDBC jar。 它完美地解决了我的问题。 重点是? 好吧,如果访问某些 Java 库可以简化手头的问题,那么请务必这么做!

我希望这可以帮到你! 抱歉,我没有任何使用其他虚拟机的经验...


我已经读到了另外一个警告,但我不太了解细节...我认为 JRuby 支持通过 Java 线程进行线程处理,而不是“绿色线程” “Matz 实现中支持线程...因此,如果您想在多核系统上进行多线程处理,JRuby 可能会更好...除非您想在 C 中进行线程处理。

I've used both Matz's Ruby and JRuby, and they solve different tasks. If you are developing a straight Ruby or Rails app, then that will probably suffice, but if there are some powerful Java libraries that would help a lot, then JRuby might be worthwhile.

I haven't done anything overly complicated, but JRuby seemed to match up pretty well, at least as far as implementing the core language features (I haven't run into any differences yet, but they may exist).

One little anecdote I wish to share... I was writing a script to interact with a DB2 database. The DB2 support in Ruby is abysmal... you have to install the whole DB2 express version just to be able to compile the Ruby drivers, which didn't even work for me. I got fed up and switched to JRuby, using JDBC and a few small DB2 JDBC jars. It resolved my problem perfectly. The point? Well, if gaining access to some Java libraries will simplify the problem at hand, by all means go for it!

I hope this was helpful! Sorry I don't have any experience with other VMs....


One more caveat I have read about, but I don't know the details too well... JRuby I think supports threading via Java threads, instead of the "green" threads supported in Matz's implementation... so if you want multithreading on multicore systems, JRuby will probably serve you better... unless you want to do the threading in C.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文