return to I Love My Journal
A Little Closer to Center...
Musings about Life, Linux, and Latter-day Saints.
Pages
About Me
Links


Tags
PERSONAL 520
SPIRITUAL 416
LDS 312
BOOK OF MORMON 237
SCRIPTURES 154
STUDIO-JOURNEY 129
RELIGION 112
LINUX 79
COMPUTERS 65
LIFE 60
GENERAL CONFERENCE 46
GENTOO 39
MISCELLANEOUS 37
MUSIC 37
PROGRAMMING 33
CARS 29
MICROSOFT 23
FAMILY 23
AUDIO 21
I LOVE MY JOURNAL 18
FUN 15
CHILDREN 12
CURRENT EVENTS 10
NATURE'S WAY 10
VIDEO 9
DRM 9
CONEXM 7
BABBLINGS 7
PROVO CITY CENTER TEMPLE 6
FRIENDS 6
HEROD THE FINK 5
GAMES 5
COMPUTER HARDWARE 5
DRUMS 4
HAND OF GOD 3
ADVERSITY 3
KDENLIVE 3
AUDIO HARDWARE 3
GENERAL INSANITY 3
STUDIO 3
THANKS4GIVING 2
CATS 2
MY JOURNAL 1
POETRY 1
FOREVERGREEN 1
EVERYDAY THOUGHTS 1
GOSPEL 1
PARENTING 1
YOUTH CONFERENCE 1
CHURCH NOTES 1
POLITICS 1


RSS Feed

RSS FeedSubscribe!
Wed - Mar 11, 2009 : 12:22 pm
sick
   rated 0 times
>>next>>
<<previous<<
Frameworks
I'm gonna step out on this one because this topic has been a hot one in my head for quite some time now.  Not only with AJAX, but frameworks in general.

To Framework, or Not To Framework...  That is the question...

When I began programming, there were no frameworks for PHP, JavaScript, or AJAX (not sure if AJAX even existed back then).  I programmed from scratch by hand, and have done so ever since.  Anyway, I've been thinking about whether I should spend the time learning and eventually actually using a framework.  I'm not entirely sure what I'm going to do, and the debate has been going on in my head now for months.  Hopefully this entry will spark some comments, and bring some light to the debate to use a framework or not.

Anyway... here is my experience:

  • I've created my own templating system which works just fine, and enables me to create applications very quickly - it's not robust at all when compared to the likes of codeigniter or cakePHP, but for my purposes, it works wonderfully, scales well, and can be used in highly complex apps.
  • I worked on a project with a guy who was a framework junkie.  He implemented multiple JS libraries (moo-tools, dojo, and most likely a few others) and I'm sure he used a PHP framework to code, and although his application was developed extremely quick, when actually loaded in the browser, it ran as fast as mud flowing uphill.  Seriously, it had so much eye-candy, it took forever to actually do anything with his app.  I was not impressed.
  • Although I haven't done any work personally with any framework, I've read quite a bit about them, and consider myself at least a bit informed about them.

Now here are some questions I have:

  1. I know that frameworks simultaneously make coding faster, yet make executing code slower.  I know this depends *highly* upon implementation and skill of the programmer, yet I can't get it out of my head that while implementing a canned framework, I'm importing thousands of lines of executable code which I'll never use.  Should I be worried about that?  Are the benefits of using a framework worth it?
  2. At the first programming job I ever had, I decided to code by hand (it was only HTML and a little JS), while my two colleagues decided to go the WYSIWYG route.  While they were marginally faster than me at whipping out websites, I found that when their sites had bugs, they had no idea how to fix them, and would come to me.  Because I had been coding by hand, and thus being able to figure out the bugs, I could squash their bugs much quicker than they could.  Will frameworks create the same dependance upon a higher-level coding, thus disabling me from learning more about the core language?  (Kind of a stupid question, I know, but broadened - I believe might still be relevant to users who have never coded PHP outside of a framework)
  3. As I understand it, to some level, frameworks standardize the codebase and make it easier for more developers to jump on board without having to learn the nuances of an eclectic developer.  I'm worried that, should I decide to use a framework for a project, and find its capabilities lacking, or am unable to make the framework function for a part of the project, I would go around it, thus fudging the code somehow, and making more of a mess than had I not used the framework to begin with.  Do frameworks provide all the funcionality needed to self-contain the code?  Are they programatically restrictive?

