JRuby对于Rails开发来说是一个可行的MRI替代品吗?

时间:2020-12-03 00:57:22

I am a beginner-verging-on-intermediate rails developer that is working hard to improve my skills.

我是一名入门级的rails开发人员,正在努力提高我的技能。

I am a little confused about the state of JRuby, and whether it is a viable alternative to switch to from the MRI.

我对JRuby的状态有点困惑,以及从MRI切换到JRuby是否可行。

Currently I run a Mac at home and edit using textedit (MRI for ruby, terminal for rails commands, etc). At work, I use NetBeans on Windows, but don't do any Ruby work there.

目前,我在家里运行Mac并使用textedit进行编辑(ruby的MRI, rails命令的终端等等)。在工作中,我在Windows上使用NetBeans,但不做任何Ruby工作。

I am seriously considering ditching the Mac for reasons irrelevant to this conversation, but I am worried that once I am on Windows, the support for Ruby will be less-than-optimal (I may be wrong about this).

我正在认真考虑放弃Mac,原因与此无关,但我担心,一旦我使用Windows, Ruby的支持将不是最优的(我可能错了)。

I really enjoy working with Netbeans at work, and I can see that using JRuby on Windows with Netbeans and allowing JRuby to manage my gems would be a relatively pleasant experience. I like the idea of code completion and a full IDE rather than a text editor (without starting an editor flame war).

我非常喜欢在工作中使用Netbeans,我可以看到在Windows上使用JRuby和Netbeans并允许JRuby管理我的gems是一种相对愉快的体验。我喜欢代码完成和完整IDE的想法,而不是文本编辑器(不需要启动编辑器大战)。

My question is, is JRuby going to complicate learning rails? From what I have seen, certain gems aren't supported on JRuby, or things might be done a little differently in that ecosystem. As a learner, I follow a lot of tutorials from the web and from books and I am worried that things might not work or will be hard to get working on JRuby. Is this scepticism well founded? Or should it be a relatively painless switch? How does it effect deployment onto non-JRuby platforms such as Heroku etc?

我的问题是,JRuby是否会使学习rails变得复杂?从我所看到的情况来看,JRuby不支持某些gem,或者在这个生态系统中可以做一些不同的事情。作为一个学习者,我从网络和书籍中学习了很多教程,我担心事情可能不会成功,或者很难在JRuby上工作。这种怀疑是否有充分的根据?还是说这是一个相对无痛的转变?它如何影响非jruby平台(如Heroku等)的部署?

I am still weighing up a lot of options including MRI on Windows, MRI or JRuby on OpenSolaris, etc. I think that either way I will be going with Netbeans.

我仍在权衡很多选项,包括Windows上的MRI, OpenSolaris上的MRI或JRuby等等。

Any comments are appreciated.

任何评论都欣赏。

5 个解决方案

#1


2  

Realistically you don't need code completion for Rails. TextMate is by far the most commonly used editor in the Ruby world, and it's more than sufficient for everything in Ruby. Ruby doesn't require anywhere near as much tool support as Java. So I would say that if the editor issue is the only reason you're opting for JRuby, it's not a very good reason. Because you're right, there are lots of gems that don't work in JRuby because they use a native extension of some kind. That said, the most popular gems tend to work in JRuby. Performance in JRuby still isn't quite as good as Ruby 1.9, but in a lot of cases it's comparable to MRI 1.8. Personally, I'd recommend treating JRuby as an advanced Ruby concept. It will run Rails, but yes, you're going to find that you won't be able to just follow along with a tutorial, and everything will be ever-so-slightly harder for a beginner. JRuby isn't a particular daunting piece of technology, but it might be more of a hurdle than you want to overcome as a beginner.

实际上,您不需要为Rails完成代码。TextMate是Ruby世界中最常用的编辑器,对于Ruby中的所有东西来说,它已经足够了。Ruby不需要像Java那么多的工具支持。所以我想说,如果编辑器问题是您选择JRuby的唯一原因,那么这不是一个很好的理由。因为您是对的,在JRuby中有很多gem不能工作,因为它们使用某种本地扩展。也就是说,最受欢迎的gem通常使用JRuby。JRuby的性能仍然不如Ruby 1.9,但在很多情况下,它可以与MRI 1.8相媲美。我个人建议将JRuby视为一个高级Ruby概念。它会运行Rails,但是,是的,你会发现你不可能仅仅跟随一个教程,而所有的东西对于初学者来说都将变得更加困难。JRuby并不是一项令人望而生畏的技术,但它可能比您作为初学者想要克服的障碍更大。

I highly recommend shelling out the Euros for a copy of TextMate anyways, even if you don't do your development in it primarily. It's worth every penny and then some. Work in that environment for awhile and see if you really need your IDE. I'm betting you won't.

