简体   繁体   English

JRuby是否可以替代Rails开发的MRI?

[英]Is JRuby a viable alternative to the MRI for Rails development?

I am a beginner-verging-on-intermediate rails developer that is working hard to improve my skills. 我是一个初学者 - 中级轨道开发人员,正在努力提高我的技能。

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的可行替代方案。

Currently I run a Mac at home and edit using textedit (MRI for ruby, terminal for rails commands, etc). 目前我在家里运行Mac并使用textedit进行编辑(MRI用于ruby,终端用于rails命令等)。 At work, I use NetBeans on Windows, but don't do any Ruby work there. 在工作中,我在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. 我非常喜欢在工作中使用Netbeans,我可以看到使用Netbeans在Windows上使用JRuby并允许JRuby管理我的宝石将是一个相对愉快的体验。 I like the idea of code completion and a full IDE rather than a text editor (without starting an editor flame war). 我喜欢代码完成的想法和完整的IDE而不是文本编辑器(没有启动编辑器火焰战争)。

My question is, is JRuby going to complicate learning rails? 我的问题是,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上不支持某些宝石,或者在该生态系统中可能会有所不同。 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. 作为一名学习者,我会从网络和书籍中学习很多教程,我担心事情可能会起作用,或者很难在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平台,如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,MRI或OpenSolaris上的JRuby等等。我认为无论哪种方式,我都会使用Netbeans。

Any comments are appreciated. 任何评论都表示赞赏。

Realistically you don't need code completion for Rails. 实际上,您不需要Rails的代码完成。 TextMate is by far the most commonly used editor in the Ruby world, and it's more than sufficient for everything in Ruby. TextMate是目前Ruby世界中最常用的编辑器,对于Ruby中的所有内容来说,它已经绰绰有余了。 Ruby doesn't require anywhere near as much tool support as Java. Ruby不需要像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. 所以我想说如果编辑问题是你选择JRuby的唯一原因,那不是一个很好的理由。 Because you're right, there are lots of gems that don't work in JRuby because they use a native extension of some kind. 因为你是对的,有很多宝石在JRuby中不起作用,因为它们使用某种原生扩展。 That said, the most popular gems tend to work in JRuby. 也就是说,最流行的宝石往往在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. JRuby的性能仍然不如Ruby 1.9,但在很多情况下它与MRI 1.8相当。 Personally, I'd recommend treating JRuby as an advanced Ruby concept. 就个人而言,我建议将JRuby视为高级Ruby概念。 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. 它会运行Rails,但是,是的,你会发现你将无法按照教程进行操作,对于初学者来说,一切都会变得如此艰难。 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. 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. 无论如何,我强烈建议将欧元用于支持TextMate的副本,即使您不主要在其中进行开发。 It's worth every penny and then some. 值得每一分钱,然后一些。 Work in that environment for awhile and see if you really need your IDE. 在该环境中工作一段时间,看看你是否真的需要你的IDE。 I'm betting you won't. 我打赌你不会。

My question is, is JRuby going to complicate learning rails? 我的问题是,JRuby是否会使学习轨道复杂化?

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上不支持某些宝石,或者在该生态系统中可能会有所不同。

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. 作为一名学习者,我会从网络和书籍中学习很多教程,我担心事情可能会起作用,或者很难在JRuby上工作。 Is this scepticism well founded? 这种怀疑主义是否有充分根据?

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. 另一种方法是使用jRuby部署到谷歌应用引擎。

On the other hand, who will write the jRuby tutorials if there is no demand? 另一方面,如果没有需求,谁会写jRuby教程?

I use Netbeans, Textmate, and Vim, but usually Netbeans. 我使用Netbeans,Textmate和Vim,但通常使用Netbeans。 I love Netbeans's integrated debugging it is very helpful at times. 我喜欢Netbeans的集成调试,有时非常有帮助。 Netbeans and Vim are cross platform and that is a big deal to me. Netbeans和Vim是跨平台的,这对我来说很重要。 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. 我很确定我已经尝试过几乎每个IDE for Rails,Netbeans是我最好的Rails IDE,但我离题了。

cwninja is right about JRuby's gem incompatibilities, albeit most gems are supported with JRuby. cwninja对JRuby的宝石不兼容性是对的,尽管JRuby支持大多数宝石。 See http://isitjruby.com/ for supported gems. 有关支持的宝石,请访问http://isitjruby.com/ JRuby has a lot of momentum right now and is a strong development choice. JRuby现在有很多动力,是一个强大的开发选择。 In theory, choosing JRuby, or MRI should be inconsequential, but don't hold me to that. 从理论上讲,选择JRuby或MRI应该是无关紧要的,但不要指责我。 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. JRuby允许轻松地在1.8.x和1.9.x之间轻松切换ruby兼容性,但是你可以再次使用RVM (恰好是炸弹)来实现这一点。

Either way, if you are considering using different ruby interpreters, take a look at RVM . 无论哪种方式,如果您正在考虑使用不同的ruby解释器,请查看RVM It allows you to easily install and manage most ruby interpreters easily. 它允许您轻松地轻松安装和管理大多数ruby解释器。

Look TBH moving away from a UNIX system towards a Windows system for Ruby developement, well it just seems stupid. 看看TBH从UNIX系统转向用于Ruby开发的Windows系统,这看起来很愚蠢。 Don't use a Mac if you don't want to, but a lot of stuff on Windows will just not work very well. 如果你不想使用Mac,请不要使用Mac,但Windows上的很多东西都不会很好用。 You will spend more time screwing with stuff to get it working, than doing any work. 与做任何工作相比,你会花更多的时间搞砸东西来让它工作。

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红宝石的一个很好的替代品,但是如果你正在学习教程,它可能只是增加了WTF的水平,因为你知道这可能会适得其反,但如果你去Windows,JRuby可能是最好的方法。

Good luck. 祝好运。

I started with MRI on OS X and then Windows. 我开始在OS X上使用MRI,然后是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. 我目前在Windows上使用JRuby,但仍然在Windows上使用MRI来检查行为,这是你会习惯的。 JRuby is undergoing a lot of changes to get it compatible with Ruby 1.9 and Ruby itself is somewhat of a moving target. JRuby正在进行大量更改以使其与Ruby 1.9兼容,而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. 查看两者之间的差异并报告错误,最终会加强您对两者的理解,并将帮助两个团队推动语言向前发展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM