PHP vs ASP.NET

It would be fair to say that the last post PHP vs ASP, was slightly one sided due to the fact that ASP is almost extinct now. However that is not to say people still don’t use it when there are other options available. Obvioulsy a fairer comparison would be PHP vs ASP.NET and this is what I discuss next.

Having used both of these languages for a variety of applications and websites I have made up another list comparing one over the other. Although PHP 5 has been released, for the purpose of this document I will be comparing the most widely used and supported version 4.11

Why PHP is better
1. Once again PHP is Free and that is a major advantage and often the decider between which language should be used. Microsoft have expensive licensing costs which are handed back to the user via more expensive hosting costs. Dedicated servers with your own MS SQL database from Microsoft is rare for smaller sites due to the cost involved.
2. Ease of learning. PHP is a straight forward scripting language, there is not a great deal of learning required before you can start programming with this language. PHP.net does a lot to help for this, it is the single, most convenient API and reference guide and in my opinion better than any other for any other language that is available. ASP.NET on the other hand requires basic programming fundamentals, and an understanding of object oriented principles which may be beyond the causal coder.
3. PHP is a very fast and efficient implementation of a programming language. It doesn’t nearly use as much memory or execution time as ASP.NET, while this may not be noticable to many websites, for people pushing the limits of their website, it is a major consideration.
4. One argument I hear a lot of ASP.NET developers raise is that there is a great IDE to develop the software on, Visual Studio.NET . While I have to agree that it is great, it does once again come with a price. Similar alternatives for the PHP language, such as Zend Studio are just as good and come at a tenth of the price.
5. PHP runs on APACHE which has a great security track record and is open source. However IIS, the platform for ASP.NET has in the past been plagued with problems and security concerns. Regardless of whether people are just attacking it because it’s Microsoft, the flaw to be exposed is still there.

Why ASP.NET is better
1. ASP.NET has something called the Common Language Runtime(CLR), and without going into too much detail, you can use a variety of different languages to program in, and when built they will all compile to the same code at that level. This means that you can use languages such as C#, Visual Basic.NET, Java.NET and you can even get implementations in PHP. This aids transition and helps other developers already learned in the lore of a certain language quickly pick up.
2. This isn’t necessarily a positive but as ASP.NET is a commercial framework, bigger companies have more faith and trust in the software, and quite often a great deal of support can be gained because of this.
3. .NET is a modern framework that has been designed from scratch. Thus meaning that the architecture, design and implementation of the languages involved are up to date and using modern principles. For example, C# is a fully object oriented language and builds on all the correct rules of programming. Regardless of the fact it may indeed take longer to program this way, it is cleaner, and logically it makes more sense and in the long run leads to less mistakes due to it’s strong typing.
4. Exception/Event Based Error handling is a definite positive for ASP.NET. With the use of try catch blocks (although expensive) allow more sophisticated error handling. Whilst error handling in PHP is possible, there is no built in standardised way to achieve this.
5. ASP.NET allows what is known as Code Behind Sheets. This effectively separates the logic from the design and allows you to create classes for each of your pages, leading to easier maintenance and clean code. This is possible in PHP but is certainly not a built in or standard feature as such.

So the main question is, which one would I pick? Really, it’s not that simple, it’s usually more a question of which one is the best for the job in hand, or even more likely the project you have to work on has already been started in one language by your employers and which you must continue in.

If it was entirely a personal opinion, I would pick the cheaper option PHP, if however there was no costs I would pick ASP.NET.

1 Comment »

  1. David Waller said,

    January 8, 2008 @ 11:01 am

    I don’t think costs are as important as you might think for it is certainly easy enough to design an code in .Net without having to spend a penny. While hosting costs for.net are higher than PH P the gulf isn’t great. You do however, have a point when comparing mysql and SQL server hosting as SQL server hosting can be considerably more expensive. If you don’t need a SQL server hosting then the cost between asp.Net and PHP is negligible.

    For ease of use and cleaner programming I would always favour .net over vanilla PHP.

RSS feed for comments on this post · TrackBack URI

Leave a Comment