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 >> || || ||

Namespaces in PHP? Why *wouldn’t* you want them?

Earlier today I say the following tweet on the-often-down-but-always-interested Twitter from Matthew Weier-O’Phinney:

“What issues to _you_ see with using namespaces in PHP? Start blogging!”

Since I am one who likes to share his opinion on a wide variety of topics, I thought this is a good one to prompt discussion.

Namespaces are expected to be a feature in future releases of PHP. I’m an outsider when it comes to tracking the going-on in the world of PHP internals. So, because of that, I’m not going to comment on the actual syntax of how namespaces will be implemented or it’s impact on internals. That’s not really important as far as this particular discussion goes.

Imagine if you will that you are the user of a web application framework that allows you to easily use third-party libraries by dropping them into a specific location in your application structure. You go to use it and…what the fuck?!? Class name conflicts?!?!? ARRRRRRGGGGGGGHHH. You proceed to post to the mailing list for said framework, complaining bitterly about how you cannot use your favourite library with this stupid framework. Some grumpy guy from Canada flames you in response and it spirals down from there into oblivion.

There are many programming languages that support namespaces, but PHP was not one of them. Why are namespaces so important? They can help to solve the exact problem mentioned in the paragraph above. Why *wouldn’t* you want such a thing?!?! You can have 5 classes with the same name in 5 different namespaces and everything will be just fine. Except for the fact you have 5 classes with the same name. That’s not good design, but namespaces would let you do that.

So, to go back to our little framework example for a minute, the framework could assign itself a namespace (oh, I dunno, like ‘Cake’) and if you happen to want to use a 3rd-party library with your application that has a class with the same name, it’s all good…as long as you didn’t put your own code in the same namespace.

So, to answer Matthew’s original question: I cannot think of any reason to NOT have namespaces in PHP.

Article Tags >>

What’s In Chris’ Brain: March 2008 Edition

I’ve got a whole bunch of little things I want to talk about, as opposed to one big topic. Here we go

  • You’ll see a badge on the right side of my blog announcing that I’m speaking at Open Web Vancounver 2008. If you can make your way up to Vancouver on April 14th and April 15th, please come up and support this conference.
  • I got an email from someone on the CakePHP mailing list asking me about what sort of setup I have for running my apps. I have a 256 MB slice with slicehost, and I have ZERO complaints about performance. I’m running PHP 5.2.5 under fastcgi (I use nginx as my web server), with MySQL on there to power my blog. In an earlier post I wrote how to create the rewrite rules for CakePHP to work with nginx, so search my archives for that. I’ve got Python on there as well for my upcoming Django work, and soon Apache will be on there to act as my app server for Django.
  • Wrote my first Python script for work: it trolls through a bunch of gzipped XML documents, doing some search and replace. 75 lines of pure Python n00bness, built entirely with the help of “Dive Into Python” and google. I’m sure it could be optimized by some more experienced Pythonistas, but it sure felt good to get the first one done and out of the way.
  • I’ve decided to start using twitter again, see how long that lasts
  • The more I use it, the more powerful I realize jQuery is
  • Some ruthless refactoring has caused my Code Igniter code to be a bit more CakePHP-like, in that I’m moving stuff into models and out of the controller wherever it makes sense. That’s a good practice no matter what framework you use
  • As much info as there is out there for using Django (the Django project site, the Django book available online), it sure would be helpful to me to find some sort of Django guru who can help me out with some of the finer points of Django and Python itself. I’m trying very hard to not write Python code like I was writing PHP, and I feel like some of the finer points are escaping me.
  • I’m working on moving some old CakePHP code I have that runs on PHP 4 over to PHP 5, and having PHP 4 *and* PHP 5 running on the same server. Should be an interesting experience
Article Tags >> || || || || ||

I’m An Editor Waffler, Part II

In a post earlier this week I had talked about the fact that I have turned into an “editor waffler”, paralyzed with fear that I couldn’t decide on what editor to use for my day-to-day use. I had promised that by the end of the week I would reveal what editor I’ve decided on using. But before I talk about that, I wanted to talk some more about my thoughts on why I can’t decide.

