What is Grails. Why should a Spring developer use it?

When I first heard about Grails, I thought Rails finally visit Java. I like Groovy, as it is quite easy for me to pick up and an framework based on it will be fun. That’s what I thought. Does things look good? Will it worth your time to shift? Let’s see.

I never really had a chance to use Grails up until last year, for my pet project. Which I longingly desired to change it from very old Spring version to something new. It was done around 2008, without any annotations.

First thing you easily notice is, when you start with Grails, you get excited. Yes, configuration is none. Which as a Spring developer, I find a good one. Next, scaffolding. I had few CRUD part which I don’t need to do with Grails, which is again good thing, All I have to do is, create domain class, create controller, map them and slap them. Bam! CRUD page is ready! And gsp is sight for sore eyes, if you have only worked with JSP till today(which I heavily doubt apart from people who always stay in maintenance work). As I stopped working in JSP long ago, gsp never impressed me. But still much better than JSP, and it looks much similar to some template engines available for Node.js. And most important thing is, it sure reduced lot of boilerplate code. Even if I don’t use scaffolding, LoC is greatly reduced compared to Spring counterpart. That is something to be considered.

After initial phase of Wow, and Oooh is over, you have to face the fact. I wanted to use JPA as I wanna give it a try and see if it really get along with Grails,. Boy, it wasn’t as easy as I thought it would be. I had to do a lot of hoopla and dropped the idea, as it was taking much more time than I expected. Not worth the time, as it is for my pet project. GORM is decent enough, well, at least for me.

Now, for worst part, speed is awful. I know, but for dev, productivity is important and every time I make changes in Java, it hot-reloads and at same time, system started slowing down. At certain point, it feels like slideshow. So I had to kill few processes to get it back to life.

Plugins : Yes, there are plugins. Lots of plugins!! You want to do X, chances are you already have X plugin. Certain things were made real easy, which makes me cry in joy! But by looking at source/issues you can see, even most popular one’s are discarded by it’s author. Yeah, it is open source and we can do whatever we want, but honestly, that’s not something we want. As much as I love to work in OSS, making it work for our requirement is again an development hurdle in my opinion.

So, what the hell am I thinking? If it matters for you, I pretty much like Grails, and as a Spring developer, it is quite an interesting journey. But do I consider using it in my existing project? I don’t know. It is not worth it. May be if something new and small comes in my way, I might give it a try. Next time, I use it for some real small project and blog here, on how it went?

Python Web Framworks – From Spring Developers POV

I have started learning Python a while ago and so far used it in scripting in server side tasks. It was quite powerful, easy and fast for small tasks. And that’s all I know of Python. Then a year ago, I read few articles about how big names started using Python and that’s when I come to know of Django, Flask etc. I always wanted to use Python for my web applications, but since my company doesn’t allow it, I decided to give it a try.(Everything was tested in my local machine. Not hosted solutions.)

For those who don’t know, all my experiences so far is with Struts/Spring/EJB/CI(PHP)/Grails and trying out something like Python was breath of fresh air for me. I felt like WTF!! I know Python is expressive and all, but with Web, I never expected it to be this easy! I can write and run an web app under a minute!!(Of course, Hello World! What else do you think). So I thought I can use it for my pet project which I did in Spring. The project was mostly CRUD with some recursive functions to calculate some financial and sales data. It took me close to ~30 hrs to finish it with Spring 4+MySQL(Lack of Scaffolding is obvious here).

Main Idea was to try Python Web FW and do it as quick as I can. Tried Django, loved it’s “Batteries Included” approach. Setting up was quite easy, to my surprise. Got CRUD part up and running after lot of fiddling and what-not in under 4 hours.(Main culprit was finding MySQL driver and connecting it with ORM). Then started customizing to add my recursive functions and since logic is already written, all I had to do was re-write it. Code base reduced to less than half, and speed was good too.

So, after 10 hours, I was ready with my application up and running with my existing DB and I re-used HTMLs which was tedious, because I heavily relied on jQuery and now with django, I wanted to use templating for the sake of learning, which took me most of my time. I was pretty happy, that I can able to develop such simple projects in such short amount of time. Added few additional modules in the application for sake of testing features and it was good.

