PHP vs ASP.Net
By the moment that ASP.Net came to the surface, there has been a long debate among programmers which one is better or not. Since I have used both languages, I will try to do a quick comparison. But lets start with some history first.
PHP traces it roots back to a 1995 Perl application designed to track accesses to Rasmus Lerdorf’s online resume! Two years later, his subsequent open-sourced C implementation of his Personal Home Page / Forms Interpreter – PHP/FI – was installed on 1% (~50,000) of the world’s Internet domains. In 1997 Andi Gutmans and Zeev Suraski do a third rewrite of the C implementation intended for their ecommerce application which was designated as PHP 3.0, a recursive acronym for Hypertext Pre-processor. PHP has now reached version 5.3.x and 6.0 is on the way!
ASP or Active Server Pages is the first attempt of Microsoft to create a server-side language used for generating dynamic and interactive pages. In 2002 Microsoft releases the ASP.NET as a successor to ASP. ASP.NET is built on the Common Language Runtime, which allows programmers to write ASP.NET code using any supported .NET language (C#, C++, J#, Jscript.NET, Python, Ruby, etc). At the moment ASP.NET is at version 3.x.
Here are some interesting comparative details for both languages:
- PHP generally is much simpler than ASP in terms of usage. PHP was written in C which make coding simple. On the other hand ASP uses a simplified form of Visual Basic language known as VB script (although with .NET you can choose between all the different languages mentioned above). However ASP has a steeper learning curve.
- One of the big advantages of PHP is the great support of different database systems (with MySQL usually as the first choice). Although connectivity in ASP is much improved since its first versions.
- ASP.NET is generally faster than PHP (both on Window and on Linux servers) with the exception of File Copy and Attribute operations.
- On the other hand loading speed is a big factor. And in that case PHP is faster, because ASP uses an overhead on the server since it uses a COM based architecture (check below the advantage of compiling of ASP).
- Related to the previous point, another important statement is that PHP isn’t compiled, except at runtime. However .NET enjoys all the benefits of fast and accurate compilation. However with PHP you can use Zend’s PHP Accelerator which is doing more or less the same.
- When it comes to databases, MySQL on PHP is a little bit faster than SQL Server on ASP. However in terms of performance for large scale databases opinions vary.
- .NET programming has more advanced options like multi-threading, asynchronous requests etc. So when it comes to high end performance programming ASP would probably be a better choice.
- PHP is open source which means free to use with tons of users with helpful hints and solutions.
- PHP enjoys the flexibility of running on various platforms such as Linux, Unix, Windows and Solaris. On the other hand ASP is primarily related with Windows platform.
To conclude, in my opinion one of the big advantages of PHP is not PHP itself, but all the programmers that have created amazing applications and tools for PHP (e.g. Drupal, Joomla, WordPress, etc.). For me that is the main factor which makes PHP my first choice.
However both languages are scripting languages of choice and are equally being used to develop rich websites with database connectivity. It is not very easy to say which one is the winner. But taking into account the current usage statue, PHP is mostly preferred.