无论如何,我强烈建议你花更多的钱去买一份TextMate,即使你并没有开发它。一分钱一分货。在这种环境中工作一段时间,看看是否真的需要IDE。我敢打赌你不会。

#2


1  

My question is, is JRuby going to complicate learning rails?

我的问题是,JRuby是否会使学习rails变得更加复杂?

Yes, because all the tutorials, beginner docs, and most of the devs who will normally be able to help you out are assuming MRI, so for each issue you have you must first eliminate a jRuby related cause.

是的,因为所有的教程、初学者文档和大多数通常能够帮助您解决问题的开发人员都假定为MRI,所以对于每个问题,您必须首先消除与jRuby相关的原因。

From what I have seen, certain gems aren't supported on JRuby, or things might be done a little differently in that ecosystem.

从我所看到的情况来看,在JRuby中不支持某些gem,或者在这个生态系统中可能会做一些不同的事情。

Any gems that are written with C native extensions need to be ported to jRuby (the inverse is also true, but the issue is rarer).

使用C本地扩展编写的任何gem都需要移植到jRuby中(反之亦然,但问题更少)。

As a learner, I follow a lot of tutorials from the web and from books and I am worried that things might not work or will be hard to get working on JRuby. Is this scepticism well founded?

作为一个学习者,我从网络和书籍中学习了很多教程,我担心事情可能不会成功,或者很难在JRuby上工作。这种怀疑是否有充分的根据?

I'd say yes, see my first point.

我会说是的,看我的第一点。

How does it effect deployment onto non-JRuby platforms such as Heroku etc?

它如何影响非jruby平台(如Heroku等)的部署?

The more your development environment strays from your production environment the more 'wacky' bugs will turn up. The alternative is to deploy to google app engine using jRuby.

开发环境越偏离生产环境,出现的“古怪”bug就越多。另一种选择是使用jRuby部署到谷歌应用程序引擎。

On the other hand, who will write the jRuby tutorials if there is no demand?

另一方面,如果没有需求,谁将编写jRuby教程?

#3


1  

I use Netbeans, Textmate, and Vim, but usually Netbeans. I love Netbeans's integrated debugging it is very helpful at times. Netbeans and Vim are cross platform and that is a big deal to me. I hate being dependent on software that is only available for one OS. I'm pretty sure I have tried just about every IDE for Rails, and Netbeans is the best Rails IDE in my oppionion, but I digress.

我使用Netbeans、Textmate和Vim,但通常使用Netbeans。我喜欢Netbeans的集成调试,它有时非常有用。Netbeans和Vim是跨平台的,这对我来说很重要。我讨厌依赖于只有一个操作系统的软件。我确信我已经尝试了几乎所有的Rails IDE,而Netbeans是我的oppionion中最好的Rails IDE,但是我离题了。

cwninja is right about JRuby's gem incompatibilities, albeit most gems are supported with JRuby. See http://isitjruby.com/ for supported gems. JRuby has a lot of momentum right now and is a strong development choice. In theory, choosing JRuby, or MRI should be inconsequential, but don't hold me to that. JRuby does allow to easily switch ruby compatibility between 1.8.x and 1.9.x pretty easily, but then again you could use RVM (which happens to be the bomb) to achieve this.

cwninja对JRuby的gem不兼容性是正确的,尽管大多数gem都支持JRuby。有关支持的gem,请参见http://isitjruby.com/。JRuby现在有很多发展动力,是一个很好的开发选择。理论上说,选择JRuby或MRI是无关紧要的,但不要让我这样做。JRuby允许在1.8之间轻松切换ruby兼容性。1.9 x和。很简单,但是你可以使用RVM(碰巧是炸弹)来实现这一点。

Either way, if you are considering using different ruby interpreters, take a look at RVM. It allows you to easily install and manage most ruby interpreters easily.

无论哪种方式,如果您正在考虑使用不同的ruby解释器,请查看RVM。它允许您轻松地安装和管理大多数ruby解释器。

#4


0  

Look TBH moving away from a UNIX system towards a Windows system for Ruby developement, well it just seems stupid. Don't use a Mac if you don't want to, but a lot of stuff on Windows will just not work very well. You will spend more time screwing with stuff to get it working, than doing any work.

看看TBH从UNIX系统转向Windows系统的Ruby开发,这看起来很愚蠢。如果你不想用的话,不要用Mac,但是Windows上的很多东西都不能很好地工作。你会花更多的时间在工作上,而不是做任何工作。

I recommend not using a code completing editor, it doesn't help you learn. I would say stay away from that till you have a good grounding in the language, learn where to look things up APIs etc before you start trying to shortcut things.

