Sunday 29 November 2015

Frameworks in Perspective

Frameworks are increasingly becoming the in-thing. From scripting languages (CodeIgniter and Symfony for PHP, Django and Pyramid for Python, etc) to front-end (AngularJS) and now even CSS (Bootstrap), frameworks are here to stay and are fast becoming mainstream, if not already firmly a part of it. Increasingly, firms are now looking for developers who not only know their way around scripting languages, but also frameworks.

What's not to love about frameworks? They take care of the nitty-gritty stuff, speed up development considerably and have great support worldwide. Knowing a framework or two adds glamor to your resume.

But here's the rub: I don't love frameworks.

Sure, I acknowledge that they are getting increasingly popular, for legitimate reasons. I acknowledge their place in the industry. I may even have used a few myself. But, call me old-fashioned, I tend to like getting things done without frameworks. Don't get me wrong, frameworks are great for business. With reduced development times and nifty things like code reuse, projects get completed faster. Deadlines get met and vendors get paid (hopefully!) sooner.

Yes, I'm going to say it again - frameworks are great for business. But I'm not a businessman. I'm a geek.

Here are some reasons why I would prefer to do without frameworks. I call them the three "Overs".

Overuse

This is web development, and there are no blanket solutions. The solution you choose should depend on the context. But some developers forget that. They think they've found this great one-size-fits-all framework and insist on using it for everything.

"I suppose it is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail." - Abraham Maslov

I once worked with a developer who used CodeIgniter for every damn thing - including Contact Us forms! And - get this - a guy who wanted to go ASP.NET MVC for a static website. That's another "Over" right there - overkill.

And seriously, if what you need is a no-frills web application that doesn't have to look pretty or be used on mobile, why would you even bother trying to use Twitter Bootstrap for it? This is insane!

It's like using a hammer to break an egg.


Uh-oh

jQuery, for example, boasts that it will drastically cut the number of lines of JavaScript code you write. Let's assume that I load the jQuery file and now instead of 20 lines per function, I write only 5 lines. If I have 50 functions in there, I would have saved (15x50) 1250 lines of code. But what if I only had 5 functions? I would still have to load the entire jQuery library. Doesn't it, then, stand to reason that I'm only getting enough bang for my buck if I use jQuery for far, far bigger things?

Now replace "jQuery" with the name of any framework out there and you'll why I facepalm at this silliness.

Overhype

As mentioned earlier, frameworks benefit the businesses by speeding up the development process. Consequently, business owners set great store by developers who can develop using frameworks. This can lead to developers thinking they're hot shit simply because they can code using a framework.

And that is sometimes implausibly stretching the truth.

You see, it is entirely possible to learn the framework without learning the foundation behind it. Knowing one does not mean knowing the other. You can learn Django without learning Python the same way one can learn jQuery without learning JavaScript. And some developers do precisely that. They start using the framework as a crutch for all the gaps in their knowledge, and that's where the problem begins.

Don't know about sanitizing input? No worries, the framework takes care of that. Don't know how to prevent SQL Injection? Framework takes care of that too. Don't know about responsive design? No problem, we use a framework!

Excuse me for a minute there, I feel the sudden urge to puke.

Gag. *hurk*
Knowing how to code in a framework is a good thing. But only if your foundation is rock solid. Otherwise, you are merely a tool user masquerading as a developer.

The framework and its source technology are not interchangeable. If you're going to use a framework, for the love of God, please make sure you're not helpless without it. Frameworks are meant to make your life easier. It's a lot like riding a jet ski without knowing how to swim. The slowest jet ski moves a lot faster than the average swimmer, but if the engine ever stalls out at sea, buddy, you are screwed.

Overhead

The overhead. Oh Christ, the overhead. They say that frameworks help you code less - by introducing a lot of predefined code, 10% of which your project may actually use. That's a gross exaggeration, but it's true that not everything in a framework will be of use in the application it's used for.

Getting a little crowded in here, guys.
But really, that's not the issue here. I can live with some wastage. Until it takes on ridiculous proportions.

I've had to use plugins before, while working on Joomla! and WordPress projects. Each plugin invariably installed its own version of jQuery or MooTools. That led to many copies of jQuery at any given time. Seriously, how is this a good thing? Again, call me old-fashioned... but the part of me whose roots came from C++ and having to manage memory, positively recoils in horror.

Or, if you want a serious miscarriage of justice, look at ASP.NET 3.0. You write the code in C# or VB.NET, and the server compiles the code to generate the pages. View the source of the generated pages, and you'll see chunks of server-generated JavaScript, both to preserve state and to simulate the action of the various ASP.NET Web Objects you probably dragged and dropped into the page. Yes, even a humble label is a Web Object!

Framing the Issue

So there you go. Do I hate frameworks? Not really. They have their place. Frameworks are not really to blame here. They're a tool like any other... and sometimes a blooming annoyance. The real issue is with the people who use them. Think about it: Is it the fault of a framework if an overenthusiastic developer decides to use it for every damn thing? Is the framework to blame if developers use it to cover up their own inadequacies? OK fine, overhead is a framework's problem, but is it really fair to blame frameworks for the other problems I've listed?

Technology's fine. It's people who suck.

Over and out.
T___T

No comments:

Post a Comment