ASP.NET 2.0 vs PHP -- or PHP.NET?

I finished up my Multisearch Windows Vista Sidebar Gadget, which allows you to choose from multiple search providers and get your RSS Search results in your Sidebar gadget, and I chose the Google Blog Search provider and searched on ASP.NET and came up with this post on Digg.com (target of post):

http://www.modernlifeisrubbish.co.uk/article/why-not-dot-net where this fellow basically trashes ASP.NET in favor of PHP. Most of his reasoning in favor of PHP is really just personal preference, the reasons given are mostly inaccurate or biased because of lack of knowledge about ASP.NET and the .NET platform.

There was one comment on the Digg posting, however, that I found revealing:

"You should check out Phalanger.


It integrates PHP with ASP.NET, pre-compiling your PHP into MSIL, the same way eAccelerator and others pre-compile scripts. The difference is, it's done by ASP.NET, and your scripts run on IIS6. With your scripts running on ASP.NET, they're running managed which protects you from a great deal of security issues.

As for performance, I suggest you give it a try, because our tests show PHP running under ASP.NET under IIS6 under Windows 2003 completely destroys the same hardware running PHP with eAccelerator under Apache Linux 2.6 or FreeBSD. Sounds hard to believe, but we're a shop full of linux/unix guys and all our stuff is currently on Apache and we gave ASP.NET a chance at running our PHP and the results were stunning.

Phalanger gives you the ability to use the .NET framework in your PHP scripts, and to use the code behind model of ASP.NET, but you don't have to use that stuff if you don't want to! It is 100% compatible with existing classic style PHP scripts, and PHP modules. (N.B. - it is - tried it, and it was a 100% total "no brainer")

I'm no microsoft fanboi, but if you're a real developer you shouldn't be a unix fanboi either, you should test things out and see what works best for you. I highly recommend you test Phalanger with your existing PHP codebase."

Well! I had already looked at Phalanger, but I didn't realize it was that far along, so I downloaded and installed it (including the Visual Studio 2005 IDE Integration support).

Let me tell you something: PHP is extremely popular, but it's still an interpreted language, like VBScript with classic ASP. When you can combine the ease of use of PHP with .NET Compiled Framework support, you have got a winning combo. I tried a couple of PHP web apps, and I was duly impressed. There is a checkbox in the installer that basically asks you if you want to support compiling classic PHP scripts, and I checked it, and it works- right out of the box!

The included PHP.NET compiler will output standard .NET class library assemblies that can be used by any .NET application. Think about it - this is HUGE!

What does Phalanger do?

My extract from the features section of the help PDF:

Phalanger enables developers to painlessly deploy and run existing PHP code on an ASP.NET web server and develop cross-platform extensions to such code taking profit from the best from both sides.

Compatible with PHP 5.1 as well as with proposed features from the upcoming PHP 6, the object model in Phalanger enables to combine PHP objects with the .NET ones. It is possible to use and extend any .NET class in PHP and also consume classes written in PHP from an arbitrary .NET language.

From another point of view, Phalanger provides .NET programmers with the giant amount of practical PHP functions and data structures - many of them reimplemented in the managed environment of the .NET Framework. The whole library of PHP functions and classes (including those implemented in the PHP extensions) is accessible to a .NET programmer together with type information.

The compilation of PHP scripts gives yet more power to the existing PHP web applications inside the Phalanger environment. All the static (run-time immutable) code in the scripts gets parsed and compiled only once and all following accesses to a page benefit from the unleashed execution of the native compilation of the script. Yet the usage of Phalanger is not limited to web applications. The compiler supports output of standalone executables or dynamic link libraries enabling you to create managed PHP console or windows applications, or library modules reusable from any other .NET Framework application.

Personally, I look at this from the standpoint that there is a huge codebase of high quality PHP stuff that I may wish to use without having to run PHP in interpreted (or even "eAccelerator") mode. With Phalanger, I can run this great codebase in ASP.NET with no hiccups at all and get the enormous perf boost that the ASP.NET model provides. And, I can host it in IIS just like any ASP.NET application.

If this isn't PHP.NET, I don't know what is.

In addition I will leave you with this snippet from Scott Guthrie's ("Mr. ASP.NET") blog from March (paraphrased for simplicity):

"Myspace had (in March) 65 million registered subscribers, and were registering 260,000 new users each day. According to the Media Metrix report (an independent analyst firm) MySpace.com had more page views in February than all of the MSN and Google sites combined. Umm!

They re-built and re-deployed their site on ASP.NET 2.0 shortly after it was shipped last year. Some statistics:

MySpace.com is now processing 1.5 Billion page views per day
MySpace.com handles 2.3 million concurrent users during the day
MySpace.com's average server CPU utilization went from 85% to 27% after moving (from another technology) to ASP.NET 2.0

The top-6 domains in terms of page-views in February according to Media Metrix were: 1) Yahoo, 2) MySpace, 3) MSN, 4) Ebay, 5) Google, and 6) Hotmail.

4 of the top 6 sites (MySpace, MSN, Ebay and Hotmail) run on IIS and Windows"

You PHP folks? Read up on it d00ds, WAKE UP and put that convenient "anti-Microsoft" stance aside for a bit, and open your mind. You can have your PHPCake and eat it, too... It's not just about scripting: it's about performance too.