views:

2226

answers:

17

PHP was the undisputed king of easy webapp development, until Ruby on Rails, Django, and other dynamic programming frameworks appeared. What are, in your opinion, PHP's strengths against the newcomers?

+10  A: 

Deployment is a big one. Write your code, upload, and it should run on most every web server.

Also, since PHP isn't a framework there's a lot less to learn to get started.

Jarrod
I think this is the only general advantage to php. One great development in rails is heroku which is a great way to easily deploy rails apps.
jshen
I'm not sure that PHP isn't trying to BE a framework. After all, the very fundamentals of the language assume that the code is running within a web request/reponse context (witness all the pre-defined $_GET, $_POST, $_REQUEST variables... these are specific only to a web execution context, and are available to ALL scripts regardless of invocation context).
Jarret Hardie
That's exactly what I meant about there being less to learn to get started. Since the language assumes it's going to be used as a web script, learning it goes hand in hand with learning the basics of web scripting.That said, it doesn't negate the advantages of a proper framework, good design patterns, etc. - it's just an easy place to start.
Jarrod
A: 

It depends on what you are trying to do as to whether PHP has an advantage.

RoR for example generally is both the UI and backend, PHP can serve very well as a backend only.

So, if I have a WinForms client it can interact with a database through the php scripts, so I limit who can get to my database. So the php client can be written in any language.

RoR (Ruby) and Django (Python) are hard to compare with PHP as the first two are frameworks that make web application development easier.

You could compare ASP.NET and PHP for example, but ASP MVC and PHP would also be difficult to compare.

James Black
+3  A: 

Deployment is definitely a strength of PHP.

However, it also ships with a lot of batteries for writing web applications. The syntax and namespace pollution that python and ruby people make fun of make for a simpler experience for new developers.

And it gets TONS of new developers because there aren't just frameworks for PHP, there are applications. WordPress, Drupal, Joomla are all huge and that's just the tip of the iceberg. Each of these systems has a huge ecosystem of "PHP Programmers" who start out by cutting and pasting some code from a blog post and learn from there.

Along the sames lines, since it starts out as an HTML file, it's a great environment for doing very simple sites where you just want to inlude some files or whatnot. Think of it as super SSI.

All that said. For doing applications, real-honest-to-god applications, instead of websites, I'm not sure it has any significant advantages beyond deployment and market traction.

easel
+1  A: 

Scalability is always a challenging issue, but I suspect it is easier to scale a PHP web application than its equivalent Rails or Django applicaton.

fuentesjr
Your avatar is "python-powered", yet your answer suggests that php-powered is more scalable. I'd be interested to hear details about your experiences.
Jarret Hardie
+2  A: 

PHP is not a framework. You could compare the Zend Framework to Ruby on Rails and Django.

I don't have experience with Ruby or Python, but I've worked with PHP and the Zend Framework for a year now. Of itself, PHP is a terrible language. It has morphed and changed through the years, but still has most of it's old functions and procedural style. The nice thing about a PHP is that many operations are very quick out of the box, but most frameworks will provide that for you anyways

John
+1  A: 

PHP's maturity as a language. Look at the number of successful international websites that are implemented (at least for the most part) in PHP, example: facebook.

As of November 2006, there were more than 19 million websites (domain names) using PHP.

Php ranks fourth in the Tiobe programming community index for 2009

This is not really a programming answer, but it's worth pointing out that the relative popularity of languages is a pretty good indicator of how vibrant their respective communities are - which means better learning and support through the sheer abundance of information.

karim79
Oh, c'mon. Most banking applications are still written in Cobol. Popularity is meaningless. Would you say that VB6, which still offers popular support because of its installed base, is a vibrant community worth joining for a new project? There's abundant information on VB6 out there... should my new webapp be written in that language?
Jarret Hardie
Which is to say, there are plenty of scenarios where one might choose PHP. Popularity is not one of them.
Jarret Hardie
+15  A: 

Firstly PHP is not a framework, its a language.

IMHO the strongest point for PHP frameworks (apart from deployment :) is the huge and mature community. RoR and Django are fantastic tools with devoted but limited followers.

RoR has been greatly imitated in the PHP world, with CakePHP being almost identical, eliminating any need for a PHP developer to switch to Ruby.

Django is one of the few gems out there but personally I am in love with Zend Framework.

There are great tools for any of the major languages, and as you cannot compare a framework with a language you can't decide on a framework if you don't decide on your language first.

Ruby, Python, PHP and (even) Perl are essentially the same for a person with strong computer science skills, and in the end the choice depends more on personal style and programming roots than which one is "better"...

Anyhow, my point is that removing Java everything else is a perfectly logical choice. ;)