Here is my view on Python Frameworks : Awesome! Why? It’s ease of use, expressive and productivity. From now on, all my freelancing and pet projects will be in Python.Why? Those works are small-medium scale and as only developer, I find managing Python code base to be easy. No tedious configuration, LoC is heavily reduced, no boilerplate coding and all regular python advantages. I never thought pet projects can be so much fun. I am not saying Spring is boring, but to certain level yes.

Does it mean, I hate Spring? No, not at all. Both have it’s own usage and excels at different scenario. If I have a chance to sneak python into my [past] organization, I can use it for all cumbersome Spring modules into Python, and get best out of both worlds. But I know that is a long shot and for now,I try to use them for my pet projects to know more about it.

Grocery CRUD – A Life saver!

I was developing an back-office application for an manufacturing company. It started off as a small project, which is why I didn’t used any framework. But changes after changes, it turned into this huge monster, which has plain-old PHP codes which is not easy to maintain. So we planned to use a framework to reduce the development overhead we have. Picked CodeIgniter due to it’s very less learning curve and it turned out to be good. But what comes next, was not planned. When we started analyzing our old code base, all we had was CRUD!!! 80% CRUD pages, 20% Other functions. I was shocked because I know, it is painful to do CRUD and we have over 40+ tables! All I knew was, I was f’ed.

But still things has to move on, so slowly started migrating from plain old PHP to CodeIgniter, although CI is exceptionally well, doing CRUD in any language is painful. It was repetetive, boring and monotonous. After 2 months of work(and I still didn’t figure out scaffolding because it was a freelancing project), we hardly crossed 30% of project, and we planned to do whole migration in 4 months. It was far cry. I knew that even if I push myself to extreme, I couldn’t finish it. I was browsing myself, thinking if there is an scaffolding tool for CI, it will be great.(I know Yii is an option, but again, that has high learning curve and a new framework. So searching for a plugin is good option)
And then got a lot, but groceryCRUD caught my attention due to its sheer ease of use, and almost no-learning-curve.

After minutes of excitement, decided to give it a try. Started with couple of tables and bam! It was done. What I did in 2 days, G-CRUD did it in few minutes! I decided to go with G-CRUD and whatever 30% of CRUD work I did in 2 months, it did within in a couple of days(Design wasn’t our 1st priority). Yes, for simple Back-Office / Admin application, this is perfect fit. You get power CI on one hand, and scaffolding ability on other hand with G-CRUD. If it wasn’t for G-CRUD,I will still be doing the project with hours and hours of frustration and anger.

I love Grocery CRUD, for it’s simplicity it brings! Ease of use, how it manages relationship between tables and UI, is simply awesome. “Yii” is awesome but it wasn’t easy to setup and start working with, unlike CodeIgniter and going for a new framework is again big PITA. G-CRUD saved my day and I intend to use it for all small-medium BO/Admin projects! G-CRUD make scaffolding nice and easy.

What Grails(Groovy on Rails) did to my PC?

You might have seen Tesla S reaching 0-100 in 3.2 secs, but with Grails under the hood, my PC can go from 0-100 in few milliseconds. Yes, it is that fast! Only difference is, with Tesla S doing that, you will be like WTF!!! This is amazing and with Grails, it will be like WTF!!! This is bullshit.

Yes, my PC has been serving me well for past 5 years and even though it is C2D, 4GB with HD4850 under the hood, it helped me play GTA 4, FC3 and many other modern games and I am pretty happy with it. Felt my PC was laggy once every 3 months, but then again it was my fault as I always overload system with lot of applications loaded. Even with Crysis 3, I never felt my PC is aging. But Grails changed my perspective.

Started my PC, and bootup time is always close to 1 minute as I don’t have any big clog-y startup programs. Then I opened command line and typed >grails create-app sample.System seems like slideshow for a cuple of minute, then fine.

Finish up all work, then type >grails run-app, Bam!! CPU Usage is 100% till it compiles and build the project. I hardly see this happening, and even the resource hungry GTA 4 did good in my PC, but Grails, simply put the PC to shame! I guess it is time to upgrade my PC. Finally want to say one word to Grails Developers, WHY!!!!!!

