Friday, October 19, 2007

PHP vs. dotNET

Ahh, the age old arguments of PHP vs. .NET. I love how each side so vigorously states their opinions. But it seems to me that most people have only used one or the other when developing web sites and doesn't see so much what the other has to offer.


I spent about 7 years programming with PHP before moving to .NET as my primary programming platform. And I will tell you that anything I do for myself will be mostly done with .NET. That's not to say that I still don't have a place in my heart for PHP, because I do. I still do some work with PHP as well from time to time.


You can follow the blog post that prompted this at the end of this post to see what that author has to say. But I would like to offer a few of my own thoughts here from my own personal experience.


My work with .NET is done 90% of the time using C#. I really don't care for VB.NET and feel that it is entirely too verbose for programming. Plus, having learned to program with C++ and spending years with PHP, the syntax of C# was closer to what I was used to. I like the way that C# is strongly typed, as it certainly helps the compiler find errors when working with the code. Of course, proponents of PHP will say that loose typing is one of the great benefits of PHP. Yes, you can cast a variable as a specific type, but you're just adding to the your code every time you want to add two variables together to ensure that both are integers, or string for concatenation.


The problem with the loose typing that PHP offers is that that same looseness limits the ability of PHP to be used well in an OOP setting. Now I know that PHP5 has come a long way toward allowing classes to be extended and has interfaces and abstract classes, but it still doesn't have the ease of use that .NET does for OOP programming. One of the biggest issues with PHP is that it doesn't allow for function overloading in classes. Come on PHP developers, this kind of functionality has been available in other languages for decades. PHPs OOP abilities also doesn't allow for namespaces, which certainly helps to ensure that you aren't colliding with other objects. Again, this has been available in other languages for a long time.


Many will say that PHP is excellent for putting a web site together fast. I really don't think that you can put together a CRUD application anywhere near as fast with PHP as can be done with .NET. After all, the GridView, FormView, DetailsView, etc of .NET make this a couple minute job everytime you want to add the functionality. Nothing like that available with PHP.


But I will give PHP a good nod for it's useful purposes. If all I had to put together was a quick form mail type script, then PHP would handle this much quicker. In fact, I could probably find several dozen pre-built PHP formMail scripts in the time it would take to build either a PHP or a .NET version myself. Of course, with the number of beginners using and releasing scripts with PHP, I would also be very careful before using one.


PHP is also a great language to help beginners learn about programming. There are a lot more people willing to help the newbie PHP developer than any other language on the planet. A big problem here though, is that there are a lot more people telling the newbie how to do it all wrong. I think a newbie would be better off learning about good OOP programming to begin with and that .NET would be a great place to start (Actually I think that smalltalk would be a better place to start, but we'll leave that for another day). I should add that Microsoft themselves has a wide variety of free tutorials and videos available to help with learning .NET too.


I know that there are so many more arguments available. I just wanted to get a few of my own out there. If you wish to discuss them, please leave a comment and let's discuss them.

read more | digg story