I guess that's it for now.  Hopefully this will spur some constructive debate and enlighten people like me who can definitely see the advantages to using a PHP framework, or a JS library, but can also see the negative side as well.
Comment by Aaron Mavrinac on Mar. 12, 2009 @ 11:08 am
1. You've left out a key advantage crucial to this question. Yes, you will be importing a lot of general-purpose code that may slow execution. However, this performance loss is balanced by the performance gain you get from using code that is likely much more optimized than your own. The authors of the framework specialize in authoring the framework, so in the vast majority of cases, it is unlikely that a solitary developer's code will outperform the framework's unless there is a very substantial advantage to tailoring to a specific application. Plus, when the framework gets faster, all your apps that run on it get faster simultaneously.

2. I don't think the analogy works. A more appropriate one might be to compare writing C to writing assembler. A framework will save you a vast amount of time, but also ensure a lot of the low-level stuff gets done right, and make your code more modular and portable. Grinding away for hours on tedious low-level coding doesn't teach you anything except an appreciation for things like frameworks.

3. Though the developers of frameworks can never know every potential application, they generally err on the side of giving you more flexibility. They want to save you from tedious and repetitive work, not tie your hands. Cherry-picking and bypassing bits of the framework is common, and does not need to be done with messy and un-portable hacks. I know of at least a couple of frameworks that provide lots of documentation about how to subclass and override stuff should you find it necessary (and people often do).
Comment by Xavier on Mar. 12, 2009 @ 11:42 am
You're basically asking the questions that matter while learning about development frameworks, and I'll try to answer them as best as I can.


- Your first question regarding the performance trade-offs between execution time and development time actually has very little merit, as there are many patterns available out there for writing components that only execute the code you require out of it, while maximizing available resources. At a high level, I'm talking about modular design, and direct request dispatching and mapping logic that make request handling just as fast as if you were directly running your code without the use of a framework at all. Most of the frameworks i've worked with implemented a very fast dispatch system, and your typical method call and content generation will probably be completed in about 10ms, while the browser will take about 10 times longer to render that content, so server-side framework performance penalty is negligible at best.


Performance optimization is an important part of web development, so it's important that you learn about it regardless of whether you decide to use a framework or not. Obviously the error your friend has made was in implementing multiple JS libraries and likely many CSS files. Every JS file, CSS file, or image referenced by CSS used in your page, need to be loaded before displaying any page. A typical HTTP request takes a while to go back and forth through the network, so 99% of the "slow" applications you see out there are slow because of the large number of requests they make. The 'Yslow' plugin for firefox's "Firebug" extension will help you through the process of eliminating those problems in your own apps.



- Your concerns regarding bugs, or having to sometimes work around the framework are valid and legitimate. Most frameworks have bugs, and I'm sure your own application template is not exempt from that rule. It's important to do your homework when it comes to picking the right framework, and to learn how to work around the bugs of the framework without circumventing the framework all-together. This is done pretty easily in my experience. The mantra of high-level architectural software design "High Cohesion, Loose Coupling". This design minimizes the risk for bugs to become show-stoppers. My advice is to look at Zend Framework (PHP) or Django (Python) for reasonable implementations of that concept.


You can read more about high cohesion and loose coupling here:


http://en.wikipedia.org/wiki/Cohesion_(computer_science)
http://en.wikipedia.org/wiki/Loose_coupling


- I'm pretty sure my previous point addresses your last point properly. Once again, it's all about trying to pick a well-designed framework and learn how to use it as it was designed to be used. This may feel limiting and restricting for the first couple of projects but it really isn't. Instead of seeing a framework as a jail, see it as a set of very well designed components that have gone through dozens of rounds of optimizations, all glued together by an elegant and clean and flexible workflow.



My point of view is that the most flexible solution is to use a very loosely-coupled framework like Django or Zend on the server-side, and another loosely coupled UI framework like Dojo on the front-end. This gives you the optimal degree of versatility while still providing you with very well designed components that you can implement in any way you see fit.