Why hate Java/C/Python/$language_name

For a long time, It’s been a lazy trend to yell at Java or C or Python or what ever languages. But lately it’s becoming mainstream. Of course comments in those post’s made my day, but deep down I always wonder why people do that. It’s like they compare onion with f’ing banana. They both meant for different purpose. Eating an onion and saying it is not sweet is totally retarded. And same applies when someone compare Language A v B.

We are programmers. We do programs. No matter whatever language it is. If you look at big names technology stack you may understand this. They try to use proper tools for jobs and as long as it is working fine it is all it matters. Instead of sitting at your desk and wimp like kid, and telling some you hate X so you wouldn’t code sounds real bad. And what’s worse than that is, blogging about it. Apart from those funny comments at those posts, those articles never had any purpose in my view.

Why hate X? If you don’t know the true potential of X, where to use and how to use, it’s your mistake.Not X’s. Some idiot did some unoptimized pathetic excuse of code and made a mess out of it and it is not the language’s mistake. Instead of bitching about it, start analyze and fix the problem. Not make fun or yell at X.

After looking at guys who implement plethora of technology in their stack, I started following their footpath and it worked well so far. I love Java, but never hesitated to learn something new. As a result of this, now I know a handful of languages which I use together depends on situation to get the best result.

I can hear you all saying “What the hell he is trying to say? “. Well, all I am saying is, try to learn as many as possible, implement them based on needs and stop complaining about an onion not being like an banana.

How do you choose your language of choice?

As a web developer and  a freelancer/consultant(once), I always had this dilemma. At times I will pick the wrong one, which lead to some horrendous situation. But after few failure attempts, nowadays I grasp the idea to choosing right tools for right work. Still my friends/acquaintances/family ask me which tool to use for their applications. Over the time, I had collected few metrics based on which I will choose the platform.

These metrics are drawn from my freelancing/consulting time and doesn’t reflect in my professional work, as both are different. Since I no longer do any freelancing or consulting, I though it would be nice if I post it, so someone will get benefit out of it. One of the main principle of mine is, always use Open Source. Never buy commercial product. So all my views are based on OS in mind.

Metrics which help me to pick the tools/platform(Languages mentioned are my preference and not necessarily implies that anyone should go by that. It is the metrics that you need to know about) :

1. Cost

Sounds weird, but true. The main thing is, even after the prices of web hosting has come down significantly over the last few years, still we can see some general price difference. In my basic view, PHP hosting is always cheaper(Java, which is my preferred language is closer, but shared JVM is something I tend to avoid for many reason). But this is not the sole reason to pick a language but plays a major role. I can remember a client ask me “Why would I need extra money for the application to work in URL, when it is already working fine in localhost?”. I had to deal with these kind of people and at times, I include web hosting charges along with my billing to avoid such embarrassing explanation session.

2. Size of the Application

It is major factor. For a teeny tiny admin application or readily-available-in-php situation, I always choose PHP. Reason, development time is fast(sometimes zero) and results are more than enough to please client. I will not touch Java for a simple inventory system or something which I can easily find online like e.x.shopping cart, CMS, invoicing etc. At times, even for some medium size application, I choose PHP. With lot of powerful PHP frameworks available today. it make sense for me to go with it, based on simplicity it brings in development and installation. For basic CRUD applications, Yii/grocerycrud(don’t ask me about Spring Roo) made my day. Development time has been greatly reduced and pain of writing CRUD is no more.

But still there are situation where I choose Java. Mostly because, if the development is going to be done my multiple developers, where as maintaining Java I find a lot easier. And the sheer size of code base increases, pain of maintain the code will decrease. With PHP, I find it hard to debug or enhance beyond certain point. Being a freelancer, you tend to do all the work and once an application reach beyond the projected scope, debugging becomes nightmare. To avoid those nightmare situation, I will go with Java. Even if something new need to be added, it is not going to be tough as Java is my bread and butter.

3. Nature of work

