Is JRuby a viable alternative to the MRI for Rails development? - ruby-on-rails

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.
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.
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).
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).
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?
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.
Any comments are appreciated.

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.
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.

My question is, is JRuby going to
complicate learning 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.
From what I have seen, certain gems
aren't supported on JRuby, or things
might be done a little differently in
that ecosystem.
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).
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?
I'd say yes, see my first point.
How does it effect deployment onto
non-JRuby platforms such as Heroku
etc?
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.
On the other hand, who will write the jRuby tutorials if there is no demand?

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.
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.
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.

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.
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.
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.
Good luck.

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.
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.

Related

Developing Ruby and Rails in Windows? Or Linux VM

I've been doing front end web work for a while. I maintain several company websites and etc, mostly on Joomla. I'm getting bored with it and I really want to expand in to development. I have a few web app ideas for the company and some personal stuff I'd like to do.
Ive decided I want to learn Ruby and Rails and have been pursuing it for about a month now. I read a lot of tutorials and work through stuff I find online. I'm also diving in to git and trying to use it more.
I feel like Windows is not going to be conducive to me getting efficient at this. I know that you can, and some do, develop in Windows but I'm wondering if its time for me to move past it.
I picked Ruby to be my first real programming language because of the simplicity I read about. For both Ruby and RoR and I want to be able to learn a language that will let me build apps and web apps that are cross platform.
On to the problem, I can't immerse myself completely in a linux world. I have to have photoshop and indesign for part of my job. So I'm thinking maybe I should just do a live usb key install and take it back and forth between work and home. Is that a better solution than dual booting for what I want to do? I also realize that a mac would give me the best of both worlds, but I am budget constrained and I can't make that leap yet.
Also, is there a good place to hang out to learn more? I have paid codeschool and tutsplus accounts. Should I be back on IRC? What do you think? I'm looking for guidance more than anything I guess. I feel kind of lost on where to go how to not waste time and start developing real skills. Thanks.
You should also checkout the vagrant project which creates headless (non-gui) VMs and makes it easier to work with your files, etc in Windows while the code actually gets run on the Vagrant VM. Also, since its headless, the graphical UI isn't eating up resources and has less impact on your host machine.
Check out these resources:
http://www.vagrantup.com/
http://blog.dcxn.com/2013/07/12/introduction-to-vagrant-for-rails-developers/
http://railscasts.com/episodes/292-virtual-machines-with-vagrant
*Also if you're learning Rails, you MUST checkout Railscasts http://railscasts.com/
The last thing I knew about this is that:
In Linux you can use RVM which handles pretty well everything about your Ruby environment. In Windows I tried pik, but it does not have support to install newer Rubies.
Also, Linux console is much friendlier than Windows one, regarding appearance and functionality. I have explored console2 for Windows, but it did not feel so comfortable that time.
In Linux you have plugins like oh-my-zsh which allows you to speed up your development. But maybe there are kind of this plugin for Windows.
Other than those, I don't know why you should choose Linux VM.
I've developed a Rails app under Windows, and it turned out to be a huge mistake. Near the end of the development, I had to make my webapp multithreaded. The default Rails server does not allow multithreading, and all the alternative servers are either Linux-only, or I couldn't get them to work.
I also considered using JRuby(because Java threads), but by then my app was too big to convert to JRuby(there are some syntax differences that I couldn't track, and I relayed on some gems that don't work on JRuby). However, if you go for JRuby from the beginning, you might be able to pull it off.

Using Rails as a framework for a large website

I've been playing around with Rails (version 3) for a few months now and I understand the framework fairly well. However, I have yet to develop a large website which offers lots of database access and user interaction.
I'm fairly skeptical of the following:
The Speed and Scalability of Ruby (I've heard that its up to 10 times slower than most other server-side languages).
The extra background processing that Rails as a framework (multiple levels of abstration).
The lack of enterprise-level web apps that run on Rails (the only ones that I can think of Groupon, Github and Hulu).
The complexity of the environment (nginx > mongrel > rails > ruby > website).
The behind-the-scenes SQL operations (I know that these can be optimized, but I'm sure that I'll miss some).
For these reasons, I'm unsure whether to continue using Rails or to switch to something that is built ontop a more performant language .. say Java Spring.
Please advise :)
There are tons of large sites and infrastructures in production that use Rails. This question has also been asked to death over the years of Rails being actively used for all manner of web apps, large and small.
Short version is that it is not the fastest language around but despite that scales fine if you know what you are doing. And you should have enough money to hire people that know what they are doing if you actually have any problems of scale.
Scaling any webapp is hard, use the language/framework you know. Programmer happiness is king.
You can get good performance with Ruby. Easy:
require 'inline'
inline :C do |builder|
builder.c <<-C_CODE
void run() {
// Write your entire application in C here
}
C_CODE
end
run
Problem solved ;)
Not the speed and scaling discussion again?
In webdevelopment the things that are the slowest is the network communication (receiving the request, getting al your data back), the database (getting all your data from the database), and most of the times it is not about the computation time at all.
While it is true that Ruby and Ruby on Rails seem more focused on programmer happiness, I think that every decent web-application built in .NET or Java has as many levels of abstraction.
The complexity of the environment? I think you mean deploying? There are a lot of options, but the most used options are Passenger (very easy deployment on top of an apache or nginx), or Torquebox.
Torquebox for the moment is the fastest, best scaling solution (based on JBoss Application server), and several big names in the Ruby community are calling Jruby the implementation of choise to deploy your applications. While AFAIK the commonest deploy still is using REE (Ruby Enterprise Edition) and Passenger.
Unless you know you are going to have to do serious mathematical, cpu-intensive operations, I think the question you should ask yourself is: which framework/language will give me the quickest result?
If you are very proficient in Java/Spring, that might be the answer for you. But if your only worry is performance in general, I would say: do not hesitate and go for Ruby on Rails. It is a pure joy to develop in. The ruby community is really awesome if you would encounter any issues: support is just a post away.
And to conclude, I want to add a few very big sites using Rails: LinkedIn is using rails (and jruby), and Twitter still is using Rails for their frontend.

