June 28, 2009 3:00 PM

My Opinion on Frameworks

A while ago I got in to a heated discussion with a friend about frameworks. He argued extensively about how great frameworks were, how they simplified development, lowered development time and forced good coding. I could not completely disagree with him as these points were to some degree true. Despite the benefits that frameworks provide, I do not like frameworks because the disadvantages far out weight the advantages. Every framework you use requires hour upon hour of reading and research to learn how it work. Frameworks are also notorious for adding extra "bloat" to your software because of unneeded and unused components. Perhaps the most annoying attribute of frameworks is that they takes control away from the programmer and places it squarely into the hands of the framework, personally I like to be in control.

First I would like to distinguish between a library and a framework because they are very similar and often confused with each other. A library is a collection of commonly used functions and classes that are used to solve a particular task. Libraries are used by your code to simplify common tasks. I like libraries and use them everyday and my site uses several home built libraries as well as a few third party libraries. Frameworks are like libraries as in they are a collection of functions and classes. However they differ greatly in how they are used. You do not use a framework in your code, you use your code with a framework. A framework lays out the foundation of your application and then you build on to it, this is a very important distinction. Now back to what I dislike about frameworks.

The first negative thing I have found when trying to use a framework is having to learn how to use it. I have not yet found a framework that is easy to learn, the learning curves are always very steep. I think that the reason for this is, in part, because frameworks do not often have the concept of using a parts of the whole framework, it is all or nothing. This means that in order to build your basic "Hello World" application on a framework you need to have a good understanding of all aspects of the framework. I tried to write a simple "Hello World" web application in CakePHP and I ended up reading 10 pages explaining the structure of a CakePHP application and how to configure my application. I then had to read up on Controllers, Components, Models, etc... until I finally was able to print out "Hello World" but I have no idea what I did and I am sure that what I did was done wrong. In contrast when I was learning Python I started out with a simple "print 'Hello World'" and built on from there getting more and more complex with each new application I wrote. Now I know that because many frameworks are difficult to learn does not mean frameworks in general are bad but it definitely makes it harder to like and use them.

The next point I want to make is more specific to a certain type of framework, that is the "general purpose, do it all framework". These frameworks try to do everything for you including installing the bathroom sink. These types of frameworks often have unused and unneeded components that take up large amounts of resources. I believe this "bloat" is unacceptable; just because we now have computers that can process tens of billions of operations per second and multiple gigabytes of ram available does not mean we should become lazy in writing fast and efficient code. I am aware that many frameworks take measures to ensure that only the required components are loaded but even this checking adds some "bloat". I am also aware that some frameworks, ones aimed to solve a specific problem, do not suffer as much from "bloat" as others and I have less of a problem with these frameworks.

I would definitely spend time learning a framework and might even put up with the resource hogging nature of frameworks if it was not for my next point. The purpose of frameworks is to take the control away from the user and place it into the predefined terms of the framework. This may sound like a great idea as I think we would all like to be able to write a few lines of code and let the framework work on the gory details. However, this is rarely the case, frameworks work great until you run into an edge case where the framework chokes. Then the process starts of trying to find if there is a way to hack the framework to make it work like you want. These hacks often result in using the framework in ways that it were not intended. You may not find this to be a big deal until your framework is updated and the hack you wrote suddenly stops working; that can be a nightmare. Frameworks often provide set rules and methods for how to perform tasks and this is why many state that frameworks encourage good coding practices. This is true but it really comes back to bite you when you try to do something thats outside the framework. To make things worse, once you discover that the framework you are using will not allow you to do the particular task you want you may decide to remove the framework. This is often extremely difficult due to the way that frameworks take over your application making them extremely hard to remove. Once you use a framework there is no going back as a near complete rewrite is often required to strip the framework from your code.

I will admit that I haven't used many of the available frameworks, mostly because of the reasons above. I have tried to use CakePHP and quickly got frustrated, I have looked into Django and was not impressed, I avoid anything with the name Zend in it. (I know the Zend Engine is the heart of PHP but what can I do.) I do use jQuery which some consider a framework but I consider it a library and if frameworks where more like jQuery I would probably have a better opinion of them. So although there is nothing wrong with frameworks in general, they are not for everyone.

Commentary
on July 13, 2009 at 2:29 PM Pradeep said:
Gravatar for Pradeep
Every framework is created with a particular concept in mind, like increasing productivity, faster changes to code things, lifetime of the project.. things like that. Yeah, Frameworks are not meant for every project. It has to be chosen with proper reasons behind it. And developers should work for the best interest of the project and not for easier implementation or control.
Comment posted August 30, 2011 at 10:56 AM:
This Comment is Awaiting Administrator Approval
Comment posted October 15, 2011 at 6:29 PM:
This Comment is Awaiting Administrator Approval
Comment posted October 16, 2011 at 3:29 AM:
This Comment is Awaiting Administrator Approval
Comment posted December 1, 2011 at 3:36 AM:
This Comment is Awaiting Administrator Approval
Comment posted December 1, 2011 at 6:22 AM:
This Comment is Awaiting Administrator Approval
Comment posted December 1, 2011 at 9:23 AM:
This Comment is Awaiting Administrator Approval
Comment posted December 1, 2011 at 4:29 PM:
This Comment is Awaiting Administrator Approval
Comment posted December 13, 2011 at 6:07 PM:
This Comment is Awaiting Administrator Approval
Comment posted December 13, 2011 at 9:10 PM:
This Comment is Awaiting Administrator Approval
Comment posted December 14, 2011 at 2:12 AM:
This Comment is Awaiting Administrator Approval
Comment posted December 14, 2011 at 4:52 AM:
This Comment is Awaiting Administrator Approval
Comment posted December 14, 2011 at 7:08 AM:
This Comment is Awaiting Administrator Approval
Comment posted December 14, 2011 at 11:52 AM:
This Comment is Awaiting Administrator Approval
Comment posted December 16, 2011 at 4:45 PM:
This Comment is Awaiting Administrator Approval
Comment posted December 24, 2011 at 8:43 AM:
This Comment is Awaiting Administrator Approval
Comment posted January 1, 2012 at 6:03 PM:
This Comment is Awaiting Administrator Approval
Comment posted January 1, 2012 at 6:05 PM:
This Comment is Awaiting Administrator Approval
Comment posted January 31, 2012 at 5:23 PM:
This Comment is Awaiting Administrator Approval
Post A Comment

Feel free to leave a comment on this site. Your email is used as a means of identification only and will not be used for any other purpose nor will it be displayed. If you do not provide one your name and website will not be saved.

Please stay on topic and use some common decency. Your first few comments will need to be approved. Eventually you will be marked trusted and your comments will not require approval.

If you wish to post code please use pastebin and post the url. If you do decided to post code it will not be formatted and any html tags will be removed.