Compilation

Jun 17, 2009

In PHP, when a page is requested, the HTML and PHP script is compiled to Zend Opcodes, which are low level binary instructions used for serving PHP pages. After these are compiled, the Zend engine runs the opcodes and afterwards, HTML markup is generated and served.

In order to speed up the execution of a PHP page, there are a number of commercial products that can be used to perform opcode optimization; another option to increase the performance of PHP scripts is to use "accelerators", which provide opcode and HTML caching. However, a downside is that such third party applications will still result in other issues, like platform compliance.

ASP.NET on the other hand works in a different way. When a request for an .aspx page is submitted to the IIS (Internet Information Service) or another Web server, the request is passed to the ASP.NET handler for processing. If the page is requested for the first time, ASP.NET will compile it to MSIL, which is then processed by the CLR to machine code. The request is then run using the resulted compiled code. Other requests from the same page are served through the same machine code.

The binary code generated by the CLR is optimized to maximum, so no add-ons are required to achieve the highest performance levels. Also, all the built in functionality in ASP.NET is already compiled to machine code.

1. Migrating from PHP to ASP.NET - Introduction
2. Feature comparison
3. Architecture and object oriented programming capabilities
4. Compilation
5. Data and page caching