I had prepared a really long blog post to answer this question but I started rambling and I deleted it all. It comes down to a fear of freedom. That’s right, a fear of freedom. I have enlightened employers who don’t care what tools I use as long as I get the job done. I’m grateful for that, so I am constantly looking for tools that meet my requirements from project to project. I think I’ve settled on the collection of tools that are working for me on a daily basis. Thanks to Marc Grabanski for his Arsenal of Web Development Tools post for reminding me that it’s about tools that you don’t fight with that help you get the job done.

Here’s my personal web development stack:

  • TextMate — built in SVN integration, syntax highlighting for all sorts of common web langauges *and* I found a plugin that highlights what files in the file drawer are under version control
  • Terminal — still a CLI guy for a lot of tasks, especially for code generation
  • Firefox with Firebug — if there was something as good for Safari I’d use it instead
  • CocoaMySQL — sometimes I use the CLI client, but CocoaMySQL is the tool I use most of the time for MySQL work. I need to find one that I like as much for Postgres
  • CSSEdit — I was so impressed at how it helped this CSS and layout n00b fix a problem, I paid for a copy

Those 5 tools are the ones I find myself using consistently, day-in and day-out. But that’s not to say I don’t use other things as well. I use vim for quick editing of system-level files and for editing on various remote servers. I do use Komodo when I really need to do some deep debugging, like I had to do a few weeks ago to try and figure out why an upgrade to the latest version of Code Igniter was failing for a work project (they broke their Active Record implementation when dealing with Postgres for whatever reason, please prove me wrong if that’s not true) and it helped me narrow down the problem a lot faster.

By being an “editor waffler” I have learned enough about a variety of tools that I feel like they are all part of my toolkit. It’s like having a large number of tools and making sure that you use the right one for the job. Okay, enough angst from for now on my choice of editors.

Article Tags >> || || || ||

What’s The Next PHP Stack?

Most developers who have worked with PHP for any significant period of time have heard of the LAMP application stack. Linux, Apache, MySQL and PHP. This is probably the most common PHP application configuration out there, and I’ve been giving application stacks a lot of thought these days for a variety of reasons. First of all, I’m giving a talk on application deployment at Open Web Vancouver, and the stack plays a big role in that. Secondly, I’m always looking at new technologies and trying to figure out where they might fit in.

Thirdly, there seems to be a trend towards providing “drop-in-place” PHP stacks for developers trying to figure out things locally. I’m talking about things like MAMP and Wampserver.

So the next thing I’ve been wondering about is about what future PHP stacks will look like, at least on the open source side of things. Have we gotten to the point where this is as good as it gets? I know for my own personal stuff, I’ve started moving away from the AMP part of LAMP, instead using Postgres for database stuff and nginx as my webserver. So, what is that now? LNPP? That doesn’t roll off the tongue as nicely as LAMP.

Also, are we limiting ourselves in the description of a stack by just going with PHP as part of LAMP? With the rise of Javascript on the client-side and the increasing use of frameworks by developers (I’m *not* getting into that MVC argument again) do they need to be considered as part of the stack now?

So, my question to my readers is this: what do you see as the future stack for PHP? Is LAMP the combination likely to continue to see the most usage? To spark things off, here are some of the PHP stacks I’ve been working with lately:

  • CakePHP + PHP + Apache2 + Postgres + Gentoo Linux
  • jQuery + Code Igniter + PHP + Apache2 + (eXist + Postgres) + Debian Linux
  • jQuery + CakePHP + PHP + MySQL + nginx + Gentoo Linux

Let me know your thoughts about the PHP application stack in the comments. I mean, are we going to see something like an application server for PHP (like Mongrel for Ruby folks) or is mod_php or FastCGI (for the nginx + lighttpd folks) as good as it’s gonna get?

Article Tags >> || ||
Want to advertise on this blog? Send email to chartjes@littlehart.net
GTcars Canadian Car Audio TurboDodge Car For Sale Sign
Audi Forum Mustang Forum Dodge Intrepid Miata Turbo
GTscene Pontiac Bonneville