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.

UPDATE (Mar 2016): As much as I loved Python, I didn’t get a chance to use it. After initial excitement fade off, doing thing in Python was little tough. Be it writing proper code, configuring it in server etc, where all becoming nightmare for me. After a lot of thinking, I decided to drop it, because it ain’t worth the time.

Reason,

1. I am not doing any mission critical freelancing projects which need such powerful framework

2. I don’t have enough time to get it up and running whatever environment I work!

3. Things get little ugly, because you know, it seems that I don’t like dynamic typing after the initial excitement. It mainly because of my years of experience in Java!

These things were pretty hard, but after getting into Nodejs and host the app within few days, got me thinking. So I said adios to Python and Aloha to Nodejs. Nodejs, here I come! Wait, not really.

Grocery CRUD – A Life saver!

I was developing a 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 at that time, 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 a perfect fit. You get the power of CI on one hand, and scaffolding ability on other hand with G-CRUD(Well, not exactly Scaffolding, but you know!). 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.

And for all people out there who are looking for simple PHP CRUD Gen, there is nothing much simpler than this, at least that I know of!

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.

Conclusion?

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.

Are we[Indians] really good at coding/programming?

After going through a lot of rants and hatred towards Indian programmers in /reddit, blogs etc, I was feeling sad. It hurts but that is true and we have to accept the fact. Even though I am not such a bad coder(now), but as an Indian, I feel like I have some obligation to explain the root cause. And by the way I am not going to justify the sub-par performance at any point of time, but simply give you the reason for that.

1. Crowd & Core Incompetency

Considering the fact almost every year we have close to million engineering graduates(who never wanted to do engineering) coming out of so-called-engineering colleges(which hardly teaches anything useful to practical approach of industries), who are looking for a job. If they stay at home and pursue their dream, they will be labelled as incompetent and abused by their own parents and relatives. So their top most priority once out of college is to get a JOB. So they are in real pressure to get A job. In the process of getting a job in their core competency(which I heavily doubt any one does as of now), they lose patience and lose respect. Out of 10, 2-3 get into their core(let’s call them bright guys or lucky!) and rest of ’em are lost in the crowd. Worst case, as we are dependent on our parents, we even get out pocket money from them while searching for THE job, which again is big PITA.

Everyday I see a lot of youngsters running behind hiring agencies(one of my friend owns a hiring agency and most of his client advise him not to send engineering graduates, rather they are okay with diploma guys) to push them into IT space for meager(or no) salary(seriously, I see freshers work their ass off in small companies for nothing, not even stipend), which in my opinion is pathetic. And then there is some weird category who get job in IT,so they can raise their dowry bar. I have personally seen a guy who earns USD 6.5k(~4L INR) per annually as fresher, got USD 162,000(1 crore INR) as dowry(Google the word dowry if you are not Indian)!!!!! or close to that. This is the state of education in India and expecting a solid coder(leaving person who loves coding) out of this system is like expecting suzuki alto to run like ferrari. It runs, but not how you expect it to.

2. Let’s make some easy money

This is the mindset of youths, who is fresh out of college. If you are an engineering/arts/whatever degree guy who is jobless, you can easily(not that easy) get into IT, no matter whatever stream you are from(ECE,Mech, hell that). As a kid, I always dream about becoming a developer, and I had the privilege of having computer at my home, when it was considered as luxury. To pursue my dream career, I chose B.Tech IT, dreaming that I can become a developer with this. But soon I realize not only IT & CS guys, but anyone can join IT. I heard parents talk to their kids like “Take Mechanical/ECE/EEE etc. Even if you don’t get a job in your field, you can always go to IT”. It never was kid’s decision(unlike me). My parents gave me liberty to choose my own course, school, clothes and that is what made me responsible, realize what I want and be where I am and what I am now.

Decisions are made for you, by your parents. Be it education, marriage, even career and kids *sigh*. Now realize what a kid will have after 4 years of education? Nothing. They expect someone to tell them what he need to do. Out of 10, 6 are like this. After their parents hand out their kid’s career decision, he will start pursuing it. As you guess, if you throw a rock in Bangalore, chances are that it will hit a IT guy. It is true. So obviously the kid will end up in IT. If you take big four names(I don’t want to spill the beans but you know who), they have training programme for freshers(A friend of mine who attended this training told me this”It was like we again ended up in college, only thing exams are limited”).Trained by below-par trainers(or in most case, no training at all) and suddenly pushed into the projects, all they can do is repetitive, monotonous, crappy code, (or even worse, sitting in bench for head counts) which is well approved by their leads and managers to finish up the project. This leads them to the illusion, that they are following software principles whatever been taught by the trainer. So according to them, they are always rights, ’cause trainer said so. Because even in training they taught them how to write code, not how to write GOOD code(BTW I never went to such big outsourcing companies so never had a chance to be a part of their training programme).

Some may even claim that their training was best, world class and eye opener for them. After all, I wasn’t surprised to hear this when a guy who scored 80+ in his degree. ‘Cause all he did in university was mug up and he follows the same trend in big companies, which he admire and embrace. Being in the industry from 2007, I can relate my experience with this. When I was a fresher, I already knew Java/J2EE. But my colleagues who were also fresher have no idea what to do and how to do. I was a bad coder, I was forced to realized that by some good guys online and I picked it up one the way. But other guys not even bothered about that. Worst, their tolerance level if I tell them straight to their face that their code sucks, they start scolding me!!!

3. Ugly Hierarchy

Next bad thing, is HIERARCHY. Since as kid I never had issue with saying NO. And I never afraid of my superiors. But it is not applicable to all. Respect is one thing, but afraid-of is another thing. Managers(80% of them), always think they own developers and they can do whatever they want with them. Apart from a few like me, most of them don’t have courage to stand up because,

1. They are not confident about them self and their skills

2. Afraid that if they go out, they will not get a good job with decent pay

With this 2 worry in their mind, developers vows to never say NO and managers will take it for granted and eat them up. If you say NO, either your life will be made living hell or you will be forced to quit(Both happened). Now the rest of them, will just work & work and churn out 1000s of lines of rubbish code,just to finish whatever task they have been assigned to. On their way to finish the task, they forgot about code quality, indenting(what? seriously? you guys have time to indent code?) and everything else you need to follow for clean, optimized code.

I have personally reviewed codes and the mere idea of doing so always scared me to death. Sometimes I yell at them but mostly I get frustrated and see what I can do to improve it(read re-write). Yeah, we are friends and shit, but when it comes to code, I never compromise with quality and expecting the same from other guys in my team was not good idea. So, I end up cleaning up the mess, to make my life less miserable. There was time when I wish I would have done the whole project by myself, so escape from these kinda issues. But it won’t happen in an organization and I am left with no option other than live with it or get out of it. This is the reason decent/good coders always jump organizations to find their comfort zone.

4. Stubbornness

This is what in my view, is the biggest issue with indian developers. They never try to learn or update themselves. In their view, it is waste of time or not fruitful(Exact word by one of my ex-colleague). Once they become 3 years experienced they want to become Lead and when they become 5-6, they want to be manager. Believe my I have seen a lot of such jokers promoted as Managers and I quit after that. All incompetent developers, who never wanted to learn/update themselves will become managers. The main reason they want to climb the ladder is, so that they don’t have to CODE.

One of my past organisation had total of 5 managers for a team of 25 developers. I mean, WTF!!!! But this is the reality. I have this habit of reading magazines, blogs, forums so that I can stay updated of newest and hottest technology, implement them and do some POC for understanding, whenever I am free. If one of the MANAGER see this, his reply will be “Why waste your time learning this. We are not using this. You can do something useful na?”(Man, I hate this slang). This is their general mindset. If a person sit idle for more than 15 minutes, they will create new task and assign it to him. And my colleagues(90%), even if they are sitting idle for 2 hours, they never try to learn something. Rather, they prefer to chat/FB/WhatsApp or go out for break!! With people of this kind of mentality, it is not fair to expect quality work out of them. Most of my time wasted in cleaning up the mess(50% only) they made but you can’t stop them from doing. Believe me I tried and the success rate was 25%(only a handful of guys picked up, rest simply ignored me!).

Final thoughts :

Finally one myth I want to explain, attrition rate. There is a common “All we[read Indians] want is money and we will jump anywhere to get big money”. This is not 100% true. Let me tell you, the people who love their job, will choose the best/product based companies(which nurture them, help them) and settle there. Best case, they may move to U.S. The people who are stuck with organization for long are, either incompetent guys, or relative of CxO or higher authorities or may be a skilled person living in their comfort zone and find no need to jump!

As many blogs portray, good guys will jump companies not only for money, but also for culture. Once they find their nest, they will not leave. So if you really want to setup offshore development center in India, all you can do, is either handpick guys(i know, it is a big pain but worth it You can easily pay 30-35k for a good coder with 7-8 years experience, which is still economical in my opinion) and setup offshore center else go for some best offshore consulting firms. although finding one is tough and a gamble.

– – –

I can point a lot more reasons, but I am not going to. With this 4 basic things, one can have fair idea why Indian developers(80%) are not able to produce good quality codes. Of all these years, I have worked in a couple of product development companies which are awesome, filled with brilliant minds and their code quality is nowhere near your everyday indian coder. But finding one such organization is a challenge, because the ratio is 10:1. It is the culture, family[pressure], new-born-lifestyle, glamour, poverty and frustration, which pushed him towards IT, and he is in knee deep shit before he realized he is not cut out to be developer. But that is too late, and he is stuck with IT forever.

[Note : For those who are going to post offensive comments, please stop. I am an Indian, so I am not doing this to make anyone look bad. IT becomes our bread and butter. If we want to retain clients, then this is how we do that. We need to accept the fact and improve ourselves, if we want outsourcing to flourish. Else, god only knows, what will happen if we all(service based/outsourcing companies employees) go jobless. Just see what happened with TCS. With no solid reason, they kicked out thousands of experienced(and some are good ones as I heard) developers and what is the guarantee that it will not happen to you or me. Be bold, face it, let’s improve the quality of work and I am sure, IT will boom rather than going downhill.]