If you’ve built a few websites from scratch, chances are you’ve noticed that you have to solve some of the same problems over and over again. Doing so is tiresome and violates one of the core tenants of good programming — Don’t Repeat Yourself (DRY).
Luckily for you other people long ago noticed that web developers face similar problems when building a new site. Sure, there are always edge cases which will vary from site to site, but for the most part there are four general tasks we developers have to handle — Create, Read, Update and Delete, otherwise known as CRUD.
What is a Web Framework?
A web framework is a software framework designed to simplify your web development life. Frameworks exist to save you from having to re-invent the wheel and help alleviate some of the overhead when you’re building a new site. Typically frameworks provide libraries for accessing a database, managing sessions and cookies, creating templates to display your HTML and in general, promote the reuse of code.
It’s important not to confuse a framework with a content management system. While a framework deals with many of the same issues and, in some cases, may make it very easy to build a content management system, a framework is much more general.
In fact a framework isn’t really anything at all. Think of a framework as a collection of tools, rather than a specific thing.
What Can You Do With a Web Framework
Frameworks exist to make building a website faster and easier. Typically frameworks provide tools to cover the common CRUD cases. For instance you’ll likely find libraries for accessing a database, managing sessions and cookies, creating templates to display your HTML pages and more.
Frameworks also promote the reuse of code. With a good framework you only need to design, for instance, a contact form once. Then you can drop your generic contact form code into all your projects and save yourself some time and effort.
Nearly any site you’re going to build will have to interact with a database. Frameworks generally offer some means of doing so without having to delve into writing your own SQL every time you want to create, read, update or delete a record.
Similarly, most frameworks either provide a template system, or make it easy to add on your own templating system so that common chunks of HTML that rarely change, for instance, the header and footer of your page, need only be written once.
How Do You Choose A Framework?
Although having a wide range of framework choices is definitely good, it can also be a source of confusion for inexperienced developers. With all of the possibilities out there, choosing one can be a daunting task the newcomer, so how do you decide?
That’s something of a religious question, but a good place to start is to see if your favorite scripting language has a framework available. The Ruby in Ruby on Rails refers to the fact that Rails is a Ruby framework. So if you’re a Ruby fan, Rails might be the framework for you, but there’s also Nitro and Merb.
Python fans have a few to choose from. Django is fast becoming the Python framework of choice, but there are other options like Pylons and TurboGears. PHP lovers can check out CakePHP, Symfony and Zend. There are also Perl and Java frameworks for those that enjoy Perl or Java.
However, just because there’s a framework available in your favorite programming language doesn’t mean it’s the ideal choice. Each of the frameworks mentioned has its strengths and weaknesses and you’ll have to evaluate each to see which is the best fit for your site’s needs.
Although none of these should be the sole criteria, each of these frameworks are noted for certain things.
Django was developed for a very large newspaper website and offers a fantastic auto-generated site administration section for your site’s users to create, edit and update content. It also includes built-in tools for caching data and building flexible URLs.
CakePHP borrows many conceptual ideas from Ruby on Rails but applies them to PHP. Given the widespread availability of PHP on shared web hosting servers, and the fact that Cake supports PHP4, it might be the most widely usable framework.
There are literally dozens, if not hundreds, of more web frameworks in all sorts of programming languages, but there just isn’t room to cover them all. Perhaps the best way to choose a framework is to simply dive and and try building a site with each one. That way you can see which frameworks fits the best with your style and goals.
- Ruby on Rails (Ruby)
- Django (Python)
- Symfony (PHP)
- CakePHP (PHP)
- Zend (PHP)
- Nitro (Ruby)
- Merb (Ruby)
- Pylons (Python)
- TurboGears (Python)
- Catalyst (Perl)
- Code Igniter (PHP)
- Fusebox (ColdFusion)
- Model Glue(ColdFusion)
- Mach-II (ColdFusion)