views:

845

answers:

18

I have a couple of years as a PHP developer under my belt now, and I have to admit other web languages/frameworks (ASP .Net and Ruby on Rails especially) are looking much more tempting than PHP. It just seems like PHP is being left in the dust by the competition. I'm even seriously considering abandoning PHP altogether and going with Ruby on Rails.

So, my question is, why the heck should I continue to use PHP when it looks like other languages are taking giant leaps and PHP is just staying stagnant (more or less)?

Edit:

There are some things I really like about PHP. Like some of you have already said, it's ease of use and $0 cost are chief among reasons why people start developing in PHP, but i'm asking why I should continue developing in PHP.

I really believe that in the attempt to make PHP easy to use, it has some built in features that can give you some really bad programming habits. For instance, I see alot of duplicate code that is peppered across multiple files because each page needed the same behavior.

+16  A: 

why the heck should I continue to use PHP

Because the infrastructure (server …) that you need to deploy to only supports PHP, or you need a PHP-specific library. This is quite a common scenario, especially if you're developing software for a widespread audience and have little control over the final working environments. PHP ensures maximum reachability.

Apart from that, I'm really struggling to think of anything. I'm with Jeff on this subject: PHP sucks […]. And yes, that may come of as awfully biased, I'm aware.

Konrad Rudolph
A: 

Frankly, in my domain Python offers a lot morethan Ruby, especially if you integrate it with pyQT .. you can do web and desktop apps using 90% of the same code.

I stick with php for small projects. I built a small CMS a few years ago, that i keep updating and working on. That said, Facebook and digg.com use php, and it seems to work fine

dassouki
Exactly my point, if it is so bad, why does facebook use it? They have the budget to use any language and yet they choose PHP, I highly doubt facebook uses PHP because it's free.
jasondavis
+10  A: 

PHP is supported by virtually every web host. Also most of the other technologies (Python, Ruby, ASP.Net) don't handle well on CGI or require persistent processes. In terms of cost PHP is easy to support and has a plethora of scripts people can use "out of the box".

envalid
+1  A: 

Read this: http://www.oreillynet.com/ruby/blog/2007/01/php_vs_ruby_on_rails_an_evolu.html

It's a little story about a guy who may have gone through the same thing you are, and he gives some real comparisons between the two (PHP and Ruby [on Rails]).

Cory Larson
i don't find many insights and real comparisons in this story
ax
I read the page too and it did not give me any insights either - except for the flame war in the comments where there was a lot of name calling going on.
Peter M
+2  A: 

We use php because some of our clients insist on it. Be it hosting concerns or they want us to build on top of an existing software component (cms, forum, blog engine etc).

vise
+7  A: 

True, PHP may encourage some bad programming habits, but it does not force them. I'm sure that you, as a professional programmer, can exercise self-control and code using best practices.

PHP is also very fast. Facebook, among other very large websites, uses PHP. Look at the trouble Twitter had a year or two ago. They've been migrating their system from Ruby/Rails to other languages so that their site can keep up with the load. Ruby is a beautiful language, but that beauty comes at a cost. It cannot match PHP's efficiency.

Also, PHP is not falling behind at all. The language has a lot of problems, but those problems have been getting better, not worse. Each release brings more fixes, more consistency and better design. 5.0 brought a tremendous boost to OO design. 5.3 even has namespaces. The PHP project is definitely moving forward.

Lucas Oman
TRWTF is that it took them until 5.3 to add namespaces, after dumping everything on a big heap. No way to fix that without breaking compatibility big time...
Thorarin
So you probably complained before that PHP didn't have namespaces, and now you complainn that it does? Would you prefer that they were never added? My point is that the language is improving. I didn't make any claims about the speed of that improvement. And porting to 5.3 will be trivial. Mere namespace functionality won't break any existing code.
Lucas Oman
I wouldn't say that PHP *encourages* bad habits, it's just that it *allows* it. As someone quite seasoned with PHP, I'd take that flexibility as a plus.
nickf
A: 

We got to the point you are, and went on a language hunt. At the end, we arrived at a very unique point:

  • PHP on the front end
  • Nice (python) app server in between
  • Python on the back end

