Why not .NET? 7 December, 2006 — Stuart Brown

Why use PHP over ASP.NET?

Posted in Web Development, Opinion
Tagged with: , , , , , ,

I was recently asked about my choice of scripting language for Modern Life - and why I chose PHP over comparable alternatives such as ASP.NET, Ruby on Rails etc. I work with PHP, Classic ASP and (more recently) ASP.NET - I've even dabbled with Ruby on Rails - but what was my rationale for choosing PHP?

Performance woes

Back in the day, Modern Life was written in Classic ASP with a SQL Server backend - but the hosting was shared IIS, with a cap on simultaneous connections which meant that visitors would get the unhelpful 'Service Unavailable' message at moderate traffic levels (circa 300 visitors/hour was the critical limit).

Quite clearly unacceptable if you plan on getting major traffic to your site, of course - so I decided to opt for a dedicated server.

Expensive hosting?

So why did I opt for a Linux server in lieu of Microsoft? Well, cost was certainly a factor - comparable Microsoft packages for hosting have a 10-15 premium to cover the licensing. All other things being equal, why pay up to 200 extra a year for Microsoft?

TCO claims regarding the Linux/Windows debate usually claim staffing costs for Linux are higher - evidently Linux experts are harder to come by when compared to Microsoft-certified types - but in a sole webmaster situation, Linux is a clear choice if cost is a factor.

No mod_rewrite? No thanks!

I've worked with IIS quite extensively, both in the enterprise sense and the tinker-at-home sense - and indeed, most of my experience with PHP has been on an IIS server. And for what it does, IIS is a capable platform - it's scalable and reasonably easy to configure.

Compare it to the unassuming Apache web server, however, and there are some obvious deficiencies in the Windows option. Whilst I will admit that editing .conf files isn't as intuitive as the Windows interface, once you're used to it, the internal workings are a lot more apparent.

Perhaps the key point when comparing IIS to Apache is the absence of a worthy mod_rewrite replacement on IIS. Pretty much all the Classic ASP and .NET applications I've worked on have had ugly, unusable URLs - and while there are alternatives (virtual directories, ISAPI extensions), none come close to the power of mod_rewrite.

If you're involved in SEO, even just a tiny little bit, then you need Apache.

Coding comfort

So what of the languages themselves? There's no doubting ASP.NET, and the .NET framework as a whole is a very robust and consistent framework, with a choice of languages and consistent object set. That's awesome. If you're a programmer.

I've come to the conclusion that I'm not so much a programmer as I am a scripter - I love to hack things together, see how they work, and mess around with stuff. For me, programming is a lot less fun when there's a way something should be done. It kinda takes the fun out of it.

PHP is an awful programming language. It's full of inconsistencies, and does practically nothing to encourage good practice. It's getting a lot better in this respect - but the one thing that has always appealed to me about PHP is the way in which you can freely experiment in a plain text editor (Crimson Editor is awesome), construct a small script, then see it work. It's a lot more comfortable than ASP.NET.

But, despite the apparent lack of efficiency and 'coding comfort', I've never been dissatisfied with PHP's performance. Its extensibility and impressive out-of-the box feature set belies a lean core, which (if used correctly) can be used on high-traffic sites without so much as an afterthought.

Heck, if Modern Life can withstand 8,000 visitors an hour from Digg, Reddit and Fark, then PHP can't be that bad at all.


I do happen to be a fan of SQL Server - the suite of tools provided with SQL Server 2000 was a familiar environment for a long time, and I have no major qualms with it at all - Enterprise Manager and Query Analyzer are very powerful tools when it comes to SQL optimization.

MySQL, then, is perhaps a weaker comparative - there's no GUI supplied, for one thing, which makes the learning curve somewhat more difficult, and the SQL used is a little more primitive - T-SQL (SQL Server's implementation) has a comprehensive feature set with fewer limitations - some more complex queries in MySQL are rejected for no reason other than arbitrary limits.

This aside, however, MySQL is fast becoming a viable option, with their pitch towards enterprise user becoming stronger than ever.


I should point out at the above is based on only my experiences, and is my opinion. ASP.NET may very well be awesome, but for whatever reason I've grown fond of PHP. If you've had any similar experiences, or if you're firmly in the .NET camp, let me know - I'd love to hear an opposing viewpoint!