Frameworks: Do they speed things up or slow things down?

As I noted in the last blog post, the bulk of the latest update to the Jimmy Cuadra Web Services site was rewriting everything using the CakePHP framework. At several times during the process of learning Cake and building a website using it, I considered dropping it altogether and just going back to coding everything from scratch.

I was determined to stick it out, however, and now that the update is finished, I'm glad I did. I can certainly see both the benefits and pitfalls of working with a web development framework. Before I begin discussing these points, I'll offer a basic description of a framework – what it is and what it does.

A web framework is a collection of code intended to simplify and strengthen repetitive tasks that developers are often faced with. It is similar to a library, in that it is a group of classes and functions written by someone else to speed up your development. The difference is that a framework works almost like an application itself, almost like a programming language within a programming language. Frameworks are also usually designed to be extremely extensible, so that more functionality can be added to the core framework easily at any time.

Frameworks can be created for use with any programming language and by many different types of people or organizations. Popular web frameworks these days include Ruby on Rails for the Ruby language, Django for the Python language, jQuery for JavaScript, and of course CakePHP for PHP. Frameworks may be built by a community of developers and offered for free as open source or sold by companies as a commercial product.

From my experience so far working with Cake and from what I've read about others, I've come to the following thoughts: Using a web framework can be either a benefit or a burden for developing a website and which of those it is depends on several factors. Here are some things to consider:

  • Complexity: How complex is your project? If all you need is a few static pages with content that is not often updated, using a framework is probably overkill. However, if your project is going to require any sort of complex dynamic functions such as user accounts, blogs, or forums, using a framework can provide a variety of benefits.
  • Learning curve: Oftentimes learning a new framework will be like learning a new language. You'll need to familiarize yourself with new classes, functions, syntax, and concepts in order to be able to use a framework comfortably and effectively. How difficult this is for you may depend on your own experience with the language you're using, your experience with programming concepts in general, or how intuitively the framework has been designed. As such, the first few times you use a framework, it may significantly slow your development process, but as you gain better understanding you will likely be saving a great deal of time on each project compared to how long it would have taken without.
  • Code quality: One of the great benefits of working in any sort of collaboration is that the quality of the code created will be stronger, more efficient, and more secure, simply because it benefits from the collective knowledge of everyone working on the project. While this effect certainly applies to commercial software, it is most evident in open source software, where the framework can be updated and refined by a potentially huge number of developers from all over the world. Using such code as the foundation for your own projects will make them that much more powerful.
  • Documentation and community: The strength of the framework's documentation and user community can also greatly affect your experience with a particular framework. In my work with CakePHP, although the documentation solved the majority of my questions, it left a lot to be desired, and things that the documentation should cover forced me to resort to asking for help via forums and their official IRC channel. Fortunately, the Cake community, although not incredibly large, was very helpful to me and helped me understand things about Cake that the manual didn't adequately explain. Depending on your experience with programming and frameworks in general, not being able to find the answers to the problems that leave you stumped may be a dealbreaker. This could be an advantage for commercial software, where you may be given guaranteed support and won't have to rely on the chance of randomly finding help on the web.
  • Fun: This may not be the case for everyone, but I found that building a site using CakePHP was much more fun than writing everything from scratch, even in the times when I was stumped on something and took a long time to figure it out. Using a framework allows you to deal less with the low-level workings of the code and concentrate more on the concepts and design of your application – the creative process that many developers find to be the fun part of programming.

The overall conclusion I've derived from all this is that a lot of choosing a framework or not (or choosing not to use a framework at all) is largely a matter of what works best for the particular developer and the particular project. The unfortunate thing is that it's not easy to know before jumping in exactly how you'll take to a particular framework. By the time you've spent enough time with a framework to decide you don't like it, you may still be disinclined to stop using it simply because of the amount of time you've spent learning it. As such, the time schedule of your project is also an important factor. Do you have time to burn learning a new framework that may save your life or completely waste your time?

For me, although there were certainly headaches involved, using CakePHP is a choice I don't regret, as I found the process to be fun, and the better I get to know it, the faster I can build new applications, and the more I can help the community that has been helping me. Learning a framework, even you don't use it forever, is also a great exercise for your mind as a programmer, and a good point to list on a resume that could easily set you apart from a crowd.