Welcome to another SitePoint Debate. Today, daggers are drawn over that long-running battle of the technological titans — Open Source and Microsoft.
Specifically, we ask “Does .NET mean the end for PHP?” Judge for yourself…
Here’s a lesson for anyone in advertising – confuse your customers. It’s a dream ticket, as Microsoft have demonstrated with their marketing of .NET. You can almost hear Google straining under the weight of “What is .NET?” queries. It’s almost as cunning as PHP’s definition:
Q: What does PHP stand for?
A: Hypertext Preprocessor
As anyone browsing the SitePoint Forums knows, the hottest debate right now is PHP vs. Microsofts .NET. Discussions range from reasoned interchange to wild argument; anything from “.NET — who cares?” to “.NET — the greatest thing since sliced bread”. What is clear from many posts is there’s a lot of uncertainty about what .NET actually is, and what impact it has on Web development.
This article is intended as “self-defence” for any PHP developers being harassed by over-exuberant .NET fanatics. It’s just one PHP’s coder’s point of view, but it should help clear up some of the most common misunderstanding, based on what’s been said at the SitePoint Forums in recent weeks.
The Top 10 Misconceptions
1. PHP is like an open source .NET.
You can’t compare PHP with .NET. .NET is an application framework (an environment for building and executing applications) not a programming language; it’s like comparing a truck to a road. PHP can, however, be compared to languages which run under .NET, such as ASP+ or C# (referred to as “Language.NET” here).
2. .NET is going to be the future of the Internet!
.NET is the future platform for all Microsoft technology — it’s not aimed solely at the Internet. In fact, it’s likely to make its first big appearance on corporate Intranets, with Office.NET and .NET versions of existing Windows NT server software.
3. .NET is the best technology for building a Website.
Both PHP and “Language.NET” are viable solutions for Web building. Whether it’s delivering a dynamic Web page generated from a database, sending an email, or interfacing with a payment gateway, both are perfectly capable. In assessing them as technologies for building your site, the only significant difference is the price. Try asking yourself “So how much does it cost to host this ASP.NET page I just wrote?”
4. PHP is not compiled, other than when it’s interpreted at runtime, whereas .NET enjoys all the benefits of being compiled.
Here’s news for the .NET crowd — you’ve finally caught up! Microsoft’s use of the word “compiled” in regard to .NET is not what a C++ coder would call “compiled”. Zend, the corporate face of the PHP project, have been doing this for a while now with PHP Accelerator (for a free equivalent, try php-accelerator.co.uk). Unfortunately for Zend, they chose to describe what Accelerator does as “advanced caching” (read more on what Zend means by “caching”). For more technical detail, try this thread at SitePoint Forums.
5. ASP.NET has accountable support. PHP has none.
Apart from the support services offered by Zend (effectively PHP’s creators), NuSphere, ThinkPHP and other corporations also provide support for PHP. You don’t need it, thanks to the ever-expanding PHP community being what it is, but if your boss wants someone credible to blame, there’s more than enough choice!
6. .NET supports multiple languages. PHP doesn’t.
Try Java for PHP or the upcoming Python extension. Obviously this isn’t quite the same as C# or J# but the point needs to be made — PHP is very flexible, and offers useful solutions for the Internet. Don’t expect to find yourself to be writing a successful Website in Cobol.NET — it’s likely each .NET language will eventually “tune in” to a particular type of application development.
7. Language.NET has superior object orientation.
For those who know PHP and its limitations, you may be amused by this .NET FAQ — sound familiar? In fact with PHP 4.3 in the wings, it may be that PHP can claim superior OO support, when you consider that FAQ.
What is significantly different is “Language.NET” will force you into an object oriented approach from the start, while PHP won’t. The Web typically does not require OO — for your average dynamic Website, a few “hacked” scripts are perfectly fine if they meets the site’s requirements. Deliver a live site now, rather than a beautifully abstract piece of code that’s ready one year after it’s needed. Paraphrasing SitePoint’s recent interview with Rasmus Lerdorf, PHP’s down-to-earth approach to problem solving is what has made it a success. And when you need OO, it’s there waiting for you.
8. .NET offers superior templating and web development features.
Microsoft has come up with some nice features with .NET that are certainly enticing, like the datagrid, and the templating mechanism. But you could easily reproduce these with a little PHP (try DaDaBIK, for example).
The basic notion of templating is to separate logic from content, so those with artistic skills can make a site that looks good, while developers apply the code “behind the scenes”. How Web designers feel about working with .NET’s templating system remains to be seen. With PHP, rather than being forced into a single approach, you have the choice of numerous Open Source projects (Smarty, Pat Template, etc.).
9. But corporations don’t like PHP.
Well apart from CBS, PHP is used on the corporate sites of Japan’s NTT DoCoMo, Switzerland’s Bluewin, and a whole load more you’ll find here. You frequently wont realise when you’re viewing a PHP-based site, because you’re not forced to use the default .php file extension (PHP often appears as .shtml or phtml).
Also, have a look at the results of this job search — not bad.
10. PHP is doomed!
This is doubtful. In fact in June 2002, PHP overtook ASP to become the first Open Source project to start from behind, and become more popular than the bespoke Microsoft solution. With IIS going into decline against Apache as a result of the Apache 2.0 release and IIS’s poor security record, the gap will only widen.
The .NET framework has only one real edge over PHP, which won’t be making itself apparent for a long time yet: with .NET, you can write an application that will run natively on Windows clients and is delivered from a Website. Microsoft has a long way to go with security before it will be able to unleash that on the Internet — and even when that time comes, browsers and content delivery may be sufficiently advanced to make it irrelevant.
PHP is successful in its own right and in fact is in no way “threatened” by .NET. As to why, your guess is as good as mine, but top of the list might be:
- its down-to-earth approach to problem solving (PHP has without doubt introduced to programming people who would never have thought themselves capable before),
- its active and inspired community,
- its comprehensive and efficient documentation (try this link for example: http://www.php.net/mysql), and
- the freedom you have as a developer, both in terms of price and choice of code architecture, to do with PHP as you please.
Microsoft would do well to learn some lessons here. PHP.NET would be a start but at the moment Microsoft seems to be ignoring the Internet’s #1 scripting language.
Business as Usual
So there’s a little ammunition for harassed PHP developers. In summary, although .NET has some interesting features, there’s no pressing reason to switch to developing in it. Right now, in terms of web development, Language.NET really only amounts to ASP version 4.0 (with an option of writing in C++ style C#).
If you’re considering Language.NET, it’s worth asking yourself three questions;
- “Is there anything here I’m not already doing or capable of doing?”
- “Do I want to be forced into a sharp learning curve, a particular coding style and particular strategies for Web development?”
- “Do I feel like paying more for hosting?”
In answering those questions, you’ll have a pretty clear idea whether .NET applies to you. And rest assured you’re not “missing out” if you decide it’s not your kettle of fish.
Having said all that, .NET framework is an interesting technology. It incorporates some great concepts, such as multiple language support and has potential for seamlessly integrating the various Microsoft product families. It’s also good that .NET promotes XML standards like XML-RPC and SOAP, which have tremendous potential for the Internet and until recently, have been largely ignored, although XML-RPC has been around since 1999. But there’s a long way to go though before .NET is truly a pervasive technology — and the real showdown for the hearts and minds of developers is not “PHP vs. .NET” but J2EE vs. .NET, which is best left to another article.
All in all, we can now get back to business as usual, while thanking Microsoft for the diversion.
Hear both side ot the argument! Find out why the opposition thinks .NET is superior, and make up your own mind!