Ruby, ruby, ruby, ruby
Well firstly let me apologise for the lack of posts recently. One of the problems of being a student is that once in a blue moon you will have work to do….
Anyway, on to the content. The other day I had an idea for a new type of wiki to aid colaboration, it is early in the research stages and I don’t know how much will come out of it, but I decided to create a prototype, in Rails. This led me to question whether CakePHP was the best choice of language for us to use.
Originally we decided to use PHP because both James and I had used it extensively (James had only done a tad of Rails), I started creating a framework originally but then came across CakePHP so we decided to use that instead. In the end I did the majority of the programming as James was better at designing than me, and this didn’t take up as much time (he has work to do at uni :P).
So now lets get onto some of the problems with CakePHP, which are mainly due to it being PHP based. Firstly when you fetch a database record, rather than getting an instance of a class (as in Rails) you get an array. Although this doesn’t sound that big a deal it means you need extra code which decreases readability. Next up is how variables are sent to the view, in Rails you just create a global variable, where as in CakePHP you need to call a function. This again means extra code which decreased reability.
Another thing about models being classes, quite a major point, in Rails you can call functions in a model that affect the data in that instance of a class, in CakePHP you can’t (AFAIK) so you either have to add extra code to your controllers or write a function in the model that fetches the relavent data, updates and saves it.
Well, I think that is enough about why CakePHP isn’t as good as Rails, lets get on to the good stuff! If you don’t want to learn another language, and want a framework for PHP then CakePHP is an excellent choice! It supports both PHP 4 and 5, it is rather easy to learn (the documentation is nice and short so you can pick it up easily) and has a nice way of debugging (printing out SQL queries and the results at the bottom of the page, Rails doesn’t have this so you have to follow the oversized log files).
So what are we going to do about it? Well at the moment not much, we have got well over 150kb of CakePHP code and I don’t really feel like rewriting it all just yet. We shall wait and say if any major problems crop up, and if so give that big task of rewriting a go. Although it might sound bad, I shouldn’t think it would take too long as getting the views right is always the biggest challenge when implementing a new feature! If you are interested more about how CakePHP stacks up, here is a good comparison!