PHP-DSL

March 8th, 2006, By Duncan Gough

Deep joy, the Zend framework launches… and gives rise to a wave of irritated reactions (the future of php is more depressing than ever, php developed ‘exclusively’ by 20 zend employees) and belated, warm applause (Zend Framework is out, it’s SitePoint, though, do be careful with those mouseclick-triggered, article obtrusive popups).

Ian Bicking has a great post called Towards PHP in which he correctly points out the reasons for the ubiquity of PHP – easy to develop, easy to learn, installed everywhere – and then wonders whether a similar Python approach could be started. Combine the two together, though, and you’re on to something. The Zend Framework is out, great, but what made PHP successful? Simplicity. Who uses MVC frameworks in Python and Ruby – experienced developers who are tired of PHP. Why do many experienced developers stick with PHP, even after learning all the bugs? Because you can comfortably knock up a site in no-time.

So, why doesn’t PHP take a leaf out of the Ruby on Rails book and create a domain-specific language. When it first came out, PHP made database driven web sites wildly simple. Now it’s bloated. The Django developers make serious jokes about this page, and they’re right. But, rather than building an anti-PHP style PHP framework that suffers from object bloat and ill-judged design patterns, why not create a DSL that accepts people will mix HTML and PHP, that people will globalise variables, that people will blindly accept user-entered input?

Do what Rails does. Make the simplest thing the correct thing and create a domain specific language, a version of PHP that doesn’t care about half the stuff in that standard library. Create ‘PHP-DSL’ with a handful of functions that systematically filter input, escape output, create valid html constructs, cache infrequently used data and so on. A version of PHP that runs in PHP but is purely focussed on creating web pages (hence, domain- or problem-specific), that does what PHP does well – no monolithic application server, no front-controller, shared nothing, etc). It’s a very, very strange feeling to admit this, but when I first saw the no-framework PHP-MVC framework I reacted much the same as everyone else, except that now I’m not so sure. In fact, I’m so not so sure that I’m discussing the fact that all PHPs’ weaknesses are its strengths and that we should embrace those strengths and create a mutant version of PHP that makes doing all those anti-framework PHP things simpler. Build a secure, fast, inline version of PHP that smuggles security, maintainability, scalability and MVC in the back door. If it runs in PHP it’ll run on every shared host that supports it. PHP-DSL has the potential to be huge.

2 comments

« The mass amateurisation of everything, in codeTetris »