03
Jan 08

4's dead baby

So PHP 4.4.8 is released, and that’s it for the whole PHP 4 line. No further normal releases are due and PHP 4 is no longer supported. Hopefully this will mean that the takeup figures for 5 get a sudden sharp upwards jolt!

It’s going to be interesting to watch as major apps like Drupal change over from having to provide legacy support for PHP4 and can start to use the better object model in 5 – the question will be, will we see an improvement in the quality of coding as the mainstream toolset improves?


02
Nov 07

Reaching the limits of PHP

First off, I rather like PHP. PHP 5 at least, I think PHP 4 was – and remains – a dog’s dinner of a thing at best. But for 90% (at least) of webpages, PHP is a pretty decent solution. Retrieval of data from databases, display of that data, no worries. Minimal learning curve, support for high-level constructs like objects and exceptions, several frameworks available – PHP’s a damn good choice in the vast majority of cases.

Thing is, right now I’m trying to put together a bit of code to act as a proof of concept, and – more fool me – I tried to use PHP to do it, figuring I’d save some time. No such luck. Turns out, trying to create data in PHP is a lot harder than trying to manipulate or display it. Right now, I’m in the middle of implementing a recognition system using a variable order markov model approach, and just generating the PPM-C prefix trees is a total pain in the fundament. Even the basic data structure I’m using – a trie – has no standard implementation in PEAR or the SPL or anywhere else I could find. So first I have to write that. Then I have to write the code to do all the other stuff. I mean, granted, hoping to find a pre-written PPM library was a bit hopeful, but prefix trees are basic data structures (and yes, I eventually found some sample code for one, but I’m still having to kick that about a fair bit to get what I need from it). But there was other stuff that I tried and ran into problems with. For example, PEAR::Math_Matrix seems to be PHP4 only, and the PEAR version doesn’t want to even parse in PHP5, let alone let me look for determinents or jacobians or eigenvalues. Which put yet another crimp in my plans earlier this week.

Anyway, for the actual production version of this project, PHP’s obviously out and never was in the running. This piece of code has to run as fast as possible – so I’m looking at C++ or C or something of that nature. But for proof of concept, I was hoping PHP was the way to go. Nope. This horse does not do well on this course. I’m thinking it’s time to start playing a bit more with Python or Perl or something for this sort of thing in the future. Which isn’t horrible – better to have more strings to your bow if at all possible. But it does rather shoot the whole fanboy attitude in the PHP-vs-Ruby-vs-Python-vs-Whatever language wars. There’s simply no place for it in a professional environment, and it’s not of any real use anywhere else either.

Still gonna do that rifle club management system project in PHP with Symfony or Prado (if they get the menu component done and released in time) though.

(And someone needs to tell Sean Coates that Microsoft is still evil 🙂 )


17
Oct 07

Prado

On a seperate project from the PEAR work I’ve been doing of late, I’ve just rewritten an earlier project to use the Prado framework. I spent some time a while back looking at various frameworks, and in the end came down to a choice between Symfony and Prado. Because of the way this current project works, I thought Prado’s event-driven model was an easier fit than Symfony’s MVC model. Mind you, for other projects (including the one I was using PEAR for), I think Symfony would be ideal (and I didn’t use it earlier only because of time pressure).

Happily, the front-end of the project I was refactoring into Prado had no work done on it at all (the previous version was effectively a proof-of-concept with all the work in the back end). Still though, if I had to do it over, I’d probably quote an extra week and rewrite the whole thing from scratch using ActiveRecord instead of the custom database interaction I had in this version.

Some of the stuff in Prado isn’t quite as optimal as I’d hoped, mind. For example, nesting templates in Prado doesn’t work fully in that if you have Template C nested in Template B nested in Template A, then a variable in Template A is not visible at all to Template C, and the code attached to Template C can’t change it. So you have to have a TContentPlaceholder in Template A and a TContent linked to that in Template B, containing a TContentPlaceholder which a TContent in Template C links to and that TContent in Template C contains the actual content. It’s suboptimal and messy, because you’re effectively doing inheritance on a pseudo-object by hand, and typos can waste lots of your time, not to mention the headache of keeping it all straight as you code.

And there’s no tree control. And there’s no built-in menu control (though that is up for the next version to be fair, but still, it’s a right pain in the touche to code a fake menu using and CSS, and it’s such a basic kind of control that I thought it bore mentioning in a complaint!).

However, little bits like this are, in the end game, just niggles. Compared to trying to do what Prado does for you out of the gate, you’re light years ahead of the curve when using the framework. Yes, I know, that’s a well-established fact for frameworks and noone’s learning anything new from it, but I thought I’d just point out that it holds for Prado and that Prado’s approach of an event-based model as opposed to an MVC model means that it’s a more comfortable fit for something with a lot of user interaction like the last project I was on.

I mean, for an example, you can build your pages in Prado with no backing PHP code whatsoever, show it to the client for a scratch-n-sniff test, and if it gets their okay, you go code it up; if not, you edit what is pretty close to HTML code and try again. Very fast turn-around that way.

I’m looking forward to v3.1.2 and the new tree/menu control, and once that comes out, I’ve got that little RCMS project I’ve been meaning to write for a few years now that should make for a nice little testbed…