PHP Vs ASP
PHP Vs ASP
net Comparison
A comparison of PHP (Open Source) vs ASP.net (Commercial), Performance, Cost, Scalability, Support and Complexity
There are hundreds of forum debates and articles on the Internet about whether PHP or ASP.net is a better platform. Unfortunately, most opinions are biased and their preference is typically based on promoting one programming language over the other. Also, if you pay attention to the dates on those articles and debates, you will see that most of the information is outdated and old. This is unfortunate the debates are showing on top of search engines and the information is no longer valid. We need to consider that there are periodic major upgrades and improvements done to both PHP and ASP.net platforms. Let me assure you that both programming languages are used in very large web applications and large successful web sites so there should not be any doubt to the ability of any of the above programming languages to handle a large web application project. In this article: Regarding performance, I'll explain what factors will effect performance and the result will prove that selecting one programming language over the other because of speed is pointless in most scenarios. Regarding scalability, I'll explain what factors to consider when it comes to scalability and if programmed correctly, both programming languages are very scalable. Regarding cost and support, since PHP is open source and commonly runs on an open source platform, LAMP (Linux, Apache, MySQL, PHP), PHP wins over ASP.net for providing the most cost effective solution and providing a large amount of resources and support. Regarding time to deployment (an additional concern for cost,) on average, it takes twice as much code writing to accomplish something with ASP.net than PHP, so time to deployment is faster using PHP. I'll go over each of the considerations and also provide my two cents below:
Programmers' experience Using the best programming practices Using a solid programming framework Following programming guidelines and standards
required enormous tasks that is why Google and Yahoo use several programming languages (mostly open source), each selected to handle the tasks that the programming language is best at performing. Below, I'm going to analyze the common and uncommon scenarios and explain which task is better than the other: 1st Common Scenario: One of the common tasks of any web application would be to access and query the database and output the result to the web server and then to the browser. So on this common scenario, all the programming language is doing is communicating / interfacing with the database server and web server. On this common scenario, the speed of the programming language has almost no affect on this process; the speed of this process relies on the database server, web server, client's web browser / computer and bandwidth. When it comes to the main and common database servers, MySQL (now owned by Oracle), PostgreSQL, MSSQL and Oracle are all fighting for speed and performance. We keep seeing new features and better performance by all database servers in each version upgrade so I will say that the above database servers will all have a great performance if the database programmers use optimized and practical SQL queries and if needed, use the advanced features such as caching. MySQL is used by Google, Facebook, YouTube, Yahoo and recently on FIFA World Cup which received a huge audience around the World. So I would not question the capability of the MySQL database server. Based on my research on a few online stats, as of this writing, the communication and interfacing between PHP and MySQL is faster than ASP.net and MSSQL but it is not very noticeable. 2nd Common Scenario: One of the other common tasks of any web application would be to access the file system, find an image and send it to the web server. In this case, again, the programming language is doing very little it is the Operating System and the file system that has the burden of communicating with the programming language. Based on my research on a few online stats, as of this writing, the Linux OS and ext4 (file system) performs better (IO) than Windows OS and NTFS (file system.) 3rd Common Scenario: Most Linux / Unix servers are run very lean without any extra un-needed packages or GUI interfaces and therefore the OS uses a lot less CPU and RAM which provides more allocation to the database and web server. Most windows servers run clunky and with many un-needed packages and GUI which will be using much more CPU and RAM. Obviously, a LAMP platform will have an advantage over the ASP.net platform because it will have more available resources. 4th Not Very Common Scenario: ASP.net is usually written in C# (pronounced C Sharp) generally speaking, as of this writing, C# is a faster programming language than PHP. (This may change as each programming language will come up with upgrades to fight for a better speed.) So if the programming language needs to run a 2,000,000 loop execution of a calculation, an ASP.net written in C# will win over PHP. However, this is a very uncommon scenario, the most loop executions of a calculation would be in 100s and not 2,000,000s. And in this case, there should be other concerns about why someone needs to do a 2,000,000 loop calculation. Additional items that can have an effect on performance but have nothing to do with which programming language is selected are:
Ability and knowledge of programmer(s) to optimize the code Ability and knowledge of programmer(s) to write proper and optimized SQL queries.
Functionality required (some functions may take longer to execute in the ASP.net platform and less time in PHP platform and vice versa.
III. Cost:
PHP, MySQL server, PostgreSQL server, Apache server, and Linux OS are all free and upgrades are also free. In addition, there is no additional licensing cost for having another hot standby server as a backup, or needing to run multiple servers for load balancing or server clustering. LAMP (Linux, Apache, MySQL and PHP) is also much more popular among hosting companies, and its popularity results in a lower monthly hosting cost for LAMP hosting compared to Windows hosting. ASP.net and IIS are free if you purchase Windows OS. There is a substantial licensing cost for a Microsoft Windows Server, Microsoft SQL Server and future upgrades. For example, Microsoft Server 2008 R2 Standard - 64-bit cost is about $1029 and Microsoft SQL Server 2008 Standard Edition For Small Business cost approximately $1038. The above licensing costs for Microsoft can substantially increase if the site becomes popular and there is a need to run the site on multiple servers or requires server features such as load balancing, server clustering or hot standby.
V. Time to Deploy
It takes a larger amount (more lines) of code to accomplish complex features and functionality with ASP.net compared to PHP, adding more time to the development process. Additionally, PHP is interpreted at the server, so when changing a functionality, no additional steps are required to see the changes. On the other hand, ASP.net needs to be compiled each time the code is modified. Again, the development process is more time-consuming when using ASP.net as opposed to PHP.
VI and VIM are very advanced and independent editors, and the programmers who learn and use those editors to the fullest capabilities can perform very complex programming, in a fast, efficient and independent way. Those programmers have more control and flexibility, and when it comes to the need of using and integrating other essential platforms, such as JavaScript, Ajax, JQuery, etc., the PHP developers have a better advantage because of their familiarity with the open source environment and hand coding using VI or VIM editors.
Site
Up Since November 1998 February 2004 February 2005 August 1995 August 1995 August 2008 January 2001 October 1995 November 2005
Server Platform
Programming Language C, Java, C++, PHP & MySQL PHP, MySQL and C++ C, Java and MySQL C++, C, Java, PHP & MySQL ASP.net
Windows
Live.com (owned by
Microsoft)
Windows
ASP.net
Wikipedia
Linux
Amazon.com
WordPress.com
Linux
VII. Popularity
The LAMP platform is much more popular than the Windows platform. Based on Netcraft's July 2010 Web Server Survey of 205,714,253 sites, 112,945,968 (54.90%) are hosted on Apache and 53,217,620 (25.87%) are hosted on Windows; the rest are hosted on other platforms.
There are many misconceptions and misinformation about Linux being unfriendly. This really depends on the experience and knowledge of the person setting up the platform. However, I have to say that I'm very impressed with the new and improved versions of popular Linux distributions. These distributions of Linux such as Ubuntu, Red Hat, CentOS, openSUSE, and Fedora have done a great job providing ease of installation and deployment, as well as a simple and straight forward GUI interface that makes configuration and setting up of a Linux server very manageable. Unfortunately, in my opinion, Microsoft Server has been going backward with usability, by making the server administration extremely clunky and filled with complex and un-needed features.