Fog Creek Software
Discussion Board

Head-to-Head: PHP vs. ASP.NET

You guys know by now that I do not realy like PHP for projects beyond the 1 or 2 pages of simple select ... from, right?

Just me (Sir to you)
Thursday, May 8, 2003

As someone who has used both PHP and ASP.NET (though I'm not primarily a web developer) that comparison is surprisingly fair, considering it was posted (presumably) to promote ASP.NET.

PHP is pretty nice for small to mid-sized sites, but I do agree the function names are a big mismash of inconsistent naming styles, and since there is virtually no object orientation in the base libraries, it can be a pain to search through the hundreds of built in functions for the one you are looking for.  ASP.NET, in my experience, scales a lot better to large projects and the variety of languages available for development is a real plus.

Of course one thing they don't highlight much in that article is that you can deploy PHP for free (free OS, free web server, free framework) whereas with ASP.NET you have to pay for, at a minimum, the base server-level OS it is running on (since you can get by without an IDE and just use the framework SDK to do development).  Of course this cost is meaningless to a big project, but for small mom & pop sites this cost can be a factor.

George McBay
Thursday, May 8, 2003

You claim that, in PHP, the functions are hard to find.

The PHP library is indeed a procedural one, and not Object-Oriented, BUT, except for very few functions, they all start with the group name.

For example, all the functions dealing with MySQL start with "mysql_", etc.

It is, in my experience, EXTREMELY easy to find the functions.

PHP has the advantage of richness - download the PHP help file (in .CHM format) and look at it. It's library is very rich. It can talk to a lot of e-commerce systems, databases, and do A LOT of things like create flash files on the fly, create PDF, send e-mail without requiring an external component like the old ASP did, etc.

PHP is a very, very rich language.

Also, the language itself is very cool - it is highly optimized for the way developers use it - for example, if I have a variable called $a, and I want to output it, I can even put it in a string:

echo "Here is the value of the variable \$a: $a";

Variable expansion does not happen with single quotes strings!

The container object (the array) is VERY powerful, almost like the Python containers!

There are many such optimizations, and the language is a pleasure to develop with.

On the other hand, ASP .NET has the advantage of a powerful RAD environment behind it. It also has components.

These things matter A LOT: no more writing code by hand to display and edit a table or a query result, for example.

So, I belive ASP .NET is superior to PHP because of the RAD environment. It is an advantage that is far more important than the other advantages of PHP.

Michael K.
Thursday, May 8, 2003

"PHP is a very, very rich language.

Also, the language itself is very cool ..."

I must respectfully disagree. I recently did a small website for a local nonprofit. An ISP offered free hosting, and they had PHP.

PHP isn't a rich language - it's a syntactical mishmash that happens to have a lot of libraries. None of which helped me, because our web host didn't have any of them installed.

I don't buy the "rich library" argument, because there didn't seem to be any of the really helpful things. Where's the libraries to help in generating forms? In validating input? If they're there, I couldn't find it.

The very weak OO support, plus the default "assignment is copy" semantics results in a language that's very easy to make mistakes in.

And there's NO DEBUGGER!

Chris Tavares
Thursday, May 8, 2003

I used to be an ASP programmer (no .NET) but after evaluating a number of technologies I switched to PHP3 (this was back in the day).  It was heads above ASP -- you could do things in PHP that were just plain impossible in ASP in a general hosting environment.

Those who say that PHP isn't good for large projects just haven't been using it correctly.  I have a project that's 5MB of source code an over 1,000 files.  It's very easy to maintain and is very object-oriented.

The biggest mistake I see is that people don't understand what do with all the PHP functions.  Most of the PHP functions should not be called directly.  For database access, you should be using a high-level object-oriented database abstraction.  For those used to using ADO, there is the excellent ADODB library for PHP.  PHP also comes with PEAR, which is a large class library for all kinds of operations.  PHP functions are mostly just loose wrappers around standard unix libraries (like the MySQL C client library, GD graphics library, etc).  This allows PHP developers to build the abstractions rather than rely on a built-in abstractions that would, in turn, just calls these library functions anyways.

PHP is not without it's problems (and I should know!)  Though I'm constantly impressed with the rate of development on PHP.  PHP5, which is well on it's way to being released, fixes a number of the architecture problems listed in the article and in this forum.

I do think that ASP.NET is an excellent platform and it fixes many of the issues that caused me to run away for ASP.  In fact, I'm hoping to get a consulting gig to convert an existing large-scale ASP application into an ASP.NET application.

The ultimate biggest problem with ASP.NET is Windows and IIS.  For general hosting, a unix/apache solution is far superior.  I would recommend IIS and ASP.NET only for projects were there is already a strong Microsoft software basis (like a web-frontend to an existing corporate backend).

Wayne Venables
Thursday, May 8, 2003

I'm not a big user of symbolic debuggers. Sure a stack backtrace is nice and breakpoints can help find well hidden bugs. I end up using mostly printf's or the local equivalent. Usually I make stand-alone version of anything remotely tricky so I can do the debugging on the component/function(s) alone. That's my approach with PHP as well. But if you need a debugger get Zend's I've heard good things about it and it's not that expensive at 195$ to 245$ for the IDE.

The functions do have an irregular naming convention. I've been following the developement of PHP for a while and they've been slowly renaming them as they go (although the "traditional" names remain.)

The attacks on the OO capacity of PHP are quite justified since the class in PHP4 they're mostly useful to manage the namespace. PHP5 will add much richer OO features as well as exceptions handling with try...catch blocks.

Also, there's a trend of merging the most popular optional library with the main distribution. Witness the early inclusion of the mysql client libraries and now gd (graphics.) PEAR is still maturing but that will add even more options to add external components.

Thursday, May 8, 2003

The latest version of PHP (4.3.x) includes a function to retrieve the backtrace of an error.  Very handy.  I have all errors automatically emailed to me with as much information as possible.  It's amazing the number of errors you can find and fix that way.

Typically, they don't like to include client libraries directly with the distribution.  GD2 was included because the library wasn't being maintained -- PHP developers had a large number of bug fix and enhancement patches that were not being added to library's official distribution.  I'm glad they did that, GD2 has been in "beta" since forever and there were always build problems with it.

Wayne Venables
Thursday, May 8, 2003

> I don't buy the "rich library" argument, because
> there didn't seem to be any of the really helpful
> things. Where's the libraries to help in generating
> forms? In validating input? If they're there, I
> couldn't find it.

Oh, yeah? And where is the native (installed with IIS) function or object, in ASP (non-.NET ASP) for sending a simple e-mail?

The answer is simple: In ASP (not ASP .NET), you have to BUY a third-party component to send a simple e-mail!

Also, let's say you have to generate an image (for a graph, etc). ASP contains absolutely NOTHING to help you with this. PHP contains a full and powerful library of functions which help you do that.

> And there's NO DEBUGGER!

There are MANY debuggers for PHP, which work well.

Just try ActiveState Komodo, or Zend Studio. I have worked with both, and they are good, solid debuggers once you learn to use them.

Michael K.
Thursday, May 8, 2003

>Oh, yeah? And where is the native (installed with IIS) >function or object, in ASP (non-.NET ASP) for sending a >simple e-mail?
>The answer is simple: In ASP (not ASP .NET), you have to >BUY a third-party component to send a simple e-mail!

Who cares? The discussion is on ASP.NET not classic ASP.

Arab who worships Camels
Thursday, May 8, 2003

Besides, you're wrong. IIS ships with an SMTP server, which can be drive by the CDONT COM objects from classic ASP with just a few lines of code.

Brad Wilson (
Thursday, May 8, 2003

> Who cares? The discussion is on ASP.NET not
> classic ASP.

Comparing ASP .NET with PHP is meaningless.

ASP and PHP are in the same generation of server-side scripting languages.

ASP .NET is the next generation, which has a RAD environment. This is, or has the potential to be a HUGE improvement in productivity.

So, comparing PHP with ASP .NET is like comparing Quick Basic 1.0 (the one that came with DOS) with Visual Basic 3.0.

There is simply no way to compare them - they are different things.

Will there be an PHP .NG (next generation) which will be equal to ASP .NET, or even better?

I don't really know, but I don't think so.

PHP is developed by a community of Unix / Linux / open source fans who don't seem to understand the importance of RAD.

For example, they consider that Linux has excellent develpment tools, because, look, it has GCC and Perl. :)

They are entitled to their opinion, but in my opinion, a superior development tool, in this day and age, MUST be a RAD one.

Yet, PHP is developed by people who consider that GCC + VI = a great development tool.


Michael K.
Thursday, May 8, 2003

<sarcasm> And, as we all know, nothing good has ever come out of all those projects that use gcc and vi.... </sarcasm>

:sigh:  Give me four terminal windows and vi over Visual Studio any day...and yes, I've used both.

Brent P. Newhall
Friday, May 9, 2003

Hey! I'm not saying you can't develop using GCC and VI!

But a RAD environment is a lot more productive, compared to that.

I know that RAD has a bad name among many programmers, especially because of Visual Basic, which has many problems, like interpreted code (no longer true in VB 5 and 6), crappy programming language, buggy components, etc.

But there are also RAD environments, like Delphi, C++ Builder, JBuilder, that don't have the disadvantages of VB, and are very cool.

ASP .NET is highly superior to PHP because there is a good RAD environment for ASP .NET, and that environment will be mainstream / used by most ASP .NET programmers.

Unless PHP gets a strong RAD environment used by most PHP programmers, it will fall farther and farther behind ASP .NET.

Michael K.
Friday, May 9, 2003

:sigh:  Give me four terminal windows and vi over Visual Studio any day...and yes, I've used both.

You know, even Bill Joy gave up on vi eons ago...

Friday, May 9, 2003

"ASP .NET is the next generation, which has a RAD environment. This is, or has the potential to be a HUGE improvement in productivity."

That's the crunch question. What ASP.NET gains on PHP in tools it loses again by being (apart from JScript which no one seems to be interested in) strongly typed. Put a (experienced) PHP coder with just a text editor and their prefered choice of PHP class libraries alongside a .NET coder and my guess is they'll be equally productive.

The .NET class library is excellent yes but PHP is not lacking in libraries of it's own, though not of the same scale, which do offer some of what the article claims PHP doesn't have. Also check out PHP based frameworks like eZ publish ( for an idea of how far well written PHP scales (e.g. - the guys behind

With PHP5 (probably 7 months away), aside from an object model which looks much like Java, PHP will have great interop, being able to access both the Java and .NET libraries (plus COM and even Python, Perl and Ruby (may be)) natively without additional layers like SOAP. So thanks MS for designing it. All that remains is a PHP parser to bind ASP.NET markup to the class library, which isn't so hard.

Anyway - .NET is a great technology but late to the game IMO. PHP effectively already is the "monopoly" solution for building dynamic web sites so there's plenty of time for perfection...

Wednesday, May 21, 2003

ASP.NET has a much better answer to separation of code and presentation than PHP does. ASP.NET web controls are a GREAT way to get reuse. PHP just gives you tag soup.

Chris Tavares
Thursday, May 22, 2003

I use PHP because there are plenty of free libraries and classes available for free using which you can accomplish pretty much anything. I don't feel like spending $100s on ASP components that are free for PHP.

Saturday, May 31, 2003

From a Marketing and sales perspective.

I would choose PHP over ASP as running a database driven website it is much easier to convert PHP urls's to search friendly data.

I have not seen anything for ASP to do this easily. :-)

James Tervit
Monday, April 19, 2004

*  Recent Topics

*  Fog Creek Home