prosperwebsolutions.co.uk
8 Bennington Street
Cheltenham, GL50 4ED
T 01242 808413 | online enquiry form

Blog

<November 2008>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

Top Stories

Archives

 Tuesday, September 09, 2008

Microsoft ASP.NET vs PHP (Open Source) Aftermath

After I have stopped using PHP for few years and started using just ASP.NET. I must admit I was astonished by the power of the language, the use, the ease and just beauty of it. For many years I kept using it. But somehow, I came back to PHP a few months ago, I have gone through hundreds of sites, gone through hundreds of code examples and generally I wanted to see what happened in the technology and how PHP has grown over the years. PHP 5.2 was a major release in PHP so I wanted to compare PHP 5.2 with ASP.NET 2.0. I want to put all bias away and just focus on facts.  Lets begin.

History

PHP – Developed  by Rasmus Ledorf in 1996, originally called Personal Home Page. Was written to solve simple Web Development problems, library was written in C. It has read html, and looked for comment tags such as <!--  --> ,  it has built virtual variables and looked for commands and then execute everything in C mode and just outputted html back. To be honest not much has changed, just that a lot more people contributed to this technology. Such as a Group of students from university have called Rasmus and have asked if they can help in building better debugger and interpretation engine to speeds things up. By version 3 a few people have been involved, however Rasmus was still doing a lot of rewriting and was still leading the project.  

Main idea of PHP was too solve a wide problem, to be able to write web based applications quickly and dirt free. So people wouldn’t have to write their own C libraries.

ASP.NET – Research began in 1997, main idea was to find the way to write clean code where the logical layer would be separated from the presentation layer. It wasn’t until January 5, 2002 language was released. It came together with windows 2003 server .NET Framework 1.1 . Original name for ASP.NET was XSP. There is no clear reason for its name.

http://www.asp.net


Popularity

graph popularity

(This graph was provided to you using compete.com)

This graph shows the amount of hits php.net and asp.net are getting. What we most not forget is that PHP.NET also contains documentation for their code, where ASP.NET contains tutorials, open source projects, news, etc.

PHP - There is no doubt that PHP is the most popular language on the web, one thing that you must consider is that PHP has been around for much longer. It had more time to test, debug, and grow. It is open source and hundreds of programmers all around the world are contributing to PHP network, to places like PECL, and PEAR. This has attracted a lot of developers, who could write their own functions and then add them to sites like PECL and PEAR where they would then be reviewed and if they are liked then later on it would be added to PHP platform at the next release. This way PHP has grown, over the years.

ASP.NET - This language has got a massive edge, because development team had a lot more time to research and think of the things they can do. They had more time to come up with IDE (Runtime Environment), one other thing that they had was a budget for research and development. ASP.NET simply had more time to plan their technology, to see what tools and features would be good to use, what language should they choose and offer to programmers who are going to use it. It was a very smart move to go with Java syntax, as it is clean and is very robust. They wanted to target different markets, Visual Basic Programmers, and more serious programmers with C#.


Scalability

PHP – this language has a share nothing culture, and each page runs as a separate entity to the whole thing. Which means that there is no problem with scalability as at all, as long as you have enough hardware, and code is written more or less well it will run fine with hundreds of visits a day. When it comes to more serious large scale websites such as facebook.com, and yahoo.com. Then you need good PHP framework that was developed within your company or that you have used from open sources. Also you need load balancing, with a good database at the backend we will talk about this later on.

ASP.NET – This language is a bit different, it does share some resources. It also has application pool, which shares memory, number of requests, etc. This was improved greatly since version IIS5. When it comes to scalability it is once again more or less a about good software engineering practices and correct hardware configuration.

This is really an arguable case, and once again no one can really prove anything. As long as there is correct infrastructure in place and right hardware both languages will scale well.


Database

DSO – Development Started On
OVN - On Version Now

MySQL -  (DSO 1995) -  (OVN 5.1) – This is one of the most popular databases that is used with PHP for all sorts of websites. MySQL is quick, efficient, and is not clunky. However it is terribly slow when it comes to Sub Queries, Stored Procedures, and when other complex features come in to the play.  However, when it comes to straight forward data handling and storage it is a great system. From my personal experience, I didn’t have such a good experience with this database. Some of our agencies clients are using this database and they are fine, however when we have used this for scale applications such as Moodle and systems that really do grow. Time from time, tables fail, and you have to run recovery scripts to fix tables. However what you must remember is that this can be caused by hardware.

MySQL main focus was speed, and performance. When the project was started developers whee not focusing on complex tasks of sub queries and data calculation. They have focused on Speed, Speed and once again Speed. Great thing about MySQL that it supports replication very well.

Sun is working together with the community on this project and is now making certain factors of this database no longer free. For things like MySQL monitor, system that lets you know

http://www.mysql.com