Yannis Rizos
Not to disagree, but unless things have changed drastically in the last year or two, the documentation for CakePHP is bad, and the support is almost non-existent. PHP frameworks that chase Rails are missing the point - PHP does its own thing very well.
b. e. hollenbeck
Well I suppose CakePHP is quite poorly documented. But I strongly believe that one of the main attractions of PHP is the community's ability to instantly adapt and imitate every current (over)hyped piece of software. There is not a clone of RoR for every given dev environment, even poorly documented.Anyway I am not suggesting CakePHP as a perfect alt to RoR or a perfect anything, just trying to point out that the PHP community is quite adjustable and versatile. ;)
Yannis Rizos
As a sidenote I have just been informed by a CakePHP developer that ver. 1.2 is adequately documented. Don't really know for myself, but book.cakephp.org looks promising... (It's always good to have a fanboy around :)
Yannis Rizos
Never trust a developer's notion that his own system is well documented.
Rob
@Rob Can we have that engraved and mounted somewhere? Just perfect.
David Berger
+2  A: 

Procedural PHP is incredibly easy to learn, especially compared to Ruby on Rails, if only for the fact that you can (until you learn better ;) ) embed it right into your HTML.

To work with RoR you need to understand MVC etc.

Matt
+16  A: 

There are a few advantages of PHP. One is the ease of deployment, you write your script and upload. Done.

Another is the huge function library, with support for SQL databases, JSON, XML parsing, cURL, calendar calculations, all libraries to make the life of the developer easier.

PHP itself is a template system. That's why I never understood the need to use things like Smarty, with the alternate colon syntax.

<?php
$fruits = array('apple', 'orange', 'banana');
?>

<ul>
  <?php foreach($fruits as $fruit): ?>
    <li><?php echo $fruit; ?></li>
  <?php endforeach; ?>
</ul>

PHP also doesn't force a design pattern on you. If you'd like to use MVC, go for it. There are a few frameworks that allow you to so. On the other hand, you can write a single-file script in 10 minutes if you really need to. It's about flexibility.

On top of all that, there's the availability of years worth of code, tutorials, examples, and experienced people to go to for help.

Justin Poliey
+1 Down-voting this is plain harsh, I don't see anything too wrong with it.
karim79
you don't have to use smarty, you can choose something else, or any coder can roll some basic template parser on his own, but I don't get what you don't understand. separating program from the UI is crucial in application design, avoiding it leads to unmaintanable code, so it shouldn't be pointed as an advice regardless of the language
zalew
^'logic' instead of 'program', sorx, tired.
zalew
"Write your script and upload": this applies only to very simple PHP-based web applications. Anything with mild complexity, and certainly anything with cached byte-compilation to achieve reasonable performance, is going to require that the server be recycled, or at least that the same code-modification-nannies as found in Python and Ruby be deployed.
Jarret Hardie
+1 My other comment notwithstanding, this is a balanced analysis of PHP, and highlights the areas where PHP shines.
Jarret Hardie
Pretty much every major language has a vast library of functions; you're dead if you don't support database interaction, XML, etc. On the other hand, *some* of these are a tad nicer to use in PHP than others; SimpleXML springs to mind.
Rob
I think this over the accepted answer, as it actually answers the question. Well done.
Paul D. Waite
+5  A: 

It's easy to replace a developer and change code location. However, the disadvantage of its popularity is you must filter good solutions/developers from the lame ones - most of python or ruby developers are not 'script kiddies' (of course there are some, as everywhere) while the programming entry level in php is much lower and you must be very selective when looking for programmers and code snippets.

Another good side is that many of its flaws are well known, the docs and forums are full of comments, and it's easy to get quick advice.

The very subjective (as I said above) strength is its' popularity...

Regardless of all above, I don't get why many mention that php is 'mature', being old enough does not result being mature, php is far from being mature and consistent, it's philosophy is a denial of matureness. It doesn't mean you cannot make a mature application in php though, it's not a matter of what language, more a matter if you know how to use it. Can you write strong and mature apps in php - yes. Is php strong and mature as a language - IMO no.

zalew
+10  A: 

Easy to get started

If you know HTML, here's how to start using PHP:

1) Change your filename to .php
2) Add an include statement to stop duplicating your menu code on every page

Assuming your web host supports PHP, that's it - one line of code does something powerful for you.

Nathan Long
This is what I first used PHP for :) +1
alex
+3  A: 

Having worked with PHP for several years (several years ago) I'd have to say that there's very little that PHP has that's an advantage. Others point out deployment... I'd say it's about even with the other web platforms out there. Others mention the language itself, to which I say bullocks. PHP is one of the worst out there. It's very easy to shoot your toe off with PHP, and very difficult to build decent, reusable components with. PHP is great for Hackers, i.e. the original sense of the term: hobbyist programmers, but it's crap for Software Engineers, i.e. anyone who cares about things like coupling, cohesion, quality and reusability.

Probably the only real advantage IMO is that it's ubiquitous; you can find a LAMP(hp) stack for uber-cheap with unlimited pretty much everything all over the web these days. There are dozens and dozens of hosts to chose from. Compare that to Rails or even ASP.NET hosts -- there are less hosts, and they're usually more expensive.

