Comparing ASP.NET MVC and Grails for a new project - java

Greetings, everyone. I consider myself to be an intermediate developer, but, to be candid, probably closer to novice than expert. In any case, I have more experience with C# and the .NET platform, but my current job has me working almost exclusively with Java. This in itself is sort of a problem, but I'm dealing with it fine and I'm not really in a position to change my role at the moment.
On the side, I am starting to work on a highly interactive, database-driven web project. I'm doing it because I feel that it's a great idea and I know that the experience of doing something like this from scratch will help me immensely.
I initially wanted to go with ASP.NET MVC and I am still leaning that direction. I'm not even sure why, but I love the community behind it and, in my opinion, Visual Studio is the best IDE around. However, doing that would be counter-productive to my current job. That brought me to Grails. Even though I realize that Groovy is not Java, it seems to be similar enough (not to mention that it runs on the JVM) that the skills I learn should still help me at my current job. The more I looked into Grails, the more I loved it, especially after having to deal with what I consider to be an extremely complex J2EE environment at work.
But with the good I found the bad. I can't help but notice that there are a lot of developers who are irritated with the amount of bugs in Grails. Being that I am starting a new project and I am fairly inexperienced, do I even want to consider Grails? Is it a liability? And what's the consensus about its longevity? I would really hate to get too involved if there is a good chance of it fading into obscurity within the next few years. And even if the bugs and longevity issues aren't a huge deal, how would you compare the ease of development of Grails with that of ASP.NET MVC? I realize this last part is highly subjective. But for the sake of comparison, let's say that someone with virtually no technical background were in the same position. Would you recommend they take a look at ASP.NET MVC or Grails?
Thanks so much. If anything needs clarified or reworded, please let me know. I sincerely hope I'm not opening a can of worms...

I am the author of this question and I can give you some shares on my own experience.
As it is stated in the question, I had no real preferences and I was opened to any technology/platform that could fulfill my requirements. After many tries of different technologies (at leats few days with PHP, Rails, ASP and Grails) and some answers from StackOverflow, I ended up with the same dilemma as yours : Grails or ASP.NET MVC ?
And I chose Grails. Why? Because of GORM. Almost only because of GORM. This is fantastic to deal only with your domain classes and have your DB schema automatically generated/updated. Of course, it has its limits but this is so powerful for querying and maintening your DB. You do not write SQL anymore and it is very easy to learn.
Now here is my 2-cents comparison of the 2 technologies:
GRAILS STRENGTHS
GORM (see above)
Complete Web Stack Framework : you can generate a website in minutes and everything is already configured
A lot to learn : You have Spring MVC, Hibernate, Sitemesh, Java, JEE, Groovy...Once you have mastered Grails you can add an additional page into your resume
Java world. Whatever you need, if it already exist in Java, you can use it.
Groovy : I really like this programming language. It takes time to get familiar but once done, you will love it.
GRAILS WEAKNESSES
Memory usage. Grails/groovy is greedy for memory and it might cost more than ASP for Web Hosting
Grails bugs : there are some and when you start a new project on a new technology, you assume that most of the problems come from you...until you find out (after 1 or 2 days) that it is a Grails bug. So my advice is to proceed by steps : test as soon as possible and don't try to twist the framework. It is rough on the edge so go after what is generally recommended. However, after 2 months, I do not encounter big problems anymore.
Debugging : due to the multiple layers of frameworks, errors are generally hidden inside tons of exception lines. Also, the only decent IDE debugger is IntelliJ but this is not as easy to debug as .NET under VS
ASP.NET MVC STRENGTHS
The community : it's HUGE ! First it is supported by Microsoft and secondly 30% of the websites out there are built in ASP.NET. You can find any snippets of code, any widgets, any AJAX components, any CMS...Grails community is very active but can you rival against millions ?
Visual Studio : I definitely agree with you : there is no better IDE. IntelliJ is very good for Grails but having using both, I prefered VS
ASP.NET MVC WEAKNESSES
The youthness of ASP.NET : this is a young framework. Built on a stable technology but young enough (less than 2 years) to have also some bugs/some bad practices. Indeed, the next version of ASP.NET MVC is strongly awaited by the community.
Microsoft : even if ASP.NET MVC is open-source, you are totally dependent on their decisions (and prices).
The Bottom Line
If you project has tight deadline and if it is crucial for you to succeed, then go for ASP (according to your background). Otherwise, give a try to Grails..don't worry, you will also succeed but it will take more time. I am also deeply convinced that Grails has just started its long journey and it has a great future (see google trends)
Update by Dmitriy: If your refer to Google Trends you have to compare the 2 of them Groovy Grails and ASP.NET MVC.
Good luck

