Ruby on Rails vs. Java

Whenever I bring up Ruby on Rails to Java programmers I always get an immediate defensive. For some reason Java programmers seem threatened by Rails. I am sure it is more to do with fanatisim that both camps have for their language. When evaluating a new endeavor however, it is wise to make an open minded decision about the framework to use.

Now there are some areas where these two languages overlap like JRuby. However, JRuby is really just Ruby compiled in Java. There are some benefits if you have some legacy Java system to integrate with, but the overhead of running on the JVM instead of the native Ruby engine really eat up some of the benefits of Ruby on Rails in the first place. The main area where JRuby has a home is in close minded organizations that won’t “allow” another operating platform to be used. Enterprising developers then develop a full blown Ruby or Ruby on Rails applicaiton and just deploy it on the Java EE platform in use by the enterprise.

There are strengths and weaknesses to both of these platforms. Evaluating these and looking at your target are essential to making a good decision. Rails is very good when you have total control over your design including database platform, table designs, graphic layouts. Rails is also a good choice for design shops that are heavy on graphic designers and light on programmers. Where Java and it’s many platforms shine is in environments where you have a legacy system that can’t be changed. It is also very good for times when you have other systems particularly SOAP or other EE systems to interface with.

With all this said I am about to enbark a new adventure. The primary platform is going to be Rails. The reasoning behind this is the lighweight deployment architecture, built in support for many web based functions, and the active community. I am already faced though with a shortcoming in the Ruby on Rails architecture. Threads. I have a data structure that is not well suited to a database it is going to be a Graph of user relationships that I need to parse out at least 3 degrees deep for many operations. The standard MySQL database doesn’t really have anything yet to support these types of complex relationships. I could implement a graph object in Ruby, however, it can’t be shared between the processes running on the application server very easily.

In comes the Java EE server. I am looking at a very light RESTfull web service to handle my relationships. I will post some additional posts and guides once I have things up and running as I am not really finding many examples where Rails ActiveResource is a consumer of a Java service.

For an update check out my revised position on jRuby: Revising my position on jRuby.

This entry was posted in Java, Ruby on Rails. Bookmark the permalink.