Setting up Ruby on Rails beginner netbeans

WOW. Setting up is complicated, can anyone recommend a link or provide me with some advice.
I have two options, a Linux Hosting server with it pre-installed or through NetBeans.
Sorry for the generic question.
I think that you are going to want both of your options. You will want to have a hosting server with Rails installed on which you will deploy your Rails application. You will want to use NetBeans on your development machine to develop the application in the first place.
It is good to note that using NetBeans is not mandatory; you can -- and many others do -- use any random text editor for building Rails applications. However, I use NetBeans for Rails development, as I find that it greatly increases my productivity.
Don't let yourself get overwhelmed by the feeling of complexity at the beginning. While getting on to the learning curve can be tricky for any system, I believe that climbing the curve with Rails is easier than with many or most other web application frameworks.

Is Rails-2.3 stable? Does anyone have any problems with it?

I want to develop an application in Ruby on Rails. I have used rails(vigorously) a couple of years ago. since then i haven't given it a try, i have been concentrating on core ruby. At that time, Rails(1.2.x) used to be a bit slow! so my problem is whether i should go for the earlier slower version or should i try newer versions... is it fast and STABLE? And does it have proper support for all the gems that were made for earlier versions?
Thanks
Compared to two years ago, you should be impressed with where Rails is at. Here are some things to take note of.
mongrel is still fine as a server, but many (most?) people are using Phusion Passenger. I'm running a few apps in production mode with Passenger, and it's great. It plugs into Apache with a very small and simple set of directives. You won't have to set up balancers or rewriters like you used to.
Phusion also offers RubyEE, which is their own, more efficient version of Ruby. The installer works in such a way that if you decide you don't like, it can be removed by simply deleting its directory. It's all self-contained.
rmagick is still just as awful to install as it ever was, but now there is Paperclip as an alternative.
You'll love how fast 2.3 loads the console.
named_scopes are a huge step forward. Be sure to read up on them.
There are dozens of other reasons to upgrade, most of which can be found on this site. Unless you have an axe to grind with Rails, I doubt that you'll be disappointed with it.
Now, when you ask about stability, the answer is "sure, it's stable." However, you gave no information regarding what types of user loads you're trying to support. More detailed questions could lead to more detailed answers.
Edit
Answering your comment.
10 Cool Things in Rails 2.3 by Luke Francl. This is a nice summary of the latest highlights.
No problems with Rails 2.3 yet! No Problems with gems as well! Give it a try, it rocks! ;)
2.3.4 is stable enough if you are running Ruby 1.8.6/7, not so much if you are running Ruby 1.9.1 (even though it should technically support it properly).
If you are going to run Ruby 1.9.1, good on you, the speed improvements are really good, however you will have to be aware that some things wont work as intended and will need some patching of either core Ruby or Rails.
Saying that I would still avoid REE. Anything that has malloc'd for me in development I wouldn't trust in production.

Is there a good resource for data on Ruby Enterprise Edition usage in the wild?

We're having great results with the Phusion stack (Passenger and Ruby Enterprise Edition) in house, but I haven't been able to find much in the way of data on their use in the wild, particularly REE. I'd love something akin to WWR's High Profile Organizations Using Rails or Ben Forta's Who's Using ColdFusion? list.
There's some google group activity on this, but I'm looking for something more, for lack of a better word, PHB-friendly.
Passenger is being used by a lot of people including Engine Yard.
REE does not have as widespread adoption.
But the same was true of jRuby before too, now many are using it.
I would recommend against REE, have had stability issues with it giving me malloc errors when i used script/console.
Can't provide a set of instructions on how to replicate it. Just seemed to happen.

Resources