我建议不要使用代码完成编辑器,它不会帮助您学习。我想说的是,在你有了良好的语言基础之前,要远离它,在你开始尝试使用快捷方式之前,先学习如何查找api等等。

JRuby is definately a good alternative to MRI ruby, but if you are following tutorials it may just add the level of WTF as you learn that may well be counter productive, but if you do go to windows JRuby is probably the best way to go.

JRuby无疑是MRI ruby的一个很好的替代品,但是如果您正在学习教程,它可能只会增加WTF的级别,因为您知道这很可能会产生相反的效果,但是如果您使用windows JRuby,那么JRuby可能是最好的方法。

Good luck.

祝你好运。

#5


0  

I started with MRI on OS X and then Windows. I use JRuby on Windows currently, but still fall back to MRI on Windows to check behavior, which is something you'll get used to. JRuby is undergoing a lot of changes to get it compatible with Ruby 1.9 and Ruby itself is somewhat of a moving target.

我从OS X上的MRI开始,然后是Windows。我目前在Windows上使用JRuby,但仍然使用MRI检查Windows上的行为,这是您会习惯的。为了使JRuby 1.9与Ruby兼容,JRuby正在进行大量的修改,而Ruby本身就是一个不断变化的目标。

Looking at the differences between the two and reporting bugs though will ultimately strengthen your understanding of both, and will help both teams push the language forward.

尽管查看这两个bug和报告bug之间的差异将最终增强您对它们的理解,并将帮助两个团队推动语言向前发展。

#1


2  

Realistically you don't need code completion for Rails. TextMate is by far the most commonly used editor in the Ruby world, and it's more than sufficient for everything in Ruby. Ruby doesn't require anywhere near as much tool support as Java. So I would say that if the editor issue is the only reason you're opting for JRuby, it's not a very good reason. Because you're right, there are lots of gems that don't work in JRuby because they use a native extension of some kind. That said, the most popular gems tend to work in JRuby. Performance in JRuby still isn't quite as good as Ruby 1.9, but in a lot of cases it's comparable to MRI 1.8. Personally, I'd recommend treating JRuby as an advanced Ruby concept. It will run Rails, but yes, you're going to find that you won't be able to just follow along with a tutorial, and everything will be ever-so-slightly harder for a beginner. JRuby isn't a particular daunting piece of technology, but it might be more of a hurdle than you want to overcome as a beginner.

实际上,您不需要为Rails完成代码。TextMate是Ruby世界中最常用的编辑器,对于Ruby中的所有东西来说,它已经足够了。Ruby不需要像Java那么多的工具支持。所以我想说,如果编辑器问题是您选择JRuby的唯一原因,那么这不是一个很好的理由。因为您是对的,在JRuby中有很多gem不能工作,因为它们使用某种本地扩展。也就是说,最受欢迎的gem通常使用JRuby。JRuby的性能仍然不如Ruby 1.9,但在很多情况下,它可以与MRI 1.8相媲美。我个人建议将JRuby视为一个高级Ruby概念。它会运行Rails,但是,是的,你会发现你不可能仅仅跟随一个教程,而所有的东西对于初学者来说都将变得更加困难。JRuby并不是一项令人望而生畏的技术,但它可能比您作为初学者想要克服的障碍更大。

I highly recommend shelling out the Euros for a copy of TextMate anyways, even if you don't do your development in it primarily. It's worth every penny and then some. Work in that environment for awhile and see if you really need your IDE. I'm betting you won't.

无论如何,我强烈建议你花更多的钱去买一份TextMate,即使你并没有开发它。一分钱一分货。在这种环境中工作一段时间,看看是否真的需要IDE。我敢打赌你不会。

#2


1  

My question is, is JRuby going to complicate learning rails?

我的问题是,JRuby是否会使学习rails变得更加复杂?

Yes, because all the tutorials, beginner docs, and most of the devs who will normally be able to help you out are assuming MRI, so for each issue you have you must first eliminate a jRuby related cause.

是的,因为所有的教程、初学者文档和大多数通常能够帮助您解决问题的开发人员都假定为MRI,所以对于每个问题,您必须首先消除与jRuby相关的原因。

From what I have seen, certain gems aren't supported on JRuby, or things might be done a little differently in that ecosystem.

从我所看到的情况来看,在JRuby中不支持某些gem,或者在这个生态系统中可能会做一些不同的事情。

Any gems that are written with C native extensions need to be ported to jRuby (the inverse is also true, but the issue is rarer).

使用C本地扩展编写的任何gem都需要移植到jRuby中(反之亦然,但问题更少)。

As a learner, I follow a lot of tutorials from the web and from books and I am worried that things might not work or will be hard to get working on JRuby. Is this scepticism well founded?

作为一个学习者,我从网络和书籍中学习了很多教程,我担心事情可能不会成功,或者很难在JRuby上工作。这种怀疑是否有充分的根据?

I'd say yes, see my first point.

我会说是的,看我的第一点。

How does it effect deployment onto non-JRuby platforms such as Heroku etc?

它如何影响非jruby平台(如Heroku等)的部署?

The more your development environment strays from your production environment the more 'wacky' bugs will turn up. The alternative is to deploy to google app engine using jRuby.

开发环境越偏离生产环境,出现的“古怪”bug就越多。另一种选择是使用jRuby部署到谷歌应用程序引擎。

On the other hand, who will write the jRuby tutorials if there is no demand?

另一方面,如果没有需求,谁将编写jRuby教程?

#3


1  

I use Netbeans, Textmate, and Vim, but usually Netbeans. I love Netbeans's integrated debugging it is very helpful at times. Netbeans and Vim are cross platform and that is a big deal to me. I hate being dependent on software that is only available for one OS. I'm pretty sure I have tried just about every IDE for Rails, and Netbeans is the best Rails IDE in my oppionion, but I digress.

我使用Netbeans、Textmate和Vim,但通常使用Netbeans。我喜欢Netbeans的集成调试,它有时非常有用。Netbeans和Vim是跨平台的,这对我来说很重要。我讨厌依赖于只有一个操作系统的软件。我确信我已经尝试了几乎所有的Rails IDE,而Netbeans是我的oppionion中最好的Rails IDE,但是我离题了。

cwninja is right about JRuby's gem incompatibilities, albeit most gems are supported with JRuby. See http://isitjruby.com/ for supported gems. JRuby has a lot of momentum right now and is a strong development choice. In theory, choosing JRuby, or MRI should be inconsequential, but don't hold me to that. JRuby does allow to easily switch ruby compatibility between 1.8.x and 1.9.x pretty easily, but then again you could use RVM (which happens to be the bomb) to achieve this.

cwninja对JRuby的gem不兼容性是正确的,尽管大多数gem都支持JRuby。有关支持的gem,请参见http://isitjruby.com/。JRuby现在有很多发展动力,是一个很好的开发选择。理论上说,选择JRuby或MRI是无关紧要的,但不要让我这样做。JRuby允许在1.8之间轻松切换ruby兼容性。1.9 x和。很简单,但是你可以使用RVM(碰巧是炸弹)来实现这一点。

Either way, if you are considering using different ruby interpreters, take a look at RVM. It allows you to easily install and manage most ruby interpreters easily.

无论哪种方式,如果您正在考虑使用不同的ruby解释器,请查看RVM。它允许您轻松地安装和管理大多数ruby解释器。

#4


0  

Look TBH moving away from a UNIX system towards a Windows system for Ruby developement, well it just seems stupid. Don't use a Mac if you don't want to, but a lot of stuff on Windows will just not work very well. You will spend more time screwing with stuff to get it working, than doing any work.

看看TBH从UNIX系统转向Windows系统的Ruby开发,这看起来很愚蠢。如果你不想用的话,不要用Mac,但是Windows上的很多东西都不能很好地工作。你会花更多的时间在工作上,而不是做任何工作。

I recommend not using a code completing editor, it doesn't help you learn. I would say stay away from that till you have a good grounding in the language, learn where to look things up APIs etc before you start trying to shortcut things.

我建议不要使用代码完成编辑器,它不会帮助您学习。我想说的是,在你有了良好的语言基础之前,要远离它,在你开始尝试使用快捷方式之前,先学习如何查找api等等。

JRuby is definately a good alternative to MRI ruby, but if you are following tutorials it may just add the level of WTF as you learn that may well be counter productive, but if you do go to windows JRuby is probably the best way to go.

JRuby无疑是MRI ruby的一个很好的替代品,但是如果您正在学习教程,它可能只会增加WTF的级别,因为您知道这很可能会产生相反的效果,但是如果您使用windows JRuby,那么JRuby可能是最好的方法。

Good luck.

祝你好运。

#5


0  

I started with MRI on OS X and then Windows. I use JRuby on Windows currently, but still fall back to MRI on Windows to check behavior, which is something you'll get used to. JRuby is undergoing a lot of changes to get it compatible with Ruby 1.9 and Ruby itself is somewhat of a moving target.

我从OS X上的MRI开始,然后是Windows。我目前在Windows上使用JRuby,但仍然使用MRI检查Windows上的行为,这是您会习惯的。为了使JRuby 1.9与Ruby兼容,JRuby正在进行大量的修改,而Ruby本身就是一个不断变化的目标。

Looking at the differences between the two and reporting bugs though will ultimately strengthen your understanding of both, and will help both teams push the language forward.

尽管查看这两个bug和报告bug之间的差异将最终增强您对它们的理解,并将帮助两个团队推动语言向前发展。