I have been a PHP programmer for a long time, it was the first web scripting language I learnt, and I have built some very cool apps, and it has served me well over the years.
However running a team who code in PHP has a lot of drawbacks:
- No de facto framework
- No coding standards
- Relatively slow benchmarks
I personally love frameworks, who wants to code boring CRUD (create, update, delete) statements, build yet another admin, or yet another news management feature. Like all good programmers I am inherently lazy and hate to code the same thing over and over again.
PHP lacks a really good unifying framework, there is no de facto framework; Ruby has Rails, Python has Django, PHP has … CakePHP, Symfony, Zend Framework and Code Ignitor.
I have used all of the mainstream PHP frameworks:
- CakePHP – I like the syntax, but the docs are poor and performance is a real problem
- Symfony – I could not get my head around the workflow and it is very slow
- Zend Framework – does not seem like a framework to me, more a collection of libraries
- Code Ignitor – is the best of a bad bunch, and personally my favourite for PHP
These frameworks all compete with each other, instead of all working together to help build one PHP framework to rule them all.
People love PHP because it is easy to pick up and get going with, you can write your first PHP script very quickly, and have something working in an afternoon. This works for good and evil, as there are so many people out there who code PHP who actually do not understand what they are doing. There is nothing inherently wrong with this, but this tends to mean that PHP has less coding standards.
On the other hand, getting Python to work is not as easy for a new developer and deploying a python site is even worse. Also as Python is a OO language it seems scarier to most new developers. I love Python as it just fits with my philosophy and I love the way that it FORCES you to write beautiful code.
As I mentioned that as a PHP shop we have already looked at all the mainstream PHP frameworks and none of them in my opinion are good enough.
I had a look at Ruby on Rails, but the publicity and hype around it, coupled with the reported scaling issues made my wary.
My friend and fellow CTO Ben Philips over at Playfire, suggested that I check out Django. I had a read of the documentation and I was seriously impressed with the feature set. It was not the easiest learning curve there are a lot of pages to read on the site to get you up to speed.
Installing Django on my Macbook Pro was not an easy task, it took me a whole evening to get up and running; I had to tweak the MySQL python library and I needed to install XCode developer tools to get the Django built in webserver to work. This was not a good start for me!
Our First App
I did persevere through the installation and I was glad I did, the Django API is very elegant and for simple tasks very easy to pick up. I did have some issues managing images, but the Python Imaging Library helped me there. Also I had to get my head around the middleware stack, and the templating language. After a day or so I was ready to build my first app.
I wanted to really try something in a real working environment, so I decided to build the Oracle Acquisition App in Django. In less than two days the app was built including LDAP requests to the corporate directory, and SSO authentication into the Oracle unified sign on.
What I Liked
I loved the loose coupling of URLs, the encapsulation in models, lazy SQL queries, well defined code layout, adherence to DRY principles, admin out of the box and the powerful template language.
What I Disliked
Importing functions into the models and views was tiresome, the sometimes cryptic error message, no SQL query logging and lack of hooks for the admin (which had since been rectified).
Overall I love Django and I cannot imagine going back to PHP, the next step is for me to sell Django into the Company. It will take some effort of the part of the developers who cannot code in Python, but most good programmers can pick Python up very quickly.
There will need to be a migration process, but I will be slowly migrating all of our systems and future projects over to Django and will be recuiting a specialist Django developer soon. If you are a superb Django developer who is looking for a job in London (and you know a bit of PHP), then have a read of this post.