PostGresSQL - (DSO 1986) – (OVN 8.2.9) This is my number one choice for database behind the PHP, reasons being, is that Postgres was written to handle complex sub queries, store procedures, to create dynamic views. When this database was being written it well documented, and bug mass bug reports have been written, which caused a lot of re writing to fix the database issues. At the end of all that hard work, the system gained respect for stability, and astonishing performance. One of the great things about Postgres, is that when you do INSERT statement, after you have inserted a record you can actually retrieve the id for that record straight away, where with MySQL it is not a fact that you will retrieve back that ID.

http://www.posgres.com

MSSQL SERVER – (DSO 1989)  - (SQL SERVER 2008)  I have to say that this is a great database and I would recommend nothing else to use with ASP.NET, the data model structure, and just easy integration with ASP.NET 3.5 and SQL SERVER 2008 is simply remarkable. One thing that has confused me, is that they are doing comparisons on their website of Oracle, MySQL and DB2 from IBM. However they left PostGres out. I Wonder why (wink, wink). To be honest looking at their website I am amazed that they have been allowed to even write half of the stuff that they have written about other products out there. But hands down, they are good when it comes to data integration with ASP.NET I can’t say anything there.
I am not going to talk about Oracle, I am sorry to all oracle fans out there. However that database is legendary and deserves a saying, so I will say few shorts paragraphs about it. No matter what any one says, oracle is powerful, it is massive, and it powered the world. That database is simply unbeatable. However it is failing in a few areas. Such as not having a good graphical interface, not having easy installation facility, and easy connection with ASP.NET. You have no idea through how much trouble I had to go through to find Oracle adapter to work with my ASP.NET applications. Remarkable database, but it is so big that it is struggling to keep up.


Performance

When it comes to this, you can’t simply argue this case. It is all about how the programmer builds his applications. If someone builds a faulty application it will run badly in ASP.NET and PHP. For all we care you can write a really bad HTML page and even that will be slow!

You must remember, that if you are a good software engineer, you will write efficient code. I will talk about efficient code in a second. However, I would love to show you graphs where it shows ASP.NET is faster then PHP or where PHP is faster, however I can’t! Simply because of 1 reason, and 1 reason only, you simply can’t compare them in performance.

I can’t run a loop in one program and then do the same for the other, why? Reason being is that PHP will be much faster that is given, ASP.NET will need to load all of it classes and all of it events. While PHP just needs to look, load it compile it. I might be wrong and ASP.NET will be quicker. What you must remember is that is that ASP.NET might not be quick at loading a loop up, but it will be quick at ensuring native ajax is plugged in. it will be quicker in ensuring that controls are simple dropped in. It will be quick when it comes to compilation because it is compiled using Windows .NET Framework that a lot of applications are running from.

However, when it comes to PHP, it will be much faster if it has modules and plug-in cached in APC (Alternative PHP Cache).  If programs are written smart and are written using efficient methods.

I will be honest, and will give quick tips to you all, it is not all in ASP.NET or PHP where performance usually lies (if you are experienced developer, plan, and implement according to a correct model) Performance usually lies in a database connections. Make sure that you place index fields, full text fields and don’t do SELECT *, but select fields you need. Make sure that Query catching is on. Pay massive attention to your database setup.

I can go on all day long about this, however, please read the following articles.

For PHP:

For ASP.NET


Corporate Use

It is shocking how much of a fire fight there is about this topic, mainly because both languages will do just as good a job if implemented correctly.

I have seen some amazing frameworks that have been written by me and my team in PHP. Frameworks that allow you to create web forms that talk to a database, delete, edit, and calculate. Written in matter of minutes, by using cleverly created Classes in PHP. I have seen amazing structures being written, for example recently we have created PHP Live extensions that enabled you to write native PHP code and It would work with AJAX without any add ons. This was based on ASP.NET AJAX model, I have to admit. We are looking to make some of this code open source over coming months.

I have to say use PHP if you want to create a really large scale application that will go beyond normal websites. Only do this if you have a good architecture in place and a skilful team. Otherwise really big projects in PHP can be a disaster.

I have to admit and say that if you want to write a web application quickly, with little hassle, and this application is not going beyond a normal. Then stick with ASP.NET. This language is powering lots of different businesses around the web, reason being that it is using universal business model and it is simply amazing. You can hire any C# develop to take a look at another’s guys C# code and he will say “hmmm, I see what he has done, I will work wit that”, what happens when you are working with PHP is “hmmm, I see what he as done, but I think I should re write that”. This is because PHP has no framework it is a wild child, and because it is such a wild child it is so great because things that PHP can do can go beyond anything that ASP.NET can do, but if you don’t have a correct team in place and don’t have really good coders who write documentation will it will be a road to hell?


Method

PHP

ASP.NET

Robust

YES

NO

Easy To Maintain

Depends on team

YES

Scales

YES

YES

Talks To Any database

YES

YES (some adapters are buggy)

Wide Support

YES

YES

Staff You Can Employ

There are lot more PHP programmers

At this point in time market is crying out for more developers

Performance

QUICK (Depends on configuration)