We ended up with the strong points of both languages, with few to none of the weak points. All of the UI and interaction is implemented in PHP and all of the Business Logic, Database Work, classes, and back end stuff is written in python.

gahooa
How is the communication between the three parts managed?
Ikke
A python application server listens on a UNIX or TCP socket. When a connection comes in, it checks the worker pool (a python set) for an active worker. If the worker is active, it passes the data on to the worker (over sockets) and waits for a reply, which is forwarded back to the requester (PHP). That's an over-simplified version, because it handles cross-project requests (like having a single EComm API and database for several projects).
gahooa
+7  A: 

I'm not a pro web developer, but I continue to use php because it Gets The Job Done. Until it doesn't Get The Job Done, I'll use it.

Paul Nathan
The key word here is: “better.” Other languages get the job done as well. Heck, even Cobol would get the job done (after a fashion). That's no argument.
Konrad Rudolph
I didn't mean, "after a fashion". I meant, php is very good at hacking a web site together fast, with minimal pain. I can get the job done without worrying about esoteric protocols or ensuring that my class hiearchies are correct. I just blat out what I need to and voila, it's there. MySQL integration is very good as well. You can argue that "hey, that's not enough for a serious website". Sure! I'm not a pro web developer. I don't write serious websites. I use PHP as a Personal Hypertext Processor.
Paul Nathan
On one hand - yes. But the problem with PHP is - it's hard to write the code /correctly/. So that it can handle all the cases, weird input data, unexpected error conditions, etc. When everything runs, it's fine. But when something goes wrong, your PHP app will come crashing down on you and you won't even know how, why and where. And even if you try to design your application to be fault-tolerant you will find that it's a sphagetti-type nightmare. Some functions return error codes, some throw exceptions, others require an error handler if you want to handle their errors, etc...
Vilx-
A: 

The whole web idea is about openness and freedom, so I personally welcome more and more web technologies because it keeps the innovation by competition.

PHP is a very important web technology I think most of other web technology were inspired in some parts by how PHP got adopted in so many applications (especially community applications) and how both designers and developers can start hacking their way into making an application.

I also think technologies such as ASP.net will add support to this kind of hack development to speed up prototyping, so I expect PHP to stick with the web for the next 10 years or so.

bashmohandes
+4  A: 

Because it has a lot of advantages over all others languages that are doing the same: web development.

  • easy to learn
  • easy to develop
  • complex enough for most task ( facebook is not the most complex )
  • easy to host
  • good community and support
  • free
  • etc.
Elzo Valugi
Well, all the points you cited are well covered by other products, such as Ruby (on Rails), Perl and Python. How do they single PHP out?
Konrad Rudolph
@Konrad. It's a subjective question. And all* of his points are subjective. He is saying from his perspective, PHP is better at all those points.* Free, is technically not all too subjective.
Jeff Davis
+2  A: 

PHP still has a ton of advantages.

Besides the other things mentioned. It's great for "getting things done". Need just one tiny bit of dynamic functionality on a largely static website? Bang...a little php to fix things up.

I like it because it doesn't force an object oriented convention (although the addition of oo support is nice). A lot of times the simple problem you are trying to solve is inherently very linear in fashion and you don't need 100 abstract classes to describe the problem. People have a way of abusing OOP after being bread on Java.

There isn't much of a learning curve. It follows the same tried and true c-like convention most programmers are familiar with. It offers all the nice webcentric functions you are likely going to need (although I admit, the calling conventions need to be standardized - needle, haystack vs. haystack, needle)

There's great library support, great support on every web server. An AMAZING help manual complete with useful user comments (that I admit are fun to just scroll through and learn some things by example).

It just plan works. Yeah you might spend some extra time meddling with details that certain frameworks are trying to abstract away from you, but my experience says that when such frameworks fail to provide you with what you need, you have a harder time getting under the covers and making things work the way you (or your client if you are developing for others) want things to work. This is a big deal from a standpoint of the "Law of leaky abstractions"

+4  A: 

There are definitely benefits PHP has over other languages/frameworks. DHH (the creator of Rails) casually wrote about this topic saying:

"I've been writing a little bit of PHP again today. That platform has really received an unfair reputation. For the small things I've been used it for lately, it's absolutely perfect."

I agree with him. PHP is perfect for small sites which do not need a full-featured framework backing it. And not to mention it is very easy to deploy and is supported by nearly every web host. It is difficult to find a reliable Rails host under $15 per month, but PHP hosts cost next to nothing.

That said if you are creating a decent-size web application I highly recommend trying out a popular framework such as Rails or Django.

ryanb
+2  A: 

See Harry Fuecks Pro PHP Rant for a good answer.

PHP is superior because it is flexible. It can be whatever you want it to be. Most of the other products force you to work in an unnatural way, just so you can follow some faux standard that will no longer be true in a couple of years.

Frankly. Nobody has ever cited a good reason NOT to use PHP. All I ever hear is that it is possible to write bad code. Well. Duh. You can write bad code in any language.

Jeff Davis
I agree 100% I am wanting to know why I should quit PHP for another language
jasondavis
A: 

Before I started using PHP all I knew was CSS and HTML. I had a pretty solid grasp of programming logic, but I knew very little about the syntax or the mechanics of an actual programming language. My boss told me turn some VBA script I wrote into PHP, saying "PHP is easy." Within weeks I had written the whole thing out and was working on projects to redo the entire staff site.

Now that's not just a great plug for PHP to start with. Since learning PHP (and MySQL and javascript), I've thought "why not try my hand at some of these other bests like ASP, .NET, or Ruby". And it reminds of that Churchill Quote:

Democracy is the worst form of government except all others.

A buddy of mine was helping me look up some documentation on PHP.net and he quipped "They should really be using Ruby for their site."

And I always thought PHP had TERRIBLE documentation. Very presumptuous, very sparse. Rarely real-world.

Then one day I went to the Ruby documentation site. I wanted to weep. It was ugly and confusing. I had no idea where I was or what was going on. I see links to book sites rather than best practices.

I've been on MSDN, and that's a hair better. If I see one more folding list, I'll puke.

Jquery has pretty great documentation, usually. PHP will always answer my questions or at least get me to the point where I know what my question is.

If you have formal training in computer programming, or if you came up from the school of hard knocks back when documentation didn't exist, then you probably are pretty comfortable wading through the backweeds to get to the good stuff. But for those of us who are creative and clever but learn server-side scripting to extend our sites, PHP is the only lighthouse in the distance. And that's why it will be the favorite of these kinds of web developers, which is why it will remain one of the most popular languages for server-side web development, which is why YOU probably ought not abandon it too quickly.

Anthony
I agree in general, but I really like Ruby's documentation.
Ed Swangren
+1  A: 

Because more goes into making a decision like this than finding the latest and greatest flashy language. PHP is prevalent, has many existing libraries, and has a large user base. Try to find a team of scala devs to create your new site and see how many applicants you get :-)

Ed Swangren
+1  A: 

While I'm mainly working with Django / Python now, it's hard to beat the rapid development & deployment of PHP. However, I've never had to do more than a small site with it.

Yancy
A: 

I continue to use PHP because I'm familiar with it and because of the volume of prior arts that exists on the platform. While older versions of PHP weren't particularly elegant, PHP 5.2/3 has come a long way.

Against many languages, PHP is great because mod_php makes writing and deploying applications trivial. PHP's syntax is sensible to me — curly braces make my day. I don't have to worry about gems (Ruby) or a typically gross application structure (Django). I can use tabs when I want, and spaces when I want (and I'm consistent). Functions have clear arguments, startpoints, and endpoints.

I'd like to see PHP's array syntax change though, and I'd like to see data types like strings and arrays become objects you can extend.

arbales
A: 

Since I have a background in classic ASP, I can manage the basic stuff in ASP.NET, but all the really great things about ASP.NET are way too difficult for me to learn. It's difficult for me to find tutorials that use VB as the language (most are C#, which I don't know) and that actually work (things seem to change too much between versions).

I don't think PHP has particularly great documentation, but it's just slightly better than ASP.NET and it's only one language so there's more useful information on the Web.

Scott