This is something that's been pretty much asked before here...
http://74.125.155.132/search?q=cache:BpGj8RtSUIsJ:stackoverflow.com/questions/1283935/what-technology-asp-php-joomla-rails-grails-for-a-website-from-scratch+Which+technology+to+choose+%28ASP.net+or+Grails%29&cd=1&hl=en&ct=clnk&gl=us&client=firefox-a
Good Luck though!

Related

Java MVC framework closest to Asp.net mvc3?

this will probably get downvoted etc for being ambiguous, but I am strapped for time and was hoping that someone with much more experience can hop in here and give me a nod in the right direction.
I have been developing several mid-size business apps with a few developers in ASP.NET MVC(3). Me and the team need to produce a java EE web app. I'd like to keep things as consistent as possible -- I have used CakePHP in the past and noticed it was pretty much a breeze to jump into after the ASP.NET MVC Stuff.
What is the best/most similar MVC framework for Java? Alot of the guys just spent the last few months learning all the new MVC3/Razor stuff after coming from more "Classic ASP" or C/C++ design stuff. I really want to keep things as consistent as possible to avoid extra confusion.
Thanks!
Edit: Also I guess I should ask with your recommendation, if one particular IDE has much better integration than the other, I am curious about this!
You may consider JSF/Seam framework (or) Spring MVC. AFAIK, JSF/Seam resembles most like .NET MVC3.
Just an alternative viewpoint to consider: There are many more important factors to consider when choosing a framework beyond "is it similar to x, which I already know." Think about what tools are best for solving the problem at hand and less about what is best/easiest for you. In the long run, if you're going to work with Java on the enterprise, you're going to probably have to learn several other frameworks and move between them anyways. You could really shoot your project in the foot if you choose JSF just because it is "like .NET."
And just so I sort of answer the question: There isn't really a Java framework that approximates what Microsoft did with .NET MVC. The whole "thing after ASP.NET" reminds me a lot of PHP and Spring before annotations based configuration. Then again, I got away from .NET in 2009, so I should probably shut up now.

Is it worth changing from java/spring/hibernate to rails for a program that is undergoing massive changes?