QUICK

IDE Available

YES

YES


IDE – Integrated Development Environment

Now this is an interesting topic, as ASP.NET Developers have amazingly well developed IDE called Visual Studio 2005 and newly released Visual Studio 2008, which providers you with amazing debugging environment and writes half of the code for you.

http://www.microsoft.com/Express/

However! NetBeans IDE 6.1 – Early Access For PHP has been realsed for a while now, and I have to say it is just as good as Visual Studio, you can debug in real time, it corrects your code, and amazingly improves your documentation on your code,  when you define your objects and provides you with the methods with in your objects, so overall, it does exactly same things as Visual Studio does, apart from it having drag and drop facility for controls, but PHP lovers don’t worry, I am sure that is already being developed (my team is already doing this on our projects).

http://download.netbeans.org/netbeans/6.1/final/

Please do take a look at this, as it is worth 5 minutes of every developers time! This is where evolution of PHP is happening.

 

Server Configuration

This is another hot topic, I am going to get right to it. Use Windows 2003 server if you people who can support it, or use Linux if you have some who can support that.

Answere is simple, honestly there is no difference between Linux or Windows server, infact it is known that Windows 2003 Server runs PHP better then Linux.

PHP - Recommend Server Configuration for large scale applications:
Windows 2003 Server or Linux (depending on available staff to support your systems)
Apache (static installation)
PHP 5.2
PostgresSQL

PHP - Recommended Server Configuration for small scale applications:
Linux
Apache
PHP 5.2
MySQL

ASP.NET – Recommended Server Configuration
Windows Server 2003 or Windows Server 2008 (wouldn’t recommend, as it just came to the market)
IIS6 or IIS7 (wouldn’t recommend as it did just come to the market)
.NET 2.0
.NET 3.5
.NET 1.1
SQL SERVER 2005 or PostgresSQL (adapter is available natively with the install of the PostGresSQL database)

If you have multiple servers then you will obviously will need replication setup, all systems will deal well with that, however, to be honest it is all about choosing a right tool for the job, and ensuring that you are configuring it correctly.

http://en.wikipedia.org/wiki/Replication_(computer_science)


Conclusion

In summary, I can go on all day long. I am going to close my article now, by giving more web links and things to read up on. Also I will say the following:

It is no secret that CIA and GCHQ, and other secret intelligence are using Redhat Linux, and it is safe to assume that they are using PHP with Oracle or PostGres.

Facebook.com one of fastest growing community sites is using PHP, and are growing massively. They have added technology called APC to the PHP framework.

Yahoo.com one of other massive sites who are using PHP architecture, and have been using it for years and years, their backend database is PostGresSQL and they are storing 2 petabytes of data!

Moodle.org virtual environment for education is using PHP for they system, and Open College is using that platform, and has re written half of it.

All of these massive places are using it, and I will tell you why, because you are not restricted by Microsoft, you don’t have to rely on them. You rely on your self. If you are writing the next big thing, use PHP.

I am being slightly bias here, as I love ASP.NET, I can’t get enough of it, but I am afraid that ASP.NET is simply growing to quickly, and not all developers will be able to keep up with their technology. They are putting all these people in to these frameworks that people have to study and understand. Yes it is great, however, it requires more education and more top skilled developers, and this is great as we are going to have better programmers out there who will write better code.

However, this is still business, and in business we are looking at speed, and it is a hell lot faster to write a PHP website with a  nice PHP framework that your team has written than it takes to study Microsoft’s ASP.NET framework. Also consider this, although not everywhere yet ASP.NET servers are available and popular in USA and UK, but think about Russia, Ukraine, Latvia, Poland, Estonia, think about all these countries. And remember that a lot of top developers are coming from there. All those guys love to see is Linux, a lot of developers there are Linux based, think about it, even in China. So it is hard to say.
Conclusion is that both languages are amazing in their own way, but there is no clear winner. I will say this:

If you are looking to build a community site, such as facebook, blog systems, search engine, e-commerce modules. Things like this, built them in PHP.

If you lets say are in mortgage business or you are a bank, write your systems in ASP.NET, 70% of these type of corporations are running on SQL SERVER 2000 and higher. This means that with ASP.NET there is easy integration. Your team will write software that will deliver results in hours and it will be easy to maintain and you won’t need to worry as any C# developer will be able to pick it up.

However if you are writing something that is not really corporate and it is more of a community thing, then use PHP. There are less limits, less walls, easy error handling, lots of Open Source projects where you can take code from and just work on. Simply more possibilities! This is why facebook.com, yahoo.com, and other large scale websites are choosing this language.

Verdict:

PHP is for Community, ASP.NET is for corporations. What category your business is in? That is for you to choose!

I would like to thank you for reading this article, it was written by Zan Kavtaskin Director of Web Technologies @ Prosper Web Solutions

Tuesday, September 09, 2008 7:30:49 PM (GMT Standard Time, UTC+00:00)
^ Skip To The Top