14 Responses to Ruby on Rails vs. Java

  1. nash says:

    Its 2010 and you still bringing up this comparison :) . Java has learnt from its mistakes and is now simple, scalable, robust, full of best known design ideas.

  2. Bill Leeper says:

    I don’t disagree that Java is ever evolving, but I am just not seeing the easy to use tutorials and helpers that the Rails community is putting out.

    As I said in the article both have their strengths and weaknesses. My current project at work would never work with Rails, it’s just too complex and integrates with too many other systems.

    I program all day in Java, but when I am home and want to just do some fun programming, I do it in Rails.

  3. chris says:

    Hi Bill,

    I wonder if you can help. We have a java website that works ok, but needs some modernising and some new gimmiks etc. We sell self catering holidays in the UK. My developers, who initially built the site, now want me to convert to Ruby from Java. This means a whacking great cost. We have a database system which is well integrated with the current website.

    My questions are these: why would the developer want me to switch from Java to Ruby? (The cost is significant for a small business like ours) Is there any benefit? What about the implications for our search engine positions with a switch?

    Your feedback would be VERY welcome

  4. Bill Leeper says:

    Without knowing the details of your specific implementation it can be a little tough to give a response.

    I have been in your developers position pushing for a change to another platform, however, it is often a difficult position for a business to fund and more often than not I have not made the switch from one technology to another.

    Here are some points.

    1. Ruby applications tend to be less complex overall, making changes faster to turn around, however, if you are adding features that account for less than 50% of the overall application switching frameworks is a lot of overhead cost. On the other hand if you are making sweeping changes it may be possible that a complete re-write will cost less in the end. Ask for detailed estimates on each solution (be prepared for them to pad the Java implementation though to support their point).
    2. Rails has a lot of the new modern capabilities either built in or readily available as add ons. I have found lately that the Java community is not producing these types of modules as much as the Rails community is.
    3. Rails is somewhat inflexible with existing database systems. It is better suited for new work. Java is more configuration driven and hence more flexible around database designs that don’t exactly match the web site design. Not impossible with Rails, just more work than when the whole system lines up from a design perspective.

    I have introduced Rails at several companies I have worked, but always with new projects, then we reduce risk and cost. Over time we rolled in more features into the new platform.

    The current state of the code and the amount of effort to fix it up to work with the new features you want is probably the biggest factor. If you are just doing some visual stuff then javascript (especially jQuery) and css styling should be able to take care of most of it with little back end code changes. If you are changing the way the system works then Rails might be more of a justification.

    Additionally if this is a contract company and they did your original work and are now not happy with that work, it may be time to get competing bids from another company. An independent analysis on the quality of the original code might help with the decision. If the Java code is of high quality then making updates in Java should be cheaper than a rewrite in Rails, on the other hand if the quality is poor (the actual code, not how well it works), then picking a different agency might be a good move, even if they also recommend Rails.

    Good Luck

  5. BM says:

    I can not say anything about RoR, but just few correction to a Java-related stuff:

    1. “Ruby applications tend to be less complex”.
    Complexity is a very relative meaning here. Java is a static language, don’t forget that. This helps really a lot, when project gets very large. Also, you do not need to write complexity in Java by simply avoiding bloated frameworks. You can go famous “indian way” to codegrind a pile of garbage, where voodoo and shamanism is required to figure it out. :) But you can do it very small, compact, robust and cute. All depends on /dev/hands after all.

    2. Capabilities.
    Not sure what you’re talking about here, so can not really comment.

    3. DB and flexibility.
    Java is completely flexible with anything. The logic here to do not expose things to outside. The less you give to expose on public, the more flexible you are inside. This is completely non-valid with e.g. Python, where you can screw up entire object at run-time, use “hidden” methods and then fall apart, when new version will remove/update/change methods.

    Also, to be “configuration based” is very good thing. In normal and well-controlled infrastructure, you are NOT allowed to change the source code. Therefore you’re driven do design your software in “right way”. Not sure about Ruby on Rails, but Zope3 is trying to do that and now suffers from slow performance. :)

    Hope Ruby guys will move towards config-based way, instead to change source.

  6. ff1959 says:

    I enjoyed reading your post. Most RoR vs. Java arguments involve turning strengths into weaknesses and weaknesses into strengths, depending on your position, viz, static vs. dynamic typing, or Emacs vs. vi, or Eclipse vs. NetBeans. Your post was much more pragmatic. Well done.

  7. Raul Herrera says:

    I, with much respect do not agree with:

    “Rails is somewhat inflexible with existing database systems. It is better suited for new work. Java is more configuration driven and hence more flexible around database designs that don’t exactly match the web site design. Not impossible with Rails, just more work than when the whole system lines up from a design perspective.”

    Yes, there are facilities if the database is already in a “rails way” because is “convention over configuration” but there is not trouble to customize exactly like Java/JSP or any other language does.

  8. reddy challa says:

    I am just entering into programming field. Many of them are encouraging me to take Ruby on Rails. What would you guys suggest about it. What choices will you suggest in .Net, Java or Ruby on Rails.

  9. Bill Leeper says:

    It does depend a bit on your goals. Many companies use Java or .NET for their internal IT applications. Ruby on Rails is a more entrepreneurial language at the moment, although this is changing. Rails is making a lot of headway into traditional areas such as IT and Government. There are a lot of jobs in all 3. Rails and the underlying language Ruby are probably the easiest to lean and get up and running with.

  10. EA says:

    Your article reminds me the Java Vs C++ argument, back in the days. Back then, I am talking about 13-15 years ago, the C++ camp folks thought that Java was slow (high footprint of jvm and the libraries) and inflexible (you can’t have multiple superclasses, WHAT?!). It took about 10 years for Java to become a mature platform. Java has been well tested on many software applications and architectures with multi-years software development cycles. Only time can tell if Ruby/RoR can get to that stage. In the meantime, I think RoR is a great RAD tool. Very easy to learn and to get a project started….just like Visual Basic (Let’s see how much heat I will get for saying this)

  11. Joe says:

    Yeah in some way it’s similar to Java vs C++. Although roles have changed:

    C++ is a complex, expressive language. Java on the other hand is simple and lacks expressiveness on purpose, take absent operator overloading for instance. People who want to write good C++ code must know the language very well and must be disciplined when writing code. Java on the other hand can be written without any discipline because the language is simpler.
    Ruby on the other hand is a much richer language than Java, it is more expressive than C++. For small projects Ruby is much safer than C++ and in most situations safer than Java because you need less variables (that could become null) to do a job. For large projects on the other hand you need a lot of discipline to keep it maintainable and structured.
    In my opinion Ruby’s problem is that most of it’s popularity is due to Rails. Rails is an ultra complex web framework that makes the programmer force it’s code into the Rails structures/MVC. Unfortunately this doesn’t always makes sense or even prevents you from doing stuff. So people stuff to (ab)use metaprogramming to work around these short-comings.

    That’s the reason why MRI has no real threading support and why there is still no literature about decent software design in Ruby. Ruby is nice but RoR is like Java for Ruby.. ;-)

  12. Bob says:

    In the past few days I installed Ruby and then Ruby on Rails. The documentation and tutorials have been great and the installation has been smooth and painless. I see the configuration to connect with MySQL database (as well as others) is also very easy. These are the kind of things I am looking for since my goal is to start a web business soon and the main component is essentially the web design. Quite personally I don’t feel like screwing around with IT related crap. Just want to get up and running implementing my ideas. So for aspiring web entrepreneurs I would recommend RoR.

  13. Robert Miller says:

    Ruby can’t defeat Java

    C# might defeat Java
    but Ruby can’t defeat Java

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree