29 May 2008

Which one to choose from .NET or PHP?


Today I found a good article on which technology to choose or suggest among .NET and PHP, its detail is given below:
Reasons why one might choose one over the other can include: The cost of development tools, or availability of such tools, or even ones comfort level with the Open Source initiative.

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.

And as ezPublish demonstrates, corporations aren't just using PHP, companies like Siemens are prepared to go into partnership to sell PHP applications to their customers.

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;

  1. "Is there anything here I'm not already doing or capable of doing?"
  2. "Do I want to be forced into a sharp learning curve, a particular coding style and particular strategies for Web development?"
  3. "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.

No comments: