Frameworks and libraries

There we go, my first post on development. Frameworks – I will not explain what a framework is, I think you already know it, instead, I will write my opinion on how and when to use them.

Frameworks are great tool for us, developers, to overcome some obstacles, when we quite do not know the solution or we are too lazy to write it ourselves. On the web world we have a lot of environments to work in – there is a server side environment (e.g. PHP or some other popular web site scripting language + Apache or some other HTTP server software + some sort of SQL RDBMS), then there is a client side environment (JavaScript, HTML, CSS and also ActionScript in Flash), and in any of those there are some problems to overcome.

At first let’s look at server side and PHP. PHP is a great language for it’s main purpose – it has already almost all the tools/functions buil-in to do almost any thing you could imagine doing on the background of page processing. There are plenty of PHP frameworks available as free and open-source solutions, for example Kohana, Code Igniter, the behemoth of them – the Zend Framework and of course since the dawn of PHP there’s been PEAR. And I do NOT use ANY of them. Why? Because thease small everyday obstacles in PHP are easy to overcome and you can reuse your code snippets later on in other scenarios. Instead of using these frameworks I write my own, for every specific needs in my project, and I treat these open-source frameworks as as code snippet repositories or ideological cook books. There is one problem with them damn frameworks – they tend to grow, and get really inter-dependent (as in inter-related, with no easy way to remove unnecessary components). I see threat in this problem, because it might and does affect overall performance.

Next up we have JavaScript. This is where “The Nightmares on Web-Street” start. Unlike PHP, there is no one-and-only interpreter for this language, and since the rise of internet each browser vendor has brought his own non-standard solutions into the world of client-side web scripting, we – web developers, were doomed. Thank god a few years back some crazy guys (and probably girls) around started doing some crazy stuff of writing famous frameworks like Prototype, jQuery, YUI, etc. By that time I tried to convince my clients that DHTML (as it used to be called) was no way to go, but thankfully I fell in love with jQuery. I really can’t imagine writing all those long addEventListener lines or long document.getElementById and child traversing, or struggle with window.onload for long pages. In my opinion jQuery is like Ruby On Rails, in just few lines of beautiful and readable code you can do really amazing stuff.

In other areas of web development, I haven’t encountered that much of a frameworking. For example CSS lovers have plotted out some good ideas on how the frameworking idea could look in their realm, but for me it basically ends with this kind of code, that is just called browser-reset:

* {
  margin: 0,
  padding: 0
}

img {
  border: 0 none;
}

One of kinda off-topic frameworks I’ve been working with is .NET and it’s own master piece of language C#. That is a perfect example of how framework can save a lot of hours of painful writing, testing and debugging. But I will not go into details on that one.

So, summing it all up. I do not use frameworks in PHP, I rather write my own – small and single-purpose only. That does not mean I always do it from the blank. I just take the previous one and do some refactoring and additional coding. A JavaScript framework is a must-have, if you do not wish to shoot yourself in the foot next time you try to do some magic AJAX event wizardry across, let’s say IE6 and Chrome 7.x

Leave a comment

Your email address will not be published.