Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I know this may come off as a flame-y / troll-y, but I hope you will take my word for it that it's not my intention. I am just trying to understand the PHP phenomenon.

After looking at the many technical issues with the language design of PHP, I am hard pressed to find any redeeming technical advantages where PHP surpasses all other languages. Before coming to the conclusion that there would simply be no reason to choose PHP as a development language on purely technical grounds, I would like to ask, if all non-technical factors were equal (such as what language the developers already know, what languages the hosting provider offers, language of existing code, cost, license, corporate fiat, etc.), would there be any type of new software system that would indicate making PHP a first choice for development? If so, what technical advantage does PHP have over all other languages that would cause you to choose it?

EDIT: I am not interested in comparing PHP "out of the box" with other languages "out of the box". If PHP has a certain feature "out of the box" that another language has only after installing some readily available add-on, that is not considered an advantage for PHP for the purposes of this question.

share|improve this question
2  
What about library and tool support? Or are you asking solely about features of the bare-bones language semantics? (That would move this question into ivory tower - I hate that term but it's what I mean so I'll use it - "look how elegant and pure our language is" territory. Not that that isn't a valid question, it's just less useful for real world decisions.) –  delnan Oct 18 '11 at 17:40
    
can you provide some links or facts about technical issues with PHP that worry you? –  Christian P Oct 18 '11 at 17:41
5  
Is what language the "hosting provider" offers really a non-technical factor? –  NickC Oct 18 '11 at 17:43
    
@delnan... library and tool support is valid, provided it is an advantage over all other languages –  JoelFan Oct 18 '11 at 17:43
    
@Renesis, yes, because the spirit of my question implies that choosing a hosting provider would be for technical reasons only (not cost, convenience, existing environment, etc) –  JoelFan Oct 18 '11 at 17:45
show 7 more comments

4 Answers

If there is a language out there that doesn't have tradeoffs, please let me know.

While what you have eliminated as "non-technical" factors does take away a number of the common PHP benefits, I can think of a few technical factors for which PHP might be favorable:

  • PHP is scripting. That means deployment can be as simple as one new file on a PHP server.
  • PHP has OOP. PHP's OOP5 is not by any means a shining example of "good" OOP but it is decent.
  • PHP is a template language. PHP and output (HTML or even JSON) can so easily be intertwined that it's very easy to create rough controller/view separation. It can be as easy as two files, or even a single file with clear delineation.
  • PHP does a lot of things out of the box. File-reading, HTTP requests, XML/JSON reading/writing, image manipulation are all very easy, right in the core language or ubiquitous extensions.*

This is a combination thing — I don't think you would pick PHP for it's "strength" in any of the above alone (except maybe what it does out of the box with very little effort).

None of these are necessarily advantages in 100% of cases. Some of them are actually negatives given some developers or some project needs. But together, they might just provide the right set of advantages for a given project.

Picking any language is about determining which tradeoffs you can and can't live with, and those features you can't live without. Just like most common languages, the advantages above (and others I may have missed) combine to fit some developers' needs the best.


* In many cases, libraries, plugins, etc. can turn a language into a direct competitor with any other. Out of the box is still a real technical advantage:

  1. Libraries come with an installation and maintenance overhead.
  2. Libraries often must be moved around with a project (or use a build automation tool) instead of just a single requirement of "must use Language version X.0.0"
  3. Each library comes with its own update cycle, which may or may not be compatible with the core language version or other libraries.
  4. May heaven help you if you end up with circular dependencies and need to upgrade anything.
share|improve this answer
    
I would add that now PHP has first class function, which is a real plus for this language. Plus the fact that is really easy to set-up and get started, so you don't ends up managing a plateform and simply focus on the software. –  deadalnix Oct 19 '11 at 16:47
add comment

I am just trying to understand the PHP phenomenon.

PHP was at the right place at exactly the right time.

There are no purely technical reasons to take PHP over another language. When doing language comparisons in the past, for me, it's boiled down to what I feel most comfortable with and which language yields the highest ROI (which also ties into which language I feel the most comfortable with obviously). My decisions have usually also been peppered with a hint of ab benchmarks as well. Every language offers the ability to do everything that another one does.

The benefits to using PHP over other languages lies purely in its community and available of PHP programmers (note, I didn't mention quality of ;)). It'd be a whole lot easier (and cheaper) to outsource portions of a PHP application than, say, an Erlang app (note, again, I didn't mention anything about quality ;)).

share|improve this answer
add comment

PHP has grown (because you really can't say it was designed) out of a need to easily generate web pages. And it has succeeded at that:

  1. In its default use case scenario (with Apache) it follows a very simple request/response-model. No multi-threading, no nothing. The only thing you ever might have to worry about is using transactions for DB access when necessary.
  2. You can easily take a static web page and just add bits of logic here and there.
  3. It is dynamically typed, very forgiving and has one general purpose data structure

From the way it is used on web servers, it is not inherently different from Perl, Ruby or Python. However those three were designed as general purpose languages (yes, one could argue Perl wasn't), that later became available as web development tools.

PHP has had a bit of a head start and simply offers the lowest entrance barrier ever to web development. For that reason, there's simply a lot of PHP developers around, there's a lot of PHP code around and if you get web space or a managed server, it usually has PHP off the shelf. Getting PHP up and running is trivial (at least if security is not a concern). Finding a library that does what you want is trivial (at least if speed is not a concern). Finding a replacement for a developer who's gone is trivial (at least if quality is not a concern).

share|improve this answer
    
You do have multi/threading with php/apache its just the the whole multi-thread/multi-process handling has been delegated to Apache! –  James Anderson Nov 22 '11 at 7:17
    
@JamesAnderson: There is a big difference between multi-threading and multi-process. And "delegation" is hardly the right word here, because that would mean PHP could control how Apache chooses to manage its workers. –  back2dos Nov 22 '11 at 8:10
    
perhaps "Apache takes responsibility for" would be a better wording! The point is you will never miss this "feature" in the language. –  James Anderson Nov 22 '11 at 10:31
    
@JamesAnderson: Maybe you will never miss it and that's ok. But when you write a server infrastructure for an MMORPG, I assure you, you quickly hit a wall with PHP, especially because of the default execution model (behind a HTTP server). –  back2dos Nov 22 '11 at 10:51
add comment

My answer: there is no technical feature where PHP is better than other languages.

There is some trend, some call it "language oriented programming", that in the future people should be able to write programs like adding new stuff to wikipedia. Just using very simple mechanisms.

To some extend PHP is good at it. It's more about how many people have access to contribute than the technical features.

With dynamic objectoriented programming there are a lot of features that PHP doesn't provide yet. (example needed)

Concerning the "OOP scripting" and using the "language as a template language" can be done with many programming languages (I think even perl6, and possibly even ruby offer this).

I think it is important to further look at the trend that more people can contribute programs. Even with domain specific languages (DSLs), small sub languages that provide the ability for non-programmers to add functionality.

Further, it is important to follow the trend of using functional programming for web programming. This is the opposite: highly complex languages and frameworks that are only suited for expert programmers. With complex stuff like Monads, category theory, lazy evaluation.

There are two very good examples:
1. Haskell and the snap frame work
2. Scala and the lift framework
(and further maybe also Clojure and http://webnoir.org/).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.