tags:

views:

2212

answers:

20
+22  Q: 

ASP.NET vs. PHP

What is the biggest advantage of ASP.NET over the PHP. Why should I switch to ASP.NET?

EDIT: I just want to understand the point behind the Joel's example: If ASP.NET is a Lexus, then PHP is a bicycle.

+43  A: 
  • Visual Studio.
  • LINQ
  • The ease with which you can convert an ASP.NET application to a desktop client, mobile or webservice - if designed correctly you just provide a new presentation layer. This isn't possible with PHP.
  • The sheer power and elegance of C#.
  • The integrated nature of the technology stack - CLR support in MSSQL Server for example.
  • PHP is an interpreted language - ASP.NET is compiled
  • The framework class library
flesh
I would also note, that when coming from client development, you can develop using the same language (C#)And: You can also have PHP in Visual Studio - with VS.Php: www.jcxsoftware.com
Sebastian Hoitz
Just because most PHP applications haven't been developed MVC-style, doesn't mean it's not possible. (well, desktop PHP applications sounds like a bad idea, but mobile/webservice/web by just adding a new presentation layer is definitely easily doable)
Infinity
pre-compiled and have a jit = just in time compilation, its almost a script with binary opcodes that the virtual machine understand.
useless
+2  A: 

It is all a matter of preference. We do both PHP and ASP.NET

I feel better doing ASP.NET with C# as I like the syntax, the framework, etc. PHP has still a more scripting-like feel to me.

But again, it is a matter of personal preference.

Try out both?

postback
To me, any scripting language is a negative, not a positive. But I understand and appreciate your point.
pearcewg
+6  A: 

As a user of both, I love the Forms nature of ASP.NET (e.g. being able to reference the text of a textbox with mytextbox.text in the code. If your application contains lot of data entry then .NET makes life much, much easier.

I'm also a big fan of Master pages and theming, features which can be replicated in PHP, but its nice having it out-the-box.

Adam Pope
Forms is very easy to start with but gets in the way later. It doesn't follow any best practices in web development, but tries to make it look like desktop development. When you start using postbacks a lot, and every resource doesn't have a URL it sucks. Hence ASP.NET MVC. But again it all depends.
Slavo
+14  A: 

As a recent convert from PHP to ASP.Net, my 'likes' are: Linq, Workflow, built in AJAX support, events, a more consistent internal framework, MVC, and in general having most things right there without having to resort to trawling multiple websites for add on functionality.

In addition to the above, the Membership Providers functionality that ASP.Net brings to the table is simply fantastic in itself for simple websites, ViewState is a godsend in most situations, and being able to bind datasources to controls rather than having to populate drop downs manually etc.

I'm sure I will be adding more as I think of them.

Moo
+5  A: 

Throwing a little fuel on the fire here... VS.Php

joseph.ferris
I used this VS.PHP plugin in a desperate attempt of mine to tackle PHP and I (along with the plugin) failed miserably. I really have put my faith in it since I could reuse World's #1 IDE : Visual Studio.Well.. as a friend says : in shit life happens (and the other way around...)
Andrei Rinea
+3  A: 

visual studio is a good answer, dot notation language (C#) is another

imho it's not really a choice you have to make, it depends where you work - LAMP shops will continue to use PHP generally, MS shops will continue to use asp.net, never the twain shall meet

you probably need to learn both to a some degree to be a really handy web-dev

edit: I have to say a lot of the things people cite as advantages (built-in ajax, controls reference server-side) I actually find to become ever more of aproblem the deeper you get into asp.net, where php offers no help in these areas it also doesn't get in my way

annakata
I work at a company that currently does all web development in PHP (with a couple of legacy ASP.net sites) and a lot of desktop development in C#. So it is possible that you'll find the two technologies in the same place, although it's probably rare.
Neil Aitken
A: 

I'm an ASP.Net guy myself. Strict typing, the code is separate from the html and can be compiled into assemblies so you don't need the code on the server.

And, of course Visual Studio is an awesome tool - even the free version.

Monodevelop is coming on too - the latest alpha has intellisense for ASP.Net which is hopefully all I'm waiting for before I can switch for my personal programming.

There are a couple of problems with ASP.Net - watch out for the viewstate etc but they can be worked around pretty easily.

DanBrad
A: 

Strongly typing, a HUGE source of Open Source libs to use, OOP (truly OO programming) which makes it far easier to use these 3rd Party libs and many more...

My favorite though would definitely be that you get to use Ra-Ajax ;)

PS!

When that is said, I think this was a very mature thread. I don't think I've ever seen someone ask questions like that without starting a war...

As in; Nice work Jeff and Joel ;)

Thomas Hansen
+6  A: 

As a develper who has had experience with both ASP.Net and PHP I greatly prefer to develop with ASP.Net. I will only develop using PHP if I absolutley have to (due to hosting restrictions, or because it is legacy code).

The crux of the matter is that ASP much more feature rich when compared to PHP. When developing in PHP I feel as if I constantly have to reinvent the wheel, and have to concentrate on how I will perform tasks instead of what I am trying to do.

.Net allows you to focus on the problem you are trying to solve rather than how you perform the steps involved. This is what rapid application development is all about.

A very good example would be the data access features introduced in VS2008 (LINQ to SQL, LINQ to XML, Entity Framework). All of these technologies provide a very rich experience for the developer, giving them a visual representation of their data model and making it very easy to maintain.

There are so many compelling features you can take advantage of when you move to .Net, you really need to try it out!

Regards,

Docta

DoctaJonez
A: 

I'm working for a PHP shop and one thing I seem to spend a lot of time on is form creation / user interaction with the form. I'm not talking about backend stuff just the frontend stuff. From what little I've played with ASP.net I want to switch so bad just to cut down on the time I have to spend writing forms.

smack0007
Use a form class.
Mario
+8  A: 

If you compare baseline PHP to ASP.NET the MS product is way ahead. If you add a couple of frameworks like Zend, Doctrine and PHPUnit to the php stack, the scales will tilt the other way.

I, personally, like PHP a lot more than ASP.NET (being both an ASP.NET dev and PHP) - PHP has dynamic typing - no casting and type errors - PHP has a lot of libraries with it. If thats not enough - consider looking at pecl for more. - PHP is OSS

I'm not considering language performance since I believe productivity has a much higher priority than it.

"no casting and type errors" - until runtime anyway!
Simon
A: 

And there's always Phalanger, which allows you to compile PHP code to run on the .NET Framework. I've never used it, but I'm assuming that you can use it to make some kind of web app, and perhaps integrate it with an ASP.NET app.

If this works the way I understand it, you might not have to switch from PHP at all to make ASP.NET applications.

Thomas Owens
+1  A: 
Mischa Kroon
+10  A: 

The bicycle metaphor:
PHP is a scripting language it's easier and faster to pick up.
You can just get on it and drive to where you want to go. Sometimes when you have to drive further, you want something which drives faster and gives you a bit more comfort while driving.

.NET can deliver this :)
The why's of that statement you can find int the other answers.

Mischa Kroon
A: 

Of course you could always look at the article entitled "Does Visual Studio Rot the Mind" by Charles Petzold (http://charlespetzold.com/etc/DoesVisualStudioRotTheMind.htlm) Charles Petzold, you will no doubt remember was a major writer on Windows topics.

Alan

apolinsky
You have a typo in the link. Here is the corrected link:http://charlespetzold.com/etc/DoesVisualStudioRotTheMind.html
Giovanni Galbo
+1  A: 

Some additional thoughts: I have the same question, I've worked with asp.net 1.1 and 2.0 and php4 and 5.
Php there are many libraries and frameworks and it takes much time to choose which one to use. Many of asp.net's features are present in Zend framework (example, there are many others). Also Zend Studio (or eclipse) have many elements that people like in visual studio. The thing is that choosing needs time :-(
The biggest consideration for me is that by choosing ASP.net you start to go in a place where all things are (or becoming) Microsoft. Asp.net equals Visual Studio this means Windows as an OS, better integration with SqlServer, etc. Or that a open source tool you use may just... die because newest VS has something similar integrated (adding to the list of things you have to relearn).

dimitris mistriotis
A: 

The Base Class Library blows the PHP Class Library out of the water.

PHP is not bad and it certainly gets the job done, but you can clearly see it's organic growth:

  • There is no common data access layer. While .net essentially always uses ADO.net (even LINQ uses ADO.net deep down), for PHP you have to use completely different methods every time to access different databases. Sure, there are third-party solutions but nothing is built in.
  • Bloat. mysql vs. mysqli
  • Lack of consistency. I think the List of Array functions says it all.

This is maybe more of a perception of myself, but I have (had to) changed from PHP to C#, and I would never ever go back. PHP seems like a loose collection of functionality without any direction or consistency, whereas .net looks a lot more planned out. Visual Studio is better than Zend Studio (have not tried the Eclipse-based one yet though) and Debugging with PHP is a PITA. (And no, var_dump/print_r is not real debugging, and neither is response.write in .net)

On the other hand: .net usually requires a Windows Server, which immediately makes it a lot more expensive in terms of initial cost.

Michael Stum
+2  A: 

Many people think they know PHP when in fact they dont. So their code is wrong/slow/insecure and they recode a lot cause they dont get the right tools/frameworks for the job.

Its easier to do the right thing in ASP.Net and most other comparable languages, and you get the default tools/frameworks right there.

OIS
+4  A: 

In my market, PHP programmers on average earn about 1/3 less than ASP.NET programmers. ;)

Not what the poster intended as an answer, but certainly important to me (as a .NET expert and professional).

pearcewg
What's your reference?
Ehsan
A: 

asp.net application are difficult to edit/manipulate.while php you can manipulate a lot.to do simple application asp.net might be okays for you while for advance application business logic ,i prefer php rather then .net solution.In php can generate complex application with dynamic sql faster rathen then asp.net solution mostly depend on store procedure to hide business logic.

That's not right... The way you hide your business logic has nothing to do with the language or platform you are using, so in the topic of your answer there is no difference.
TomWij