I have a project whose core domain is dramatically changing. It's possible to use 50% of the core functionality from this site and just add the 50% new functionality, but I am starting to consider that maybe it might be faster to simply redo the product in Rails. Development speed is very important.
There are some things I really like about java - the performance and scalability are very good. I am not a crappy Java developer, so my apps tend to run very well - better than the Rails sites I've seen. I've always accepted the idea that people probably just throw a little more money at the problem when it comes to using Rails, which probably works itself out in the end because of the insane productivity benefits.
I am actually quite agile with Java. I know it will still take me longer to add a basic entity to the system, but I am quick at it and I don't mind it that much. At least it's easy and straight-forward to do.
What I do mind is:
having to start/stop the server just to fix a route, lazy load exception, controller is going to wrong view, etc.
putting up with the fact that unit/integration tests sometimes have different results than the production environment (because annotations on controllers can't be tested, or lazy-loading exceptions occur during asynchronous service calls, or things like that). Knowing if your Jackson is marshaling your data properly is another Tomcat-only thing because it's handled by Spring. There are lots of things that go wrong after you have tested all that you can, and this frankly annoys the crap out of me.
putting up with the occasional maven/classloader problem that doesn't rear its ugly head until you deploy into tomcat. It gives the false impression that everything is "a-okay" when you are in your IDE.
having to put more effort to do database migrations than the ruby people ever have to.
putting up with framework bugs in Spring that block (it's happened about 5 times on this project since 2009) or Hibernate. I also don't like upgrading Spring Security and having them constantly change the configuration, apis and tag libraries over and over again. This is annoying.
wasting so much time uploading 58 MB war files to the server! These take me 12 minutes to upload whenever I need to deploy changes. If I forgot to do 'mvn clean' before I upload, Spring might complain that 2 beans exist with the same name because I moved one to a new package... and then I have to re-upload the whole stupid war file again. Why isn't "clean" run by default whenever you do 'mvn package' for?!?! Sometimes these frameworks and tools use the stupidest default settings. This is just so common in the Java world.
Having to spend hour(s) to figure out where a framework wants to plug-in your own custom implementation for something. This is very annoying. You can spend 2 hours sifting through Google and crappy documentation trying to figure out how to override Spring Security's authentication mechanism for example... and then spend only 5 minutes writing the actual implementation. Of course, they wrote paragraphs upon paragraphs explaining the architecture and how awesome it is, but nobody cares. For something so common, why not just give example source code and be done with it?
Waiting 10-15 seconds for Spring to start up whenever you want to run your integration tests. This is a drag.
There are a few things I like about Java though. Role-based access is very easy to do with Spring Security. Authentication is never that big of a gain, but I like the implementation inside of Spring.
I also like Spring's form-backing objects and #ModelAttribute. These are huge wins when it comes to controllers, and I don't know if Rails can do these things. I honestly never liked passing request parameters around in every action - Spring MVC is actually a lot easier to use when it comes to this common bloat.
Being able to cache really massive structures in memory and have them stay in memory when you start the application is also highly desirable, especially for this application actually. I have an in-memory thesaurus and grammar checker that needs to get called hundreds of times per request, so in memory is pretty much the fastest option for me.
Even still, I think I could rebuild what I have in 2-3 weeks, and then add all of the new features in a few weeks using rails.
On the bright side, all of the really well-designed css, html and javascript could be ported over with very little problems.
I'd appreciate some advice on the subject before I continue.
PS: I could also go to Spring-ROO... but that would also be a considerable rework. I was never using JPA - I was using Hibernate directly. I am also not using JSP's - I am using Freemarker.
It takes more time to get good at Ruby, and Rails. I worked as an independent contractor as Spring and Hibernate expert myself, but I felt strangled by java and it's web frameworks so I decided to learn Ruby on Rails.
I would advice you to learn Ruby, from what I read you would probably master it, although get pretty frustrated with the very different way the use the ORM. I had issues with it, used to working on aggregate roots in Hibernate to the ActiveRecord one class one table kind of pattern. But hey, you could easily try out MongoDB to have some real fun.
Ruby is
less code
it's fast and scalable (slower than java on the specific tasks, but you get rid of stacks of layers.)
the problems are more often; which gem should I use. Luxorious!
a unique, big, sharing and caring open source community
nice frameworks, as Rails and Sinatra
powerful.
fun!
Would I advice you to do the project you describe in Ruby.
NO.
Not if speed of development matters. You will be slower, trust me. There's a lot to learn, it's conventions are not familiar to a java programmer and when you get stuck, lots of hours fly by.
The best option would be to hire a senior ruby developer to pair up with you and teach you. Be a good apprentice and you'll learn fast. Faster than me, I had to learn most by myself, which is really inefficient.
Good luck!
Check out Playframework. Its fun to develop, and you can use your Java experience to develop features way quicker (given than you have 2 weeks) than any other Java-based frameworks out there.
You do not have to start/stop a server. You fix the code in Eclipse and hit refresh on the browser. No dealing with WAR files till you have to actually deploy in production. Do everything from within Eclipse. Easily perform TDD process if thats what you want as you develop code. From an architecture standpoint, it is a fully stateless, RESTful framework from the get-go. Fully JPA compliant (even for NoSQL like Mongo), so you will not have to write complex JDBC code. On the front-end, it has a full featured templating engine, using Groovy as a templating language.
I can go on and on, but I'd recommend going through the site and take a look.
You should take a look at Grails.
You can continue to leverage a lot of your Java code but use a scripting language (Groovy) and many of the paradigms of Rails. E.g. lots of time saved by using convention rather than configuration.
Grails is used by some pretty big web sites E.g. BSkyB the UK satellite broadcaster.
It doesn't really help with some of the startup speed aspects. If you really prize development speed that much - get a faster machine or buy an SSD and fit in your machine. If you work for a big company - sell it to your manager as the cheaper option (E.g. buy a $2000 machine rather than spend 3 weeks rewriting something to save 10 minutes a day).
Java will scale better in the long run than Rails. The Hotspot technology in the JVM is one of the wonders of modern technology.
Also worth checking out is Tapestry5. It allows you to make code changes on the fly (no server restart required) and is easily the fastest & leanest framework to develop with in Java I've used.
I would still give Spring Roo a shot, it will the same rework as with Ruby on Rails or Grails or even less, but you will still stay with something that you are familiar with, which is often the biggest consideration
It has the scaffolding concepts of Ruby on Rails and Grails, but it gives you zero lock in code, just simple, well written (massive use of AOP is matter of taste though) of Spring + Hibernate / JPA (I think you can use Freemarker for the views, Roo has a miriad of plugins, but I'm not 100% sure)

Getting back up to speed in Java development

Using Getting back up to speed on Java after 8-10 years as a starting point...
Along with updating myself with the core JDK6 features, would knowing the different components of JBoss be enough of a refresher?
Though I have about six+ years of Java development experience, it's been about five years since I've done professional Java coding.
I used to do a fair bit of work with WebLogic, but as noted earlier it's been five years...
The best "refresher" I've always found when working with a technology I haven't used in a while is to actually try to do some sort of project with it. Reading is great, but actually building something useful is even better.
I'd start by doing the following:
Download a recent version of JBoss from here.
Study the documentation, found here, chapter 12 has a lot of good info for actual application development.
Try building a simple web application using servlets, JSP's and session beans.
As far as whether "knowing the different components of JBoss be enough of a refresher to make you marketable", that depends on who's hiring. If they are looking for someone who already knows these technologies well and can hit the ground running, then probably not. But if you can find a company that judges you based on your attitude/aptitude and willingness to learn, then you may have a shot.
It's always better to have experience, but if someone is driven to learn then they'll almost always overtake the experienced person who does nothing to keep learning and keep their skills sharp. The hard part is finding a company that hires on that basis, because sadly, it's often not the case.
Good luck!

Best approach to creating a database driven Java website?

I'm fairly new to programming and new to java, but I'd like to jump in the deep end with a little database driven website project. I've read quite a lot about requirements in the 'real world' requesting experience with Spring and Hibernate, so I have those installed on netbeans and a project created (if I hit run I get the default spring page). Now I just need a little guidance as to where to start designing my app (please tell me if I'm getting in a bit too over my head for a beginner!).
Should I start off with my classes? - create all my classes as they map to my database tables and decide which attributes and methods each will require?
Can anyone suggest any good books for maybe.. making a java based website from scratch (i.e. from design right through to deployment) that might be useful for a beginner?
Any help appreciated thanks.
Edit: since posting this I've found a brilliant book that fits my needs just right to get started. Firstly I tried both spring in action and hibernate in action - but found both to be a bit too heavy for my novice mind. Instead I got the Java EE 5 Development with Netbeans 6 book https://www.packtpub.com/java-ee5-development-with-netbeans-6/book and its been a great help. If you use netbeans and are in a similar position to me, I'd say pick it up!
Too over your head? Depends on what you hope to accomplish. Are you trying to create a revenue-generating site to which users will be asked to trust credit card numbers and other sensitive information? Then yeah, you're getting way ahead of yourself. Is this a tool for personal use or a toy you're throwing together primarily as a learning experience? Then I say "Pffffft!" to the notion of over-the-head-ness. Go for it.
As to where to start, I say start with whatever portion of this beast is clearest to you. Have a solid idea of what the database is going to look like? Then start with it and its supporting classes. Have a clear vision of what the guts of the code are supposed to do? Start there. Etc. And if all things are equal, I'd say start at the bottom with the database layer and work your way up -- but that's just me.
And as for the books, can't help you there, but I'm sure somebody can.
I suggest to take a look at web application frameworks such as Spring's Roo or Grails. Sadly I have no experience with Roo. But I do have some experience with Grails.
With Grails you will be working mostly with Groovy, a language similar to Python, but still using the JVM. You'll still have the option to use Java anywhere you like (I think). Grails (and maybe Roo too?) manages Spring and Hibernate for you.
As for books on Grails, I recommend "Grails in Action". I have read a little of "Grails 1.1 Web Application Development" and it also seems to be a good reference. BTW, netbeans supports Grails too.
Not trying to gut your goals, but if you are wondering whether to start with your classes, I would suggest you work on your programming skills more.
I'd suggest taking a look at Larman's "Applying UML & Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development (3rd Edition)" as well as a book on relational database theory (you need to know how to model databases properly.)
You can try your hand at building a database driven web app, and it might give you an insight into how to do it, but you need have some programming maturity to take those skills into the non-trivial.
This is a completely personal opinion so please take it with a grain of salt: Before someone tackles the building of a data-driven application with the purpose of eventually being able to use it in non-trivial projects, that person needs to have a good exposure to programming (by good I mean a LOT, say 1-2 introductory courses, 1-2 intermediate and at least one junior-level course, perhaps a total of 15-30 credits.) Unless that person is a natural programming virtuoso, I don't see it happening otherwise.
I would suggest, if you are serious about programming, to spend a substantial amount on learning the fundamentals before tackling something like this.
Good luck.

Switch to Java from PHP/Ajax in 45 days (or so)

Because of the nature of new project we are about to start, I need to get into Java world rather quickly.
I have about 8 years of PHP experience, and about 3 year in Javascript.
(CI, Kohana and my own MVC framework)
I have solid knowledge of OOP (as much as you can get from PHP/JS and little ActionScript & python here and there)
So instead of learning from scratch, i was thinking to grab some web framework (at the end, project will be web based) and learn java along the way. Java code it self don't seam too strange, and i have solid experience with MVC in php so the whole concept makes sense to me.
So I'm looking a list of instructions on how should I learn Java.
(and not to spend too much time on things that are not so important)
Also you can suggest framework, from what i seen, struts looks nice, spring too, but it seam that it have too much XML configuration...
Start with a good book. I always found Thinking in Java pretty good, besides there is a free online version available. Skip the things you already know. Well you probably know what an object is and so on...
Next thing learn to use a good IDE. Have a look at Netbeans, IntelliJ IDEA or Eclipse. Java without a proper IDE is useless.
If you transit from PhP you are probably going to develop some Web applications? This is a steep learning curve. JavaEE is big, complex and it takes a while to dig into all those frameworks. Propably you end up saying "Why is this so complicated, I can do it much easier in PhP". You will be right about that.
Can't give you a good recommendation about the frameworks that are suited best for you. We use Seam + Richfaces. Not that hard.
If you're switching from PHP, and looking at Web frameworks, then I'm assuming that you intend to continue Web development in Java. In that case I would spend a little bit of time on the Java Tutorials, then get into a book on Web programming in Java, like Head First Servlets and JSP. I think it will be a lot more focused on what you need than more general books on the Java language.
(source: oreilly.com)
I also find that once you learn the basics of servlets, JSP, and JSTL, it becomes much easier to understand any of the different Java-based Web frameworks.
None of them required extensive XML configuration anymore, those were the old days.
I will suggest you to grab Java concepts, anyway. Grab a good Java book to learn it along the way, as you said. Thinking in Java is good to go, but its just about core java and concepts. For java web you might want to look into Servlet and JSP basic, which you can learn using official J2EE Tutorial from Sun.
For Java web framework, there are plenty. But I would suggest you something you are already familiar with. You are right MVC based Java framework. Struts and Spring both are MVC frameworks and give you are clear separation of layers. Spring is a giant in itself, it has the answer for almost everything, that might confuse you in the start. Struts 1 is already outdated, and Struts 2 has a very tough competition.
I would suggest you to look into Wicket. It just a web framework, unlike Spring, and a very well written and easy to grasp.
Its a tough task, I must say. Lets see what other has to recommend.
Good point, nooomi. I would suggest Netbeans, its much more intuitive, and sleek.
IntelliJ is amazing, but commercial and not free.
Eclipse is not my type, lot of other folks are quite happy with that. You might find it good too.
So I'm looking a list of instructions
on how should I learn Java. (and not
to spend too much time on things that
are not so important)
I liked Head First Java, but I know some find the format offputting, and experienced programmers probably find it a bit simplistic, the SJCP Study Guide by same author (Kathy Sierra) goes more in-depth while keeping playful tone. There is of course the Java Tutorial online where you can get a quick overview of the main parts of the platform. Effective Java is a good "best practices" book once you have gotten the hang of the basics.
Also you can suggest framework, from
what i seen, struts looks nice, spring
too, but it seam that it have too much
XML configuration...
Another vote from me for Wicket as web framework. For persistence/db part, I recommend you look into iBatis before trying Hibernate. This is a "sql query" oriented framework rather than object-relational mapping, so it will probably feel more familiar to you. I haven't used it yet myself, but from what I have heard it probably has fewer "gotchas" (with regards to caching, performance etc) than Hibernate too.

Categories