15 Jul
What’s In Chris’ Brain, July 2008 Edition
The summer is always the worst for me in terms of blogging. That’s when I have to run my team in the IBL, play slo-pitch (or softball for my American readers) at least once a week, do side-jobs to help pay the bills, and spend time with the family. Phew. So, that leaves little time for the types of activities that lead to good blogging. But never fear, I will continue to dispense what wisdom I can from here. So, here’s some of the things I’ve been thinking about.
Closures and lambdas coming to PHP
Via twitter I found out that PHP 5.3 is going to have lambdas and closures. I suggest you google around for a better explanation of what they are, but they are an incredibly powerful tool. If you do any Ruby on Rails work, you end up using them. If you use jQuery, you end up using them. I had a conversation in twitter with Mr. Git Book about this, where he accused me of being a “closure hater”. Believe me, I’m not a hater of that particular programming construct. I simple expressed my feelings that given how horribly some PHP programmers abused OOP concepts, I imagine the same things happening with lambdas and closures. Please prove me wrong.
Where The Hell Are The Easy Layout Editing Tools For Non-Designers?!?
I have a side job where I am taking an existing app and converting if over to CakePHP, but preserving the look and feel. What this poor designer-challenged programmer needs is a tool that will take that existing HTML and let me edit it in a fairly intuitive way so I can fix the so-many-damn-tables-I-want-to-bleach-my-eyes layout that exists. Can nobody help me with this? Sheesh. I don’t want to burn up my billable hours fucking around with layouts.
The Framework Jihad
I need a “Framework Jihad” t-shirt. Size 2XLT, please.
Yes, the arguments about frameworks will just not go away. Which one is best?!? Why should you even use a framework?!?! And the more it goes on, the more ambivalent I feel about it. I cannot think of the last time I wrote a PHP script that was NOT part of a framework. Hell, even my Python programming has been 75% Django and 25% straight Python, but that’s only to do things like loading up databases with info from a CSV file. But here’s what I think: the Framework Jihad is winning.
If you substitute “modularized code with standardized API” for “framework”, would that make people feel better? I use frameworks because so much of the infrastructure code is stuff I DO NOT WANT TO WRITE ANY MORE. After 10 years of doing this, it’s time I stopped reinventing things. My old motto of “just build it, damnit!” requires a structure around your application to let you quickly build something. To me, that means a framework that has taken care of database access and application flow and templating.
The number one complaint about frameworks appears to be that they are slow and have all sorts of overhead. Fair enough, but I tell you what: I’ll worry about scaling when I, you know, have something to worry about. If I get to the point where I have to worry about scaling, then I have done very well indeed. Despite our desires, not everyone can create a Flickr or Twitter. They are the lucky ones. The rest of us should shut up and just build something.
It’s just too easy to dismiss the Framework Jihad as irrelevant. Like many things in life, dismiss it at your own peril.
Article Tags >> Chris' Brain || frameworks || layouts || PHP
Posted by Matthew Weier O'Phinney on 15.07.08 at 1:44 pm
“I’ll worry about scaling when I, you know, have something to worry about. If I get to the point where I have to worry about scaling, then I have done very well indeed. Despite our desires, not everyone can create a Flickr or Twitter. They are the lucky ones. The rest of us should shut up and just build something.”
Hear, hear!
I’m largely ignoring complaints about performance and benchmarks, because most of those complaining and running the benchmarks aren’t building anything that actually _needs_ to scale. And if you’re a competent developer, you probably already know a few easy tricks that you can put in place immediately to help (can you say op-code cache plus database and/or content caching?) — and can strip out and refactor as needed to really rein those cycles in. In the meantime, it should be about getting something coded and out the door — and a framework is going to help you do that faster.
Nice post, Chris.
Posted by nate on 15.07.08 at 1:44 pm
Yeah man, looks like the lambdas/closures patch just barely snuck in there. Here’s the deal on that: yes, many PHP developers horribly abuse OO concepts, and the same is likely to happen to this, but I think what it’ll take is some framework or library that forces you to interact with it in a certain way, using these features. Hopefully that’ll be instructive enough to keep people on the straight and narrow.
Posted by leo on 15.07.08 at 1:44 pm
“I use frameworks because so much of the infrastructure code is stuff I DO NOT WANT TO WRITE ANY MORE. After 10 years of doing this, it’s time I stopped reinventing things.”
I’m with you 100%. I’ve spent my life believing that I should do things the ‘pure’ way, building from the ground up - okay to copy and paste earlier code, so long as I had written it in the first place. Now I’m just too old and tired. If I can build a website with, for example, CakePHP in two weeks that would normally take 3 months, I see that as a result. If you give a shit about purity, don’t look under the bonnet. Unfortunately, this can invite some dodgy coding practices on the basis that “if it works who cares what it looks like?”. Well, if it works, who cares what it looks like?
Now I have to read up on lambdas and closures. I always thought lambdas were some sort of curry and closures were something Americans did at the end of relationships.
Posted by David Dashifen Kees on 15.07.08 at 1:44 pm
I, for one, am looking forward to closures in PHP. You’re right, they are a dangerous and oft-abused part of programming (when they’re available) and I’ve met many a coder who accidentally operated on a variable as a result of a closure when they hadn’t intended to, but they do provide a great deal of flexibility.
Besides, the “global” keyword provided something similar to closures anyway. Not quite the same thing, but near enough that you could use it to produce similar results.
Posted by Mark Story on 15.07.08 at 1:44 pm
I for one am really excited about lambdas. Closures are also neat, but I find they create a lot of confusion in javascript as scoping can get lost if you are not familiar with them.
I think it strange that late static binding, closures, and lambda’s are being introduced in what is marked as a minor version of the language. What will they have left for PHP6?
Posted by Brendon Kozlowski on 15.07.08 at 1:44 pm
What’s this about a “Framework Jihad!” t-shirt? Hmmm…?
Posted by derek martin on 15.07.08 at 1:44 pm
I hate to say it, but “dreamweaver” or “indesign” will make your layout issues disappear. They’re both much better than they used to be.
Posted by rtconner on 15.07.08 at 1:44 pm
I’m still all pissed off at php for crossing off named params on the todo list.
ya I agree on the scaling point
Posted by Carlton Dickson on 15.07.08 at 1:44 pm
I wasted a lot of time with layouts and weren’t even sure how they would work across browsers so gave blueprint css a try and would highly recommend it, it’s pretty easy to use and utilises a grid layout system which could be perfect for replacing your current table HTML…I’ve been meaning to write a tutorial on using blueprint and a random css template to show how simple it is.
As for the framework argument I have been learning how to use the Zend Framework and so far I love it….admitedly I was a bit worried about the associated performance issues after reading this article…http://www.avnetlabs.com/php/php-framework-comparison-benchmarks…but you raised a good point “If I get to the point where I have to worry about scaling, then I have done very well indeed”.
The reason I picked up a PHP framework is so that I can hopefully increase my productivity and so far I believe I have…for example the MVC nature of a project and the Zend_Layout component make maintenance so much easier IMO