Randolpho
This comment is spot on. PHP is TERRIBLE compared to real languages like Ruby and Python - the only benefit it has is the same thing that VB had; lots of people know it. That's also the biggest drawback to PHP because any idiot can pick up a book and call themselves a PHP Programmer, and drive down the wages of the rest of us.
Wayne M
@Wayne: I hear ya. Given the choice between programming in PHP or programming in Python (but I have to lose my left leg), I say "I can get around on crutches". Of course, if you add C#/ASP.NET MVC to the equation (but I have to lose both my legs), I'd have to say "where's my wheelchair?".
Randolpho
So in other words, asm is the only language you'll ever need to learn... @Wayne: And any idiot can pick up a book and call themselves whatever they want. Most idiots however will not take the trouble to pick up any book.
Yannis Rizos
@Yannis: That's pretty much the exact opposite of what I wrote. The language itself isn't notably bad, other than the complete and utter lack of modularity -- I mean, it's like they did their best to make sure you *couldn't* build libraries and code for reuse. Seriously, WTF? No, despite that, the biggest problem with PHP is its inconsistent and frankly crappy library. PHP has grown organically over the years, just like other languages, but it has utterly failed to clean up after itself. PHP could be a serious condenter if it did top-to-bottom rewrite of its API.
Randolpho
@Randolpho: PHP the language is not its libraries or extensions. PHP's handling of arrays (ie), which is a core language structure, is uniquely simple and powerful. I will not comment on R and P, just say that it's not surprising for very low adoption langs to attract good developers and widely adoption langs to attract everyone. Let's not flame each other anymore, Python is cool, Ruby is cooler but since I started out as a Perl dev their syntax and quirks makes me laugh. Matter of personal opinion, nothing more.
Yannis Rizos
@Yannis: Oh, I agree -- PHP's array system, while not unique, is certainly powerful. But you must agree that the default libraries that ship with a language are an important factor in how the language is used.
Randolpho
a bad workman always blames his tools - i'd be quite content building a highly scalable web app using php. The only thing i'd like to see added to php mysqli is disconnected resultsets, that's about it.oh and incase there's any confusionhttp://msdn.microsoft.com/en-us/library/aa266531%28VS.60%29.aspx
f00
@f00: Sure, it's possibl to build a house with a hammer and a handsaw. But you can build a house faster and often with better quality if you have better tools available that make the job easier.
Randolpho
A: 

PHP's biggest advantage and its biggest disadvantage are one and the same: ubiquity.

PHP is the dominant language on the Web, so it's easy to find a host that supports it and it's easy to find a "developer" who knows it.

Unfortunately, because it's the dominant language and thus the weak-minded* will gravitate toward it, the vast majority of PHP developers and hosts seem to be pretty terrible.

Also, PHP (just by itself) is just a language, and thus offers more flexibility but a lot less support than Rails or Django, which are frameworks. There are frameworks for PHP as well, of course, but any framework will decrease the flexibility you get from the relatively blank slate that is PHP.

* Note about the "weak-minded" thing: I just mean that the less talented and/or motivated tend to gravitate toward the dominant platform — no matter which one it is — not that anyone who uses PHP is stupid.

Chuck
How does "weak-minded/less-talented" not essentially equate to "stupid" in the context of software development? :-)
Jarret Hardie
Geez, my clarification was unclear. I mean that although the weak-minded disproportionately gravitate toward PHP, they aren't the only ones who do. People tend to get hot under the collar when it comes to their favorite language, so I wanted to make it clear that I wasn't insulting *all* PHP coders. (At least, not on this particular occasion.)
Chuck
A: 
  • cheaper hosting
  • cheaper developers
Andre Bossard
+1  A: 
vartec
Eh, I don't know that the learning curve is all that big an advantage. Do you really think Ruby and Python are that much more difficult?
Chuck
It's more difficult for absolute beginner to make web application in Python or Ruby. In PHP they'll just create spaghetti, HTML with embedded PHP code. So as I've said, it's also disadvantage. That type of code is impossible to maintain.
vartec
The fact that in Python or Ruby you'll use framework from very beginning, gives you advantage later on.
vartec
A: 

I think PHP's Web Frameworks compared with Ruby on Rails and Django would be right comparision. Only real difference is programming languages used in these web frameworks. PHP is more popular (today) then Ruby or Python, much easier to learn and deploy thats main advantage of PHP over these two, got better libraries as larger community behind it and you can easily find multiple learning resources. On other hand Ruby and Python are considered as better programming languages, you will be using these languages in their web framework. PHP and its web framework are good for certain projects but got some serious design flaws, while ruby on rails and django are better for complex projects. Most of the Rails and Django developers were php prgrammers, that might explain. PHP is simple for simple jobs, Rails/Django is simple for tough jobs.

Dhawal
A: 

there's less overhead if you roll your own framework with php !!

f00