How to develop Java webapps in a Ruby on Rails-like way? - java

We've got an app that needs to run in a Java app server. I've got to develop a webapp to go with it. I've started reading about Ruby on Rails, and I really like the approach: MVC, convention over configuration, tons of stuff taken care of for you.
I may be dreaming the impossible dream, but are there any Java webapp development frameworks out there that work in a similar way?
Straight JSP is miserable, because logic and presentation are mixed. Simple template systems, like Velocity and Freemarker don't do the database stuff. I don't know much about Spring.
Everybody here knows Java, and we don't have time before the next release cycle to learn an entirely new language and library, else I'd plunge into RoR in a serious way.

Not impossible at all. It's already been done.
Here are a few Java-equivalents:
Grails http://www.grails.org/
SpringRoo. http://www.springsource.org/roo
Spring MVC. http://www.springsource.org/
All are products of SpringSource. If you're getting serious about Java web development, I highly recommend you check them out.
Grails was actually inspired by Rails, hence the name, so you'll see many similarities in features and paradigms between the two, including MVC, convention-over-configuration, and code generation. So if you're looking to get right into Rails-like development in Java, I highly recommend Grails. I should note that Grails has more features than Rails, some of which I think Rails should adopt. An example is Grails provides a service layer to handle all business logic. You could easily implement a service layer in Rails, but its convenience we all love, and because Grails includes it, it is more convenient. I've hopped between Rails and Grails once upon a time, both great frameworks.
Keep in mind that you can do Rails development with Java as well, via JRuby, which is not a bad option either. You get all the features of the Ruby language (v. 1.8), along with the ability to integrate and use Java libraries within your Ruby code.
SpringRoo is SpringSource's new code generator framework, so you can use it with the Spring framework to aid in agile/rapid application development.
Grails is actually built on-top of the Spring framework and Groovy. Groovy is Java-derivative which looks more like a scripting language and provides all the meta/dynamic programming goodness that you see in languages such as Ruby and Python. However, Groovy allows you to write Java code as well, so there's no need to learn it, not entirely at least.

Have a good look at the the Play Framework. I think that it's the best way to develop Java web applications at the moment. Certainly the quickest. There is no deploy cycle. Save the code and refresh the browser.
It comes with Hibernate and a host of enhanced functionality that streamlines the development process. Totally REST based and stateless.
Add in jQuery and it feels like web heaven.

Related

Using groovy in Java EE Apps?

Did anyone yet use Groovy in Java EE Web Applications? Is it worth digging deeper into this and would I benefit from it using when using Java EE, JSF, Facelets etc?
What I especially looking for would be things like Groovy auto-generates getter/setter, or not having to always use object.getProperty but just writing conduits like object.list.property.prop and so on.
Is it worth it?
You might try Grails, if you're interested in Groovy for web apps. This is basically Groovy atop a Spring MVC/Hibernate/Sitemesh framework.
Development can be quicker, with the more efficient syntax, convention-based setup, scaffolding, and there are a lot of plugins to add functionality. But, maintenance may be challenging in a complex app, and when something goes wrong in all the magic it works to hide implementation from you, it can be painful to debug.

Integrating standard java into web frameworks such as Stripes, Grails JRuby and Rails

