views:

1485

answers:

10

If I have no to little experience in either of them, but know enough Java and Ruby to be comfortable, is one framework harder to learn than the other? Is one easier to use for the beginner on these?

I know it is hard to answer. Just looking for general thoughts on it.

A: 

The thing about Spring is that it is mainly two things:

  1. It is essentially an "adapter" or "facade" for existing technologies and libraries; and
  2. It is philosophically different from say J2EE in that it is all about dependency injection or inversion of control, which is a fundamentally different approach than what came previously.

For (1) for example, Spring can do things like help ease the pain of what JMS provider you use or do things like translate exceptions generated by different databases into Spring runtime DataAccessExceptions.

Spring is typically labelled a lightweight container for this reason. In the Spring world ("application context"), vendor differences typically become just an issue of configuration. Dependency injection does a lot of things like making testing much easier (done right).

The biggest challenge in learning and using Spring is learning to think that way if you haven't previously done anything like it.

Other than that, there's really not a lot to Spring and that's a good thing. Spring doesn't get in your way. You choose whatever technologies you want to use and Spring nearly always just makes using them and integrating them easier.

Once you get into the DI/IoC way of thinking.

cletus
+1  A: 

Spring is quite big, it has two facets that I know of the dependency injection and AOP. Ruby on rails is very much geared up towards writing web apps.

If you are looking to write a web app I would expect you would find ROR easier to use as it is much closer to the problem domain.

If you wanted to use spring to write a web app you would most likely need to learn a few more technologies as well which may get a bit overwhelming. However if you are just learning for fun, combining spring with the head first patterns book can be fun.

Jeremy French
+4  A: 

Both Spring and Ruby on Rails share the "convention over configuration" moto. This reduces code lines significantly. Ruby on Rails is a Web Framework and it could be compared with Spring MVC, together with an ORM tool like Hibernate.

One could say that Spring together with Spring MVC or another MVC framework and Hibernate are the closest that you can get to Ruby on Rails for the Java world.

However, Spring has a much wider scope than RoR.

kgiannakakis
Which aspects of Spring do you consider to utilise Convention over Configuration? For the version of Spring that I'm somewhat familiar with, you have to write reams of XML configuration. Later versions let you use annotations instead, but it's still configuration of at least some things that could probably be inferred.
John Topley
In Spring 2.x+ spring introduced CoC in MVC, see http://static.springsource.org/spring/docs/2.0.x/reference/mvc.html#mvc-coc. Also using annotations dramatically reduces the XML configuration necessary for all other Spring aspects.
Rich Kroll
configuration via annotations is still configuration
Matt Briggs
I agree with John Topley...heard that annotations were good, but the majority of stuff I've seen out there still uses XML config and shitloads of it
scottschulthess
+1  A: 

I suspect this question is really about Spring MVC. One of the hallmarks of Ruby on Rails is "convention over configuration". If you use the right names, you spare yourself a lot of work writing configuration files. With Spring, you're probably going to need to go ahead and type in a lot of that configuration.

Also Rails routing is much more powerful and concise than the alternatives in Spring. In recent releases, Spring has tried to move to more of a convention over configuration model, but it will still seem burdensome to a Rails developer.

Rafe
+6  A: 

After working with Rails, Spring (and just about any other Java coding) feels tedious and time consuming.

Eric the Red
ditto for .net and its various frameworks
Matt Briggs
+2  A: 

Comparing RoR to Spring directly is not a direct or easy comparison.

RoR focuses rather tightly on developing websites easily. RoR does a great job of making crafting pages, linking them together, and persisting data very easy. RoR was designed explicitly with web development in mind, and is a great tool for this. That said, when you need to do more "enterprise" development (messaging, integration, etc.), or have a need to do something that does not fit into the RoR conventions, you will feel some pain.

That said, Spring has many facets: Spring IoC, Spring AOP, SpringMVC, etc. that is aimed at solving a myriad of different development issues faced by developers. Spring has a very wide assortment of technologies that will ease most development challenges you will face.

To directly answer your question, it directly depends on your requirements. If you are developing simply database backed web applications, RoR will allow you to quickly and easily develop an application and is easier for the beginner to get started with. Spring on the other hand has a steeper learning curve and more configuration necessary, but gives you much more flexibility and power.

Once facet that I think is often missing from this type of discussion is the power of the community, tooling, and libraries available. Java/Spring is a mature platform with extensive community and tooling support, while Ruby/RoR has a great community, the tooling is still catching up IMO.

Rich Kroll
+9  A: 

I don't like this comparison.

You should compare Grails or Spring Roo to Rails. Groovy Grails is a RoR like system built on Spring that uses Groovy for rails-like DSLs. Roo is a vaguely railish pure java DSL for RoR like apps.

I really hate to say it this way but Spring is a platform. You use it to wire Java technologies together. You can use it for non-web, non-database, zero UI apps. You can use it to write batch servers. You can use it to write clients.

Rails isn't the same. I really like rails for data driven web apps but I shudder at the thought of writing a batch processing system in rails.

sal
Agreed.
miek
A: 

I just found this while looking at the idea of use Spring or Rail, very interesting overview blog comes in three parts. Two are their already and the third is next week which will be the comparison.

http://www.vyre.com/company/blog/blog-detail/item23960/Spring-&-Rails-Frameworks--MVC-application-support-comparison--Part-1/

strivel
A: 

I've worked with both somewhat extensively, and I found Spring and the most popular "add-ons" hibernate, JSF, JSP, Rich Faces, etc extremely hard to use.

Mostly it was because of a personal dissatisfaction with the documentation and the available books and tutorials on the full stack.

scottschulthess
A: 

I have recently moved to using Spring MVC + WebFlow from 4 years on ruby on rails.

Ruby is great rails is the productivity egde. However, spring MVC is geared more towards the enterprise with layers of design and patterns over patterns.

I don't say it is rubbish it's interesting to learn a different approach towards UI development.

You can not compare the two. Spring MVC is more tailored towards designs that can be reused in Portlet development or development of webflows that can be altered without changing a lot of java code.

There are subframeworks like spring security and not to mention Aspects in all shapes and kinds I find all this a big learning curve. The views can be rendered with JSF or JSP/JSTL.

Honestly, I think java is a language that has not evolved in ages and people have had substantial investments in this stack they have hacked and overwritten ways around code. Annotations and XML or be it Generics they are all with an aim to make the language cater to ever increasing and evolving world around it.

Contrasting that to a modern dynamic language like ruby there is a lot of productivity difference. Ruby is dead simple programmer friendly and superior in every way.

Rails is a very opinionated piece of software dictated by what DHH and the rest think and want in it.

Yes, its great for web app development in fact you will feel you have acquired the missing thing when you start programming rails.

The trouble is rails has received a lot of negative publicity over the years. I am not sure about it's future at this time and choosing between something proven vs something that is getting cloned in every new web framework is a risk.

ASP.net mvc, grails cakePHP every popular MVC framework out there has cloned rails.

Is spring hard compared to rails?

I think if you apply your mind both are equal in terms of the learning curve.

Jet Abe