If the work is re-writing legacy code, or adding a new functionality the existing applications, then things get interesting. With Node.js becoming buzzword, I started using it for simple utility kind of applications as well as moving legacy applications to new UI etc. Keep back end untouched(if performance is good), and improve the GUI and front-end speed. With this approach, billable hours are greatly reduced and response time has been good. Only downside is, getting a decent/good Node.js resource is real tough. For a simple utility applications, not much of an hassle. But bringing back legacy applications to new life, need some serious work and this is when finding a resource becomes real tricky. It is very tricky, at some point, I dropped the projects or idea of using Node.js. Adding new functionality to existing one is little tricky too, so I care to choose projects based on what language it is written. There is no way I am going to learn a completely new alien programming language which I know I never will use, for the sake of the just one project. I have done many such projects in Python, PHP, Struts, VB.Net etc. For me to learn, either it should be worthy or it should be fun to learn. Else, I am happy to skip the project.

4. Deadline

If deadline is going to be too tight to choose my preferred language, I will go with PHP blindly, reason being, support and ease of development. But again, if deadline is too tight and nature of works requires me to go for Java, I will simply refuse, as I will never want to give sub-par work, as it is against my own moral. But most of the time, I either negotiate for time or split the release into phases, so additional features can go after live.


These are all some of basic metrics which I follow in choosing language for projects. And I hope these metrics will be helpful for someone out there, who is facing the same dilemma what I faced years ago. Just keep some priority and standard for the kind of work and don’t go below that. I would like to be called good developer who did less project than mediocre developer who did a lot of projects. For this, these 4 metrics along with lot other factors helps me in finding right tool for right job.

Does Spring looses its charm?

Back in 2009, when my employer wanted to start a project in Struts, I suggested them to go with Spring, even though no one in my team knows it, even me. I always love to work with latest and hottest framework, for it’s support and added features it bring over existing frameworks and ease of setup.(And spring was a buzzword back then) No hurdle from management side, so we took it as a challenge, started doing POC and after facing a lot of errors(I hate BeanCreationException and likes), we(along with one of my colleague) succeeded and finished prototype just the day of the deadline. It was a special moment for me. I was not expert in Struts(in fact all I did at that point was some POC, no real time, project experience), but still I bit the bullet and I succeeded in my challenge, which was pretty tough for just 2 years experienced java developer, who never worked in a framework before.

My journey with Spring started then. I have been working in Spring from then, learned a lot and now starting a project in Spring is like back of my hand. But then meanwhile, a lot has been changed in the other end of spectrum too. Play was not what it used to be. It has changed a lot and Play 1.1 was a mighty leap from what I saw before (No idea about Play2.0 as I don’t feel it is for Java). New trend has been spotted, JS-MVC, Node.js etc. Over the past 2 years, I had to work with new technologies and after getting to know them better, I kinda say Spring lost it’s charm. Why?

Main reason why I chose Spring : It was Lightwight. But not any more! Sadly, Spring spread it’s wings, but a little too much in my opinion. Almost everything is a plugin, and that is what annoys me. I mean, I appreciate Spring ORM, but Spring Social, MongoDB, but why? We already have tons of libraries to do that, which already integrates well with Spring. In that case, why the need to re-invent the wheel? Everytime I want to integrate new plugin, I simply read their documentation and start implementing it. But now, I look at Spring to see if they are already have plugin for that! Then I ignore it and go with my original way. In fact couple of times, I tried Spring Social and I feel it is not leveraging the libraries to it’s true potential. I know most of them are not yet in v1 or some are, but still it is not what I expected out of Spring and what we need.

Stop spoon feed everything(for developers) and innovate something which once kept you as market leader(I guess this is right word).I read JEE6 has improved a lot and the gap it had with Spring, is becoming thin. If it not for Glassfish or my laziness, I would have already gone with JEE6. Slowly, I switched my interest towards these V8 engine boys and Play framework. Create a REST backend, Use Node.js+AngularJS, finish up things. It was pain at first, but after a couple of time, things looking easier this way. And with Play! framework, RAD is possible and much better than Spring Roo in my opinion.

Unless Spring comes up with new innovative features or better Spring Roo implementation, I guess I will start using something else, and it eventually means less Spring more competitor.

Note : The views expressed are purely by me and if you find have conflict with facts and information, please feel free to point out. I will correct it. All opinions are mine and doesn’t mean Spring is bad, but it doesn’t interest me any more like it does before.