For various reasons we have to use a java based web framework to create a proof of concept site. We've a lot of algorithms written in standard java that will have to hook into the site.
So right now I'm considering stripes, grails and jruby and rails. Bearing in mind I know almost nothing about any of these. My core issue is going to be, how easy is it to integrate our various java objects into the web framework.
I'd usually assume this is a straight forward process... but then again it is java and the web!
Anyone have any experience ?
Groovy (Grails) can execute vanilla Java just fine
Stripes is written in vanilla Java so no problem there
jRuby can execute vanilla Java just fine
So basically, any of these frameworks should be able to handle your "algorithms" just fine assuming they aren't dependent on something out of the ordinary.
For Grails it is pretty easy (I'm not sure about the other frameworks).
Grails encourages you to separate your "web" stuff and your "business objects" stuff - have a look at their "Service Layer" http://grails.org/doc/latest/guide/8.%20The%20Service%20Layer.html.

Which framework to choose?

I was thinking which framework would be a good choice to go into. I'm focusing on java apps and tested spring, grails and seam so far. I've also looked aboard java and gave ruby on rails a try too.
In future I will be focusing on portlet development which I've gone through already without a complete framework (just hibernate).
Maybe someone could share some experiences? Or point me to a corner which I don't looked in so far?
Regards and thanks for reading ;)
If you're doing this out of curiosity and to learn something new, rather than to meet specific requirements for a specific project, maybe you'll enjoy the Play! Framework. It contains a lot of stuff from other frameworks and is designed to get you up and going very quickly, with short development cycles and not a lot of arcanae.
Their stated purpose is to be "by Web developers for Web developers". They intend to put the fun back into Web programming.
This sounds good and I've read a few nice things about it in fora and blogs, but I haven't tried it myself yet so that's all the recommendation I can give.
Grails has a plugin for developing portlets, described here.
If you consider Groovy or Grail, you might consider ZK, too. It is an Ajax framework integrated well with Groovy and Grail.
I'd say you go with a framework that targets the programming language you're most proficient in. If you already are good in Java, and you're a quick learner ( to learn Groovy ), Grails could be a good choice.
If you'd like to go with another scripting language, say Ruby/Python, then choose Rails or Django, or Pylons ( the list could go on here ).
If you're going for a Java only framework, I'd go with Spring MVC.
You should have a look at the play framework (SO question).
Finally a Java framework made by Web developers. Discover a clean alternative to bloated enterprise Java stacks. Play focuses on developer productivity and targets RESTful architectures.
I was thinking which framework would be a good choice to go into. I'm focusing on java apps and tested spring, grails and seam so far. I've also looked aboard java and gave ruby on rails a try too.
FYI - Grails is using Spring and Hibernate underneath; SEAM uses JSF and Hibernate.
Grails is the Java equivalent of RoR. It's based on the same idea: "convention over configuration".
It's also important to be clear that Spring is far more than a mere web MVC framework. It's based on DI and AOP and encompasses persistence, remoting, enterprise services, etc. It supports portlet MVC, which is a plus given your requirements.
Personally, I would recommend straight Spring over any of your choices so far if you stick with Java. It's important to know something about what's going on under the covers. If you know Spring well, Grails will be easy.
I'd use Wicket rather than Play! because Play! requires Python as a semi-dependency. With Wicket, you only need Apache and Java and thats it.
I suggest you also check out here:
http://gokhan.ozar.net/best-java-web-frameworks/

Django or RoR like common Java or ASP web-frameworks

I am a fan of big agile software development methodology and love to develop web pages using Django and RoR. However, it creates a big constrain as there are really very few Django or RoR developers to hire.
For a new web project, we will be hiring developers and even though I would love to see these employees using such tools, sadly it will be either impossible to find related developers or even if we find them(virtually impossible for my country), we will be very dependant on them.
Also time is a big constrain thus considering "finding clever programmers and letting them learn these technologies" is not an option.
Under these conditions, I would like to hear common Java or .Net alternatives and why would you suggest them.
I can think of Spring, Hibernate, Stripes, Struts and Wicket for Java
Also Microsoft ASP.NET MVC looks really promising.
EDIT: I Need to mention that I won't be an active developer for this project but act as a manager.
Regards
If you want Java, Spring, and Hibernate with RoR-like "convention over coding", why not try Grails? It's based on Java, Groovy, Spring, and Hibernate. You'll be able to get a lift similar to RoR for web-based CRUD apps.
ASP.NET MVC is quite promising. It "borrows" a lot of its ideas from the Rails framework and community. I am a ASP.NET (MVC)/C# developer primarily, but had the opportunity of doing some Rails development before I moved from traditional ASP.NET WebForms to ASP.NET MVC. After doing development in Rails, I found it quite easy to make the transition to ASP.NET MVC.
Also, I haven't done any web development in Java, but since there are so many web frameworks to choose from, you may not find enough Java developers to build out and ramp up a team quickly enough, all with experience in the same Java web framework.
web4j might be what you're asking for. However, it is not that popular and your developers will have to learn the framework too. I think it will be faster than learning a new language though.
I believe that building a framework in java or .Net that resembles RoR or DJango is very difficult. This because the languages designs are so different. Also because Java and .Net target the enterprise market, which usually requires more robustness.
Agile development really has nothing to do with what languages or tools you're using. Of course, certain tools and methodologies make it easier (MVC tends to make it easier), but my suggestions would be as such:
Go with ASP.NET MVC. It borrows a lot of the good stuff from Rails, and provides some powerful tools that will make developing ASP very friendly to everyone involved.
Use an agile planning tool. I suggest Skinnyboard, as it allows you to do true agile planning.
Don't fret about the tech! Agile is how you manage the project, not the technologies that the project is using.
You're asking how to develop webapps fast with enterprise frameworks vs RoR.
My initial answer is you can't expect to develop webapps in .NET/(Spring/Hiberbnate) as you would for RoR. Lots more setup, lots more to learn and understand at a deeper level. Lots of configuration.
I don't see php here. I assume a lot more people use php. Why not look at php and symfony. Symfony derives its fundamentals from RoR.
If none of the above fit the bill I'd go for Spring/Hibernate/MySQL/Tomcat. We developed multiple largescale web apps with that stack in an agile Scrum/Sprint scenerio
For Java, VRaptor has a controller+view implementation similar to rails actionpack, and uses a DI Container based on Spring. Also has some nice integration with Hibernate/JPA, XML/JSON serialization using XStream, helpers for Integration Tests and a pretty nice documentation.
Haven't tried it myself, but Play! Framework for Java looks very promising. RESTful architecture, MVC and a neat admin interface (like Django) built in.
A platform based on Seam/Hibernate/JBoss sounds exactly like what you're looking for.
Seam is the web framework, Hibernate is the object relational model, and JBoss is the server container.
After coming up with a database schema, you can even use seam-gen to reverse engineer it and do your "scaffolding."
It's flexible, enterprise level, and free to work with.
Furthermore, Java developers are everywhere.

Helping a beginner for java web application

I have pretty big background of .net, and I've decided that i want to port one of my websites to Java. (now with the asp.net MVC craze, I've figured I'd better learn a more mature approach to MVC).
i've downloaded eclipse (easyeclipse distro to be exact, and am ready and willing to develop my first website in java).
i've programmed j2me application before, so i know the language and some of the framework.
can someone guide me? any advice?
Although I'm not very aware of "asp.net mvc" is all about, I would suggest you to take a look at Spring it may be interesting.
Probably is too complicated at the beginning but when you get the concept it turns out very easy to follow.
Spring has 5 core modules ( which I don't remember exactly ) but they were like:
AOP
ORM
MVC
Core
( some other I'm missing here )
The MVC part uses a lot of annotations to make life easier. There's a very big community around Spring.
Here's an introductory article about spring.
Java has a ton of frameworks you can choose from. The technology stack that I use for my Java development is either:
Spring for IoC.
Hibernate for the data layer.
Struts2 for the MVC framework.
I have also swapped out spring and used Guice for the IoC.
Spring also has MVC, but I tend to like Struts2 better.
I'd recommend looking at Grails, it lets you become comfortable with all the java libraries and frameworks like Spring, SpringMVC, Hibernate, SiteMesh, and so on but gives you a much better DSL for web applications and much more concise code with the Groovy language (think of it as Java with dynamic typing, blocks, closures, and so on).
If you'd rather stick to pure Java I'd recommend looking at the Stripes framework and the following book:
http://pragprog.com/titles/fdstr/stripes
If you interested in web applications specifically, I would recommend using MyEclipse http://www.myeclipseide.com. Basically, this is a version of eclipse with all the web server integration and functionality built in. I've been using it for a few years and it's much easier to develop with than with plain vanilla eclipse. Depending on how much your going to use it, you have to decide whether the $55 annual subscription is worth it for you.
I'm a little confused. does spring framework actually a full blown framework? doesn't Java already have a framework? (by framework i mean all those misc libraries).

Categories

Resources