Hacker News new | ask | show | jobs
by keiretsu 6936 days ago
Don't assume that everyone who uses PHP don't use a framework. Anyone who uses a PHP framework can get similar development speed as someone who uses Django/Rails.

There's a reason why smart people uses PHP instead of Rails: Most notably it's proven to scale (Yahoo, Facebook). I have personally tried Rails and love it to bits. But the performance issue is not worth it. In the end, i wrote my own stripped down Rails-like framework in PHP in 1 week and migrated the app in a few days. Performance boost was very noticeable. (Avg page loading time dropped from 1.5 secs to 0.3s)

And to those anti-PHP fascists, yes it's possible to write neat PHP code. There is no scattered SQL in my app since i follow Rails' MVC structure. And since I code "functionally" and don't use PHP OO features, so its half-baked object system doesn't bother me.

I don't mean pure functional. I mean i use lots of functions instead of object methods. I don't like mixing data with functions.

2 comments

I explicitly stated in my post that I was unsure if he was using a php framework. I try to avoid unfounded assumptions, although I certainly make them.

Scaling can be overemphasized: it doesn't matter if it scales well if it doesn't work. Beyond that, Rails and Django both have sites getting hit with huge quantities of requests. Beyond that, many of the issues with scaling are database issues, not framework issues. As such you will have those same database issues regardless of the framework you chose.

I see scaling well on a Django site as being simpler than scaling well on php. Django has a potent caching system that is easy to activate (the creators of Django also created memcached, so the integration is exceptionally well done, but you can also cache to files, a database, etc), and it can be configured to cache at the level of granularity required (specific db queries, entire pages, components of pages, only for users who are not logged it, etc).

I have no doubt there are reasons to be using php over rails or django, but I don't think that scaling is one of them.

Finally, writing your own framework is the antithesis of doing something that scales well: your company and your programmers also have to scale along with your software.

The issue with Rails for me wasn't the database bottleneck. It was the ActiveRecord. It was using far too much memory and was taking up the bulk of the page loading time. After i migrated the app to my php framework, I downgraded to from a 2GBz 1GB RAM server to a 2GHz 512MB RAM server and i still get a performance boost. Running the rails app on the 512MB server was painfully slow.

Writing your own framework is a good compromise if it can give you that performance boost that the other frameworks can't give you. I've tried the other PHP frameworks and the best page loading time i got was 0.9s.

Code Igniter is a pretty good framework for php. Much better than Cake as it doesn't sport so much "magic" behind the scenes.