ShareThis

Tuesday, October 22, 2013

Is it Ruby on Rails or Java for You?

Rails vs Java
So you have a web development project in mind to be developed from scratch. For sure, it is a complex web application that has got to be rich in feature, scalable and maintainable. Among these core requirements, it’s difficult for teams to choose a programming language or a web framework that is objectively the best to suit the given requirements.

There are hosts of technologies and programming languages available. Of these enterprises have widely embraced open source object-oriented programming languages like Java, Python, Ruby etc. for their web development requirements. Considering the coding advantages and structure of language, the most preferable languages that come to my mind are Ruby on Rails and Java since the other language i.e. Python is loosely structured which makes the development process longer.

Now the question here arises whether to choose Ruby on Rails or Java technology for your web application development requirements.

Let us take a closer look at both these technologies from the following perspectives to make an objective decision-

Find out the bests of Java & Ruby



Tools, Libraries and APIs:
Since Java has been around for a long time, there are several tools, APIs and libraries available which makes its infrastructure more powerful than Ruby. Having this kind of infrastructure is more essential when a company matures and customers demanding high quality services and features expands. Since Ruby is younger than Java, it lacks the support of such tools, libraries and APIs. This makes Ruby stand lower compared to Java.

Learning Curve:
As Java comes with various combinations of libraries and technologies to be applied while coding, developers have to spend more time in learning different architecture and sorting out the details. On the contrary, Ruby helps you get started quickly due to its simple development architecture which is easy to learn and apply. Hence the vote goes to Ruby for the advantage on learning curve.

Manageability of Codes:
With Java, managing codes and defining classes is easy owing to its statically typed programming language. In Java, especially with Eclipse, you can search defined methods and classes which are better than calling something hypothetical as in Ruby where handling codes and naming classes is difficult due to its dynamic language type. With dynamic typing, it’s confusing and difficult to assume what you are typing and changing since there are no warnings from the Static compiler. This ends up spending more time in Ruby and difficulty in managing codes.

Testability & Robustness:
Although both the languages have good support for regression testing, Ruby is slightly ahead of Java as it relies strongly on automated tests which ensure things do not break easily if there are changes at the other end of the application.

Scalability and Stability:
In terms of scalability and stability, Java beats Ruby due to the scalable architecture of all the frameworks of Java. In the event of outages and unfavorable environments or with a large number of users and database, Java frameworks are more secure and dependable than Ruby. Even corporates prefer Java over Ruby for their critical applications which means Java outweighs Ruby on scalability and stability grounds.

Percentage Hiring:
A survey conducted two years ago in cooperation with the SHARE user group, IBM and Northern Illinois University on 376 employers revealed that Java is the most sought after language by enterprises for hiring. Java accounted for 56% while Ruby constituted only 5%.

Considering the above perspectives, you may find that Java is better if you want the backend of your application to be more scalable and manageable while Ruby can be a choice if you want to get it done quickly. For those who cannot decide, here is an example of the social media giant – Twitter. 

Find out what and how it did.

See what Twitter did

Twitter is one of popular and highly used micro-blogging and social networking services started in 2006.
Twitter & Java

Twitter in its early years was running on Ruby on Rails. With over-usage by people across the world, there was a time when Twitter became vulnerable as the number of tweets and queries increased which created load on the back-end server. Moreover, the search latencies also increased which reduced the request handling making it unavailable for users.

Hence in 2010, the engineers at Twitter realized that Ruby was not enough capable of juggling with the tweets of millions of people across the world.

The team found that Java frameworks because of higher scalability and maintainability were well-suited to develop web-services that can stand the large traffic. The engineers started rewriting the Twitter search engines and moved it from MySQL to Lucene. They also replaced the frond-end Ruby with Blender – a Java Server to improve the search latencies and sustain the traffic.

Twitter engineers also installed JVM (Java Virtual machines) across all their servers and created an independent web service which communicates with each other constantly but also looks after various part of their web application. Like there will be an independent web service that will look after Twitter homepage and another that will handle tweets from mobile.

As a result of these changes, Twitter started running 3x faster without any problems.

Mazen Rawashdeh - Twitter's VP of Infrastructure Operations Engineering then said “The bottom line: No matter when, where or how people use Twitter, we need to remain accessible 24/7, around the world.” "We’re hard at work delivering on that vision."

This is how Twitter moved from ROR to Java and managed to be on top even after so many crisis.

Java surely rules it

From the above example, it’s evident that Java is better than Ruby on several grounds. It is not only a programming language for developing application but also a virtual machine that can run codes built in myriad languages. Even big operations like Google, LinkedIn, Tumblr, and Square, have adopted Java because of its ease of use and ability to handle multiple operations through the JVM.

Owing to its lightweight and fast-to-deploy architecture, Java is gaining recognition. As published in a post on Zd.net, Wired Enterprise’s Editor Cade Metz observed that "Like Twitter, many other companies have realized that Java is particularly well suited to building web services that can stand up to the massive amounts of traffic streaming across the modern internet,"

However, it is still portrayed as an insecure framework but after Oracle acquired Sun – the original producer of Java, it has become more stable and secure programming language.

So now what do you think? Is it ROR or Java for your web development project? Do let us know in commens section. 

Download our Free Whitepaper on Grails: Accelerating J2EE Application Development

8 comments:

  1. "Ruby is slightly ahead of Java as it relies strongly on automated tests"
    I don't know Ruby, but can you add more details about this? How is Ruby more robust than Java. I cover all my cases with tests and have prevented lots of regressions before uploading my code to the version control. Of course, I have to provide my project with proper tests to achieve so (and I guess it goes for Ruby, Python, C# and even VB)

    ReplyDelete
  2. Some data to support your claims (I'm a Java developer, so I will stand for Java :-)) would add more value to this post.

    ReplyDelete
  3. Alied Perez - Ruby has Watir - the most preferred tool for regression automation. Besides, it also has RSpec , another strong tool for BDD which make the test-driven development more powerful. Ruby supports unit tests, functional tests and integration tests which plays an important role in application development and also while performing regression tests. Hence to some extent Ruby has a better support in terms regression automation testing. For reference - http://www.oreillynet.com/pub/a/ruby/2007/06/07/rails-testing-not-just-for-the-paranoid.html?page=1
    http://rspec.info/
    https://groups.google.com/forum/#!topic/watir-general/_WPkQV2hKPI

    ReplyDelete
  4. 1. this is a religious fight
    2. java is better, faster
    3. java has a nice IDE with autosuggest and documentation on autosuggest
    4. ruby is slow, complex, powerful and in the wrong hands you are screwed

    For ruby you have to be more experienced to write nice code

    ReplyDelete
  5. Java or Ruby -I dont care.............Which would fetch me more money -working as a Ruby Developer or Java Developer ? I want answers in a word and not big stories...

    ReplyDelete
  6. So I will develop in Rails 10 sites while a java developer builds 3. One of 1,000,000 will be as busy as Twitter. Once I find that one I'll switch it to Java. It worked for Twitter after all.

    ReplyDelete
  7. Thank you for your comments. This post is based on our experience and findings after research. We as a company have worked both in Java and Ruby and we are not against any of these technologies. The post here simply throws some light on different aspects of both the languages.

    As a developer you can opt for Java or Ruby depending on your requirements. The argument that Java surely rules it is mentioned here only in the context of Twitter example and other companies adopting Java. If you have any experiences or preferences be if for Java or Ruby, you can definitely share with us which will be helpful for others too.

    ReplyDelete
  8. Java is a language and Rails is a framework. You really ought to be comparing stacks here. It’s been a long time since I wrote a Java web application so my “stack" is probably out-dated but my point of reference is Spring, Hibernate and Tapestry or Struts vs Rails (where Rails includes AR and uses HAML). I’ve also maintained (but not written) Java web apps using JDO (ugh) so depending on your stack of choice, your mileage may/will vary regardless of the language you use.

    With that in mind:

    Learning curve:
    I agree with you; the Java stack (see above) with it’s vast array of frameworks is a steeper learning curve than Rails. As a vendor selling the service of creating web applications I suppose that may well be a barrier to entry. But as a client hiring a vendor to write a web app; I expect that vendor to already be proficient in the language/stack of choice and to be able to suggest the correct language/stack based on my specific requirements.

    Code manageability:
    It sounds like you’re referring to name spacing (packages) in Java and the lack thereof in Ruby. I think that’s a fair argument although the use of modules in Ruby enables a developer to be clearer about which classes they are using, extending, etc... Also, modern IDEs make this a lot easier to deal with. Another point to be made here is that Java is so much more verbose that large systems will have increasingly more lines of code (and possibly more classes) as they get bigger. Ruby’s succinctness means there is just less physical code to deal with. It’s a course grained metric but less code may (or, of course, may not) lead to easier manageability.

    Testability:
    I think this is a question of the developer and not the language/stack. If your developers are prone to write tests they’ll do it; if they’re not they won’t. There are good frameworks available in both languages/stacks for writing robust unit/functional/integration tests that, IMHO, are equally as robust. Bottom line, Java and Ruby are both testable.

    Stability/Scalability:
    To be honest, I haven’t compared systems as big as Twitter in Java and Ruby to know if one is more stable/scalable than the other. Twitter is definitely one example of a company that chose Java over Ruby (for some things) because their perception and experience led them to the conclusion that Java was superior on this front at that time.

    There are certainly many other more recent examples that demonstrate that modern versions of Ruby on Rails are as stable and scalable as any other language. Twitter still uses Rails for parts of their infrastructure and Github is a notable high traffic site that uses Rails and I’m sure there are others.

    Percentage Hiring:
    I wonder if those statistics are skewed by government contracts. The government is more likely to use, what are perceived as, more enterprise languages (I’d call Java a more “enterprise” language/technology than Ruby). But to be honest I don’t know why that is.

    Current Infrastructure:
    You didn’t mention this but it’s worth bringing up: I think this is less of an issue in these days of cloud based computing but if a company (vendor or client) has made a large capital investment in resources so that they can support a Java environment then they’re going to want to write, purchase, support Java applications.

    Final Thoughts:
    I think there are almost limitless arguments as to why a particular language/framework is better than another and some are valid and some are not. I’m curious… What made you compare Java and Rails? Why not C# and Clojure? …or ASP.net and Grails? Surely there are arguments to be made for all of these other languages/frameworks for one reason or another?

    ReplyDelete