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.

http://www.codeplex.com/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.

Comments

  1. Anonymous9:54 AM

    From your article, I learn that there are at least two PHP.NET framework.:) have a look at http://www.pradosoft.com/, you will find another php framework which simulate .NET framework.

    ReplyDelete
  2. No, Prado is strictly PHP and has nothing to do with .NET. Here, I am focusing on compiled PHP under the Microsoft .NET Framework only.

    ReplyDelete
  3. Anonymous9:57 AM

    Hi there. Funny enough, I didn´t knew that you could build windows aplications with Php...

    I'm a great Php fan, and not so much an ASP.NET fan, although I like windows and it's framework in general.

    There is something else that you should discuss, instead and comparing ASP.NET vs Php, which is, where they work on.
    Don't forget that ASP.NET isn't actually a programming language, it uses code behind that can be in any MSIL converted language.
    The biggest problem with ASP.NET, is it's platform, and Php wins greatly when it works under Apache. Apache is a very strong, and relieble web server, which can't be said by IIS.

    Another downside of ASP.NET, is the fact that you don't control the output (you can do it, but no one does). With Php (for example), you control every single space or 'new line' that goes to the client. That gives you a lot of control on the final aplication.

    There is a final fact that makes Php a bit better than ASP.NET.
    ASP.NET enables you to change the layout (with limits) without the need to recompile the application, but Php enables you to change not only the layout, but the application's functionality without compiling anything (it's interpreted)...

    Cheers.

    ReplyDelete
  4. Re "Hi There". Sorry but you have some incomplete info or you are just very opinionated. IIS is an excellent web server, its in broad use by major sites all over the world (in fact, MySpace the most visited site in the world, runs on IIS). You can run ASP.NET on either IIS or Apache, and even on Linux with the MONO runtime.
    Moreover, your contention that you cannot control the output with ASP.NET as with PHP is just dead wrong. If you look at the statistics on performance, it is very easy to see why a compiled language platform is superior to one running an interpreted language.

    ReplyDelete
  5. Why do you keep referring to MySpace? MySpace is slow and has the worst HTML code I have ever seen, so I wouldn't doubt that the programmers behind it aren't any better. And just because MySpace runs on IIS and APS doesn't mean it's great. MySpace got popular for the idea, NOT because it runs on ASP!

    "MySpace.com's average server CPU utilization went from 85% to 27% after moving (from another technology) to ASP.NET 2.0"
    That technology was ColdFusion, which is SLOW. You can't compare PHP and ASP and then talk about how ASP is better than ColdFusion. You really had no valid arguments against PHP.

    Also, IIS is a pretty good server, but it's nowhere near Apache's level.

    ReplyDelete
  6. Anonymous2:31 PM

    The thing about PHP is it is nice when developing lower-level, "quick and dirty" applications.

    Unless you're working for a pretty big company, chances are you're not creating another myspace.com or Yahoo!. You're probably just making a comment form or a database driven web page.

    For that, .NET requires way too much overhead in setting permissions, setting up the form, etc. etc. You can do the same thing, for a small project, in PHP, by hand, much faster.

    There is no reason to use .NET if you're versed in the ways of PHP unless you're working for a large enough company to warrant using it.

    Just my humble opinion.

    ReplyDelete
  7. I'm not sure I agree with all that. You are saying this because you are used to developing with PHP.
    I can throw together an ASP.NET app just as fast as any PHP developer can do the same in classic PHP. The point of the article is that Phalanger now allows you to do your PHP thing and gain the advantage of compiled code.

    ReplyDelete
  8. I always find this comparison quite interesting. I have worked in both technologies long enough to compare the two. And being honest ASP.net can get a job done but I would not recommend it to a serious and disciplined programmer over PHP. The things you can do with an untyped language and the many other freedoms found in PHP can either get you in a serious tangled mess or can allow you to write far less code than a language like C#. I'm not knocking C# I'm simply saying that if you take away all the safeguards against bad programming the results are amazing.

    And on this whole code seperation thing. Codebehind is nothing that could not have been done in PHP in the first place and in fact it HAS been done all along. Most GOOD programmers wrote their php in a modular form with code for the page at the top and display code at the bottom. You create your dynamic elements at the top and hold them in strings that are echoed in the display code. This is FAR more efficient performance wise than building the dynamic stuff inline with the display markup. Through the use of php's flexible include function you could then move that entire code block to a seperate file and replace it with one line of code and voila....codebehind. You still have access to all variables classes etc. in you new found code behind. And putting a simple php shorthand echo statement within your html is no different that putting all those asp control tags in. The only difference is that while asp.net will dictate the html coming out of those controls (unless overridden) php allows you to dictate your own html or use some of the free classes to get asp style controls.

    Everytime I see these same pro asp.net arguments I believe most people either have not really used php or have no clue what they are doing if the language doesn't tell them what to do. I mean wake up people... ASP.net is a framework. PHP is a language... you can actually build the ASP.net framework in PHP (if you actually know what you are doing).....see Prado

    ReplyDelete
  9. Anonymous8:08 PM

    Philip, you obviously have not coded with Asp.net, or have a php biased opinion The .Net framework IS a codebase of methods etc.to help you get up and running faster. If you look at the direction php/mysql is heading, they are copying Microsoft and Asp.net.... Stored procedures, Frameworks(cake, drupal etc). Microsoft has had these features implemented for years. Php wasn't really object oriented until release 5. I have been coding with PHP since version 3, so I am no stranger to it. As far as Peter bringing up Myspace and Asp.net, it's with good reason. Don't you think Myspace could/would use the best technology available?

    ReplyDelete

Post a Comment

Popular posts from this blog

Some observations on Script Callbacks, "AJAX", "ATLAS" "AHAB" and where it's all going.

IE7 - Vista: "Internet Explorer has stopped Working"

FIREFOX / IE Word-Wrap, Word-Break, TABLES FIX

System.Web.Caching.Cache, HttpRuntime.Cache, and IIS Recycles

FIX: Requested Registry Access is not allowed (Visual Studio 2008)