10 reasons to use PHP

With my departure from Zend this week I figured now might be a good time to reflect on the past 5.5 years.  I will still be working with Zend as a contractor, most specifically to make sure the ZendCon 2012 content is handled properly along with some other tasks.  But I will be spending my time being self-employed, working on mobile applications.  There have been a few ideas I’ve had toying around in my head for a while and it’s probably time that I put my money where my mouth is.

I do like working with client/server-like architectures and so I intend to be building apps that have a fair amount of server-side processing to back it up.  More details on that to come in the next few months.

I have decided that, for the time being, to use PhoneGap for my frontend development.  There are several reasons for this.  1) HTML 5 is at the point where you can create compelling data-driven applications, 2) I didn’t want to have to learn a bunch of new languages/ecosystems to get up and running, 3) I wanted to use my existing skill set.  OK, 2 and 3 are about the same, though a little different.

So the question was what to use for the backend development and, to nobody’s surprise I presume, PHP is my chosen way to go.

You might think that “Duh, the Zend guy picked PHP” but that’s not the whole story.   When I first started using PHP I didn’t like it at all, but I learned it.  My preference was actually Perl and Java.  Tried my hand at C but pointers keep messing me up, even to this day.  I have no idea why.  But I got the call saying that Zend was looking for a consultant and I figured I’d give it a shot.  How I got past the interview process, I don’t know.  Maybe they were desperate.  I liked the language but I was more interested in the challenges that I would have to overcome as a consultant.

But now that my work life is switching gears I have to make the decision again.  Do I continue to do work with PHP or do I choose something newer and flashier to get the job done?  PHP was my choice and it remains my choice.  But why?  Here are 10 reasons.

  1. PHP is stupid easy to scale – In the unlikely event that any of my projects go viral I will have the need to scale quickly.  PHP does it quite easily due to its shared-nothing architecture.  I can drop in more servers and increase my cluster size by orders of magnitude with very little configuration.
  2. I won’t need experts – If the event that my new ventures grow and I need to hire on more programmers I do not need the best and brightest to get the job done.  PHP just works, in many cases.  If you have an organization that needs to hire the best and brightest you are probably doing it wrong.  The best and brightest are expensive, moody and prone to boredom.  PHP allows you to set up processes that  can allow ordinary programmers do extraordinary things.  Very, very few languages can do that.
  3. It is tied to the web – HTTP is an imperfect protocol.  But it is prolific, for good reasons, IMHO.  PHP is bound directly to HTTP.  You can run it in non-HTTP environments but it is built for HTTP.  Since my communication will be over HTTP, PHP makes a lot of sense.
  4. When it fails, it doesn’t fail hard – Granted, you can fail spectacularly with PHP, but it probably won’t be PHP’s fault.  Because PHP cleans up and starts over for each request, one request will not corrupt another.  Other languages need a lot of plumbing to handle that.  PHP does it by default.
  5. Frameworks – There are a plethora of frameworks to chose from.  While some may consider that a drawback, I consider it a strength.  If you need something that supports a complicated, or enterprise-like application you have the likes of Zend Framework or Symfony.  If you need something simpler you have Silex or Slim.
  6. Best documentation on the web – Sure it looks like it was stylized by Tim Burton’s Joker but the content is prolific.  Every function and method call has some kind of documentation and a great number of functions have tons of examples.  Not all of the examples are good, but there are enough of them that you can get moving in the right direction quite easily.  The only thing I wished that was different was that you could log in with Twitter or something like that to propose a change.  I have enough logins as it is. (Correction, you can log in and edit the docs with a Facebook login). But even so.  Best. Documentation. Around.
  7. Tons of blogs – PHP developers love to blog.  Notoriety in PHPLand is based largely on how much you share information with other people and lots of people take this to heart.
  8. The PHP Community – This could also be seen as a 7(b).  But there is no shortage of people who are willing to help you on IRC, Twitter or a host of other places.  You just need to know where to look.  Special mention must go to Cal Evans and Michelangelo van Dam who have put up with me and done more for me than I ever could have reciprocated, for various reasons.
  9. It integrates with everything – There are tons of interfaces to third party systems.  Some of them are native like MongoDB or Memcache, some of them are PHP-based like Pusher.  And that’s not surprising, really.  PHP powers a third of the web and is used by banks, transportation, governments with tons of business critical applications.  PHP should be a wide open target for anyone attempting to make a play for web-enabled applications.
  10. Dynamic typing – “But how do you know if you’re working with an int or a string?”  By using your brain.  HTTP does not do typing and so PHP does not do (strong) typing for scalars.  Quite frankly, it makes complete sense to do it that way.  Want an int?  Cast the damn thing and stop complaining.  Dynamic typing significantly reduces the amount of code you need to write and error conditions you need to check for.
  11. It plain works – Programmer’s have it wrong.  The technical solution is not the end goal.  Technology should be an enabler.  Do you have a wonderful technical solution that doesn’t solve a problem?  Bye, bye.  PHP solves problems faster, easier and with a lower cost of ownership than almost anything out there.  A lot of that is based on “assumptions” (or shortcuts) that PHP takes to solve a problem.  Most often those shortcuts work, and the workarounds are very easy to implement (I’m thinking mainly about strict type checking here).
Now that I’m going out on my own I have to be very careful about where I put my money.  Heck, I’ve even given up satellite TV, which, sadly, means no more F1 races this season (though I did find the wonderful The IT Crowd on Netflix).  But I’m putting my money where my mouth is, and my mouth is saying that, if you’re doing the web, PHP is where it’s at for at least the next 5 years, if not longer.  Beyond the 5-10 year range we don’t really know what programming languages will look like.  People will guess and 73.5% of them will get it wrong.  So for the foreseeable future, PHP is where it’s at on the web.

 

<Also, comments will be liberally deleted if you’re going to be an ass about this post />

132 comments
kschroeder
kschroeder moderator

For those who were talking about PHP development as being something that basement programmers with no real importance are doing, this is a survey that Zend just released today (http://www.zend.com/en/community/state-of-php-in-the-enterprise?src=li).  I knew about the survey results when I wrote this but could not talk about them.  So when people talk about how useless or amateur or un-enterprise-ready PHP is, here is DATA to show that the "enterprise" is actually taking PHP quite seriously.  PHP is much more pervasive than a lot of people think and it is the driving force behind a lot of business.

 

I encourage you to read this report.  But here are a few select quotes.

 

"the demand for PHP developers is growing faster than any other server-side development language. There are currently nearly 25 million (public) web sites running PHP, including such high-profile sites as Facebook, Wikipedia, and Yahoo. Additionally, comparing job trend data to other Web scripting languages, PHP could be ranked as the most popular Web language today."

 

"in our survey, 60 percent described their PHP applications as revenue generating, or critical in nature, while only 15 percent described them as being used for non-critical purposes. For those planning to use PHPin the future, only 13 percent described their planned PHPapplication as non-critical in nature"

 

"The majority of those who chose PHP did so to deliver higher quality, an improved user experience, and optimal application performance, all while saving costs with increased efficiency."

 

"97 percent of those organizations that are actively using PHP plan to use it for future application development."

 

I am sure that this comment will generate another dozen links to "A fractal of bad design".  That article is right about it's charges about PHP's design.  The problem is that the charges don't matter.  It's like saying that I'm a lawbreaker who deserves prison because I have a lead foot.  The proof is in the numbers.  PHP has no corporate support like .NET or Java.  Is not new like Ruby or CS-sound like Python.  But yet when you look at the amount of web work churned out by PHP it is on par with the primary corporate languages and eclipses the others.

 

Not bad for PHP getting it all wrong.

Mr CSharp
Mr CSharp

I'm a C# ASP.NET specialist and here's my counter against your points:

 

1) PHP is not the only one with scalability in mind.  ASP, then ASP.NET can do the same.  It's not like this platform came out of nowhere.  Scalability is usually determined by the servers and the host software you're hosting it on.

 

2) PHP is very similar in nature to Javascript.  You still need the skilled developers to write the code.  Why do you think ASP.NET has been so much more popular with the business for the past 15 years?  Also, if there is no expertise in doing the code, imagine the maintenance on it by someone else.  With PHP being much like ASP, the UI code logic gets inlined with HTML code.  I just cringe when I go back to doing ASP and all the UI logic is interspersed with HTML.  Imagine if you're looking at that code with a plain old text editor trying to find a malformed tag?  So, IMHO, PHP actually requires more skilled developers even though a lot of kids use it in their basement before becoming web developers professionally and then learning other commercial languages in the corporate world.

 

3) Yeah PHP is tied strictly to the web just like HTML is tied strictly to the web.  And so is ASP, ASP.NET, Web Services, and a wide variety of web languages.  What's interesting though is that scalability to not have it strictly tied to the web done correctly through frameworks and patterns.  With .NET development, the separation of backend logic vs UI markups greatly uncouples the two.  Therefore, a Windows desktop UI piece can be fitted into a desktop, web, or a mobile device in event that the client wants that.

 

4) Failure of runtime code is actually dependent on the server host software it's running on. Usually these are thread safe and the application is guarded from other services to prevent a total server lockup.

 

5) There are tonnes of frameworks everywhere for the most common languages used for the web and other types of code development, not just for PHP.  jQuery, for example, is one framework for Javascript while there are couple of dozen more tailored for what other developers want.  ASP.NET has tonnes upon tonnes of frameworks, but really, do we need to have that flexibility and have a cowboy style of development where cowboys run wild and everyone does their own things.  Think about the maintenance costs, standards, and the time to learn the plethora of frameworks out there.  Why don't we just concentrate on a small number of patterns and a single framework rather than "hey, this is something new.  Let's go try it out" kind of attitude.

 

6) I tried doing PHP long time ago and I felt the documentation sucked as compared to that for Microsoft's ASP and ASP.NET.  Why?  It's because there are more people out there in the corporate world doing ASP.NET right now than there are kids in the basement doing PHP.

 

7) There are also tonnes of blogs on HTML, Javascript, jQuery, and especially C#, LINQ, and ASP.NET classic and MVC.  PHP is just one small piece in the whole WWW.

 

8) Everyone grows up and need to earn money after coming out from the basement and into the harsh reality of the corporate world.  

 

9) Sure PHP integrates with a lot of other integration server, I have to give you that.  But the integration software might not be cheap even if the PHP software is for free.

 

10) Dynamic typing - cripes, I hated ASP, VB, VBScript, and Javascript for having that.  With C#, strongly typed variables are way easier to manage code.  With weakly typed variables, you don't know what the variable is until you use it.  Going back to the previous points about the skill level needed - think about a guy who goes while and make a variable a date value then with the same variable later on, turns it into a decimal value, then a string and then back to a date.  How confusing is that?  A skill developer will try to do away with this and make everything consistent.

 

11) You can make anything work in programming.  Back to point  #10, it'd be better if things are compiled ahead of time to make sure you don't get any runtime errors.  With Javascript, it'll run as well, but at least the browsers can hide the errors for general users.  With HTML, it'll render in IE even if the tags are malformed.  So, what's the point of this point?

upr0
upr0

In your article the only sentence which you emphasis was that only stupids use php  and php does not need so much talent ... dear friend never compare a language like php which is not fully Object oriented with a powerful language like C# with is fully object oriented and a powerful company like microsoft support it. I suggest C# to any programmer. be sure if you are 10 in programming with help of microsoft and using C# you will be 20 at least. be sure.

good luck

thank you for your information.

aloksupremacy
aloksupremacy

Time waste 2 padhne ke baad maine ise padhna bhi jaruri nhi samjha...

bjori
bjori

"The only thing I wished that was different was that you could log in with Twitter or something like that to propose a change."

All the doc pages have an "edit" button which allows you to login with facebook, google account, or just modify the documentation anonymously.

 

In case you don't have the time to edit the docs, or you don't know how to fix them - or you believe they are simply wrong, you have the "report a bug" button which allows you to make suggestions quickly or mention what you believe is wrong :)

 

AGHICT
AGHICT

Good,

I hope people check this post before say ASP

danaketh
danaketh

I can't say if I love or hate PHP. I just live with it. It's one of the things that helps me to pay the bills. Sometimes it makes me pretty angry. That's when it throws errors for no visible reason or I'm forced to fix something written by an idiot or using Zend Framework. But it's able to make me happy again, because when I take a look how much work is there for me and how much I'm getting paid for it and compare it with those who do "real languages" (whatever that means), I have to laugh. I'll be gladly the one who "writes scripts in cobbled-together mishmash of inconsistencies" as long as I'm getting paid 3-6 times more than those with "real languages".

 

After years with PHP, I know most of the problems and strange things that it contains but so far the only real annoyance is the inconsistent syntax. The rest I can live with because I'm not really seeing them anymore.

asusmx
asusmx

Here is something else to think about. For my work I use CMS et program of the sort (Joomla, Drupal, SugarCRM and son on). I wonder why they use use php. Oh yeah their is is few of those for .NET, but those for php are definitly the most popular. Even hosting company offer excellent support for those, they install it and configure them for optimal performance on their server setup. I would really be missing a lot not to use them. But hey, php is not strictly type, I shouldn't use it...

euyisenga
euyisenga

I'm not good in php but I think I like it and hope too know it. 

hakeem_tunde
hakeem_tunde

It's nice to cee people's view. Php is one of d cheap programming Lang 2 start with talkin of scripting Lang. That said I wish u good luck.

EdATODI
EdATODI

I like PHP; but, CFML is better.

 

It has all the same benefits as PHP (as listed above).

 

It also has better security, faster development time, better management interfaces and, generally speaking, faster page execution times on high end servers.

 

 

howmnsk
howmnsk

have a look at a Language and database called MAPPER

matt_pedley
matt_pedley

For me it's number 11, it just works.  I'd agree with some of the comments such as not ideal as a first programming language but as someone who has come through the Windows Application route I mostly work in PHP now.  I prefer it for most web applications compared to .NET.

 

I have seen some terrible and dangerous PHP coding and understand why some think that itself is a reason why the language is bad.  Reality is though, if you have programming knowledge it is a brilliant language that gives results.

kokopelli
kokopelli

I am an independent contractor and I have a Job with a firm. For the firm I write C# ASP.net MVC3, using nuGet and EF. I love C#!!! But for my contract work, it's always about PHP and Zend MVC. I use Backbone, Require.js, Underscore for the Javascript end.

That being said, Kevin, I agree with you 100%. I also am an advanced Actionscript developer, using RobotLegs and such....I just recently setup 2 huge servers with Citrix Zen, installing WAAS (Windows 7), Windows Server and a few CentOS servers. So now I can develop independently using C# and PHP. It also allows me to make money hosting the clients project.

So, Kevin, I say, you do what you have to do to get the bills paid. My Mortgage company doesn't want to hear me say, "I couldn't pay my mortgage because I was banking on Ruby and Python but no work came my way...I passed up all the PHP work because other developers talk bad about PHP and Linux....etc....etc....etc.."

That being said, Kevin, get your money son!!!!! See ya at the crossroads!!

 

As for the haters....well.....thanks for making me rich!!!

 

Peace

opwernby1
opwernby1

Hmmm... Sorry to have to say this, but the fact that pointers screw you up in C explains exactly why you've written this article from this point of view. Not to put too fine a point on it, but PHP isn't a language: it's a cobbled-together mishmash of inconsistencies which puts friction burns on the inside of Edsger W. Dijkstra's coffin, it makes him roll in his grave so much.

mrlee
mrlee

I'm always surprised by the hate for PHP.  It's a perfectly good language and lends itself to web programming nicely.  Why bother comparing it to .NET people?  I can't believe we are back to the old windows vs unix argument.

I started working with PHP as an afterthought.  Having worked with .NET (ASP, C#), Django, Rails and a bevvy of other languages I always wanted to try PHP but I thought (still do) that the documentation on PHP.NET is horrible.  There are sometimes good eamples but a.) you have to read them all to find one and b.) they are usually for the easy stuff and I don't need 50 examples on how to do a select.

My university offered a class on PHP and I took it.  Since then it is my preferred choice for server side web apps AND it is also a good replacement for unix shell scripts.

Working for yourself is difficult and fun.  Good job on getting rid of cable, now uninstall the WoW client and you are ready to go!

yaph
yaph

"I won’t need experts... PHP just works, in many cases."""

 

PHP often just doesn't work and you need experts to tell you why or read through scores of documentation comments, support requests or bug reports.

 

I guess you haven't looked at many other language docs, if you think that PHP has the best one.  It could certainly be worse, but often important information is only found in the comments sections, and not incorporated in the main docs.

 

Dynamic typing is both good and bad, but PHP is so full of surprises considering types, that it will often be the cause of very hard to identify bugs.

 

There are good things about PHP but for me the negative aspects outweigh them easily. As you may have guessed not my language of choice.

Alvaro
Alvaro

Deleting the bad critics about your article, you just demonstrate what type of person you are. I really pity you. Good luck in your life, you will need it.

asusmx
asusmx

Most of you miss the most important statement in this, he is "self-employed"...I'm there too, and after investigating the demands around me, for the web, one language stands outs for all the reason above, yes php/mysql. I have a extensive MS background, knowing VB ever since ver 1.0. If you write code as an "employee" for some firm, MS is the most likely solution. But when you work on you own, as a startup, you can't afford to buy Windows Server at 999$ each, which also requires $1500+ machine to run on. But linux on a P4, that you can, and have to if you want to succeed. Second point, hosting company are better at php/mysql. .NET on a hosting company is more expensive and noticeably slower. As far as all the details about language (strong typed and such), you quickly learn to deal with. No language is perfect, I mean none. But for a self-employed, startup, web oriented development, php is the best solution even with some imperfection. Anyway, this is my story, I have try to sell .NET solution for web apps, I could not compete, with php/mysql, I work everyday. Talking about that, I need to get back to my work...

GothAlice
GothAlice

 @kschroeder Interesting article.  The results are skewed and nearly useless without context, of course… with context hidden behind a signup-wall.  Way to go.

 

"the demand for PHP developers is growing faster than any other server-side development language." — natural fall-through from large quantities of "unwashed masses" entering into web development with PHP as their first language.  Normalize the numbers of developers, then compare.

 

"Facebook, Wikipedia" — I've mentioned before that Facebook actually compile their PHP to C (ALL of their PHP code is compiled to one ELF executable!) and use Python for realtime work which fairly excludes them from fair comparison.  MediaWiki, while having an obviously huge deployment, is a really difficult to work with codebase; far more complicated than it needs to be and hardly a shining beacon of best practices or maintainability.

 

"Additionally, comparing job trend data to other Web scripting languages, PHP could be ranked as the most popular Web language today." — Again, a pointless data point.  HTML is the most widely deployed markup language, but you'll find few business documents formatted using it.

 

"in our survey, 60 percent described their PHP applications as revenue generating, or critical in nature, while only 15 percent described them as being used for non-critical purposes." — I'd need to see a comparison against other languages to be sure, but I'm fairly confident this ratio is relatively unchanged for other languages, too, if you ask the right people.

 

"higher quality, an improved user experience, and optimal application performance, all while saving costs with increased efficiency."  — Even the most poorly coded Python web application—barring calls to time.sleep()—runs faster and is more "efficient" than an equivalent PHP application.  The difference in deployment architecture alone accounts for this.  User experience has little to do with underlying language on the web, as in any application worth its salt views (template/css/js) are external.

 

"97 percent of those organizations that are actively using PHP plan to use it for future application development." — Vendor lock-in is a good thing?  My Python code runs in CPython, Jython (mmm, using Python in Java enterprise deployments), PyPy, Stackless…

 

"The problem is that the charges don't matter." — Very true.  Quantity does not equal quality, however, and I'd love to see reports on 5-year and 10-year support and maintenance costs.  The only truly valid comparison between languages, development speeds, security, etc. would be between a single application developed with all of the languages to be compared, though.  "Compared to your next most-used language" — would help to identify context, here.  If their next-most-used language is C, C++, etc. then this type of comparison is pointless.

 

(Oh, and Python is hardly CS-sound; like any scripting language it's very difficult to prove correctness. ;^)

 

Not having to worry about SQL injection or HTML injection attacks at all in Python and Ruby (extremely high quality ORMs, real template engines that compile to language runtime bytecode) is two fewer things for a developer to concern himself with, as an example.  Real packaging and dependency resolution (even multi-versioning) is better.  I'm pretty sure that given one or two 40-minute presentations I could convince anyone starting a new project to use Python, even if they don't already know the language!

 

/devil's advocate

 

Thank you for updating with the link; I'll see if I can find somebody with an account to squirt me the whole report for some light evening reading.  :)

savire
savire

 @Mr CSharp Lol, easy there, remember, the language's just the tool. If you are stuck with one language then good luck there, because you does not really understand how the "world" works.

 

As far as I concern PHP had done many of my clients projects successfully so whatever case peoples saying about it, it just bring me money and nowadays like it or not, PHP still dominates most of the web and enterprises do had incorporates them too. The thing is enterprises usually does not care what languages used they just care when something happen they had someone to takes care of it, or to be exact to be blamed for. That's how it work and it will always be. 

 

And yes, you can do a lot with PHP not just the web. Do some research. Of course that would be the same for other languages as well. So if you truly are developer then any languages is beautiful in it's own way.

SeanJA
SeanJA

 @Mr CSharp PHP isn't just for the web, you can do "normal" programming for it too (it just usually gets used for the web).

 

We are currently using Java, perl, and php in our "corporate" environment... also php can be compiled too.

SeanJA
SeanJA

 @upr0 A 10 in programming? Is programming now an RPG? Does microsoft help you level up with their documentation?

savire
savire

 @danaketh Well they inconsistent because they tried to covers all and when you do that with all of those open-source peoples enthusiast who loves the languages be prepare to face this as some of the result. I think it's somewhat a bargain which need to be paid of. 

savire
savire

 @asusmx Well then again because nowadays shared php hosting is still popular and most of it cost less than windows box version which offer latest .NET technology supports and believe it or not for heavy-weight portal written in .NET with enterprises level if you does not had the knowledge of tuning it up then be ready to face bottle-neck. Been having those problems on some of my clients before.

GothAlice
GothAlice

@ericgreenn I find it quite interesting how many PHP-positive comments here are from developers with a Microsoft (C#, ASP, or VB) background.  For comparison, I have a C/Pascal/Perl background—and programmed in PHP for a not insignificant number of years.  This correlation and comment by ericgreenn seem to indicate to me that C#/ASP/VB must be absolutely terrible if those languages could learn something from PHP.  VB has full inheritable class-based OOP, something PHP still doesn't have quite right.  Again I'll reference "PHP: A fractal of bad design".  It's worth a read for a great listing of technical through social lessons from PHP.

 

Case in point, I asked about processing a query string formatted string into an array of variables, and asked in #php why parse_str populated the local namespace even if I passed in an array to populate. I got back a dozen responses of "because PHP sucks".  On the official support channel.  Apparently I had to wrap it in a function so I wouldn't regress to register_globals all over again.  :/

 

savire
savire

 @kokopelli +1, Let the haters say stupid things. Well it's just work and many paid for it. I do have fair knowledge on most of others languages but well when your clients ask and wants faster development time why would forced them otherwise?

EdATODI
EdATODI

 @opwernby1 

c is good for writing filters and such; but, for a real program, done in a reasonable time frame, no way - Objective c maybe, C # maybe, c ++ maybe, but not c.

Pointers don't bother me.  In c, pointers, recursion and the like are expected, which is part of why it is not suitable for large scale app development in the modern world.

 

PHP and CFML are basically advanced code generators targeted to the web, that run in real time.  Hence, they are excellent languages for web development. C and all it's variants are not especially good at this.  Too much time is spent on either minutia or idiosyncratic .Net libraries, and/or variable type declarations that read like encyclopedias.  Tools, frameworks and generators only go so far, the programmer gets left to weed through the rest of it.

 

I can do in a few lines of CFML or PHP what would take a few screens full (and multiple linked modules) of C #.

SeanJA
SeanJA

 @opwernby1 Ah, so you use ASP.NET and look down on us php developers with our non-language. Gotcha.

mrlee
mrlee

 @opwernby1

Hey opwernby1, what is the URL to your blog.  I want to read more valuable commentary from you.  Brilliant nuggets such as 'PHP isn't a language' and the thing about Dijkstra are improving my coding abilities by the second.

ericgreenn
ericgreenn

Yes, use what gets the job done and works well. Most importantly in timely way.

 

No WoW! Come on, you've got to live to :)

 

kschroeder
kschroeder moderator

 @Alvaro Agreed on most counts.  If you look at the comments I have kept several from people who are critical.  Critics, I have no problem with.  Feel free to critique my points in a thoughtful matter.  But if you call me stupid, ignorant or narrow minded, especially when you have no idea what my experience, history and expertise is I don't think it is unreasonable for me delete your comments.  Respond to this article in a thoughtful, respectful manner and we can have a discussion about it.  If you can't do that, take a hike.  Personally, I would prefer the former.

Latest blog post: Loudness Wars - Premonitions

GothAlice
GothAlice

 @asusmx Best is, unfortunately, a relative term.  The best solution I've found so far for the tasks my clients have given me has been Python, though I do maintain legacy support for older PHP applications I've developed.  More and more web hosts are providing excellent alternate language support, such as WebFaction.  These days, though, I maintain my own virtual servers on Rackspace Cloud, and previously Amazon EC2.

 

I'm a performance nut.  I run Gentoo servers (rice ahoy!) tweaked to fully boot in 6 seconds (and compile the Linux kernel from depclean in 54), run a heavily reconfigured Nginx, and my Python applications, for the most part, can withstand extended C10K hammering… with a single application server.  PHP only _begins_ to approach good performance with a third-party bytecode cache (I use xcache for various reasons), run in FPM mode with proper scaling limits, using an on-disk socket, and even then the fact I have to run Suhosin and outright disable a number of core functions to have any semblance of security is concerning to me as a managed hosting provider.  Stability is an issue as well with the regressions I've mentioned.  Hell, the core of PHP barely has a unit test suite… though this is improving slowly over time.

 

Most of my Python application virtual servers, those C10K ones, only have 256MB RAM allocations, making them close to dirt cheap.  (WebFaction managed hosting, as an example, is ~$9/mo for that allocation.)  Even Facebook resorted to compiling PHP to C (HipHop) for performance, and even _then_ they use Python for their realtime messaging and push notification systems (Tornado).

 

Now, let me qualify this with the contributing factors of why I switched from PHP to Python: mind-blastingly awesome ORMs and template engines, real package management w/ versioned dependencies and a huge library of available packages, resident-in-memory and thus zero setup overhead per request and the ability to use in-process caches, integral bytecode cache w/ optimization levels (i.e. strip asserts, docstrings, and 'if __debug__' blocks in production), true threading support (important for full text search ranking and background e-mail delivery), and the fact that the language itself is far more internally consistent.

 

PHPAMF, as an example, only communicates in arrays, integers, and strings, and typecasts to integer eagerly.  This means that if my Flex application sends an MD5 that starts with a number, PHP sees it as a number.  (Real problem, fixed by prepending an 'x'.  That's stupid, let alone ignoring the other datatypes the protocol supports!)

 

bourgarelremi
bourgarelremi

 @asusmx While I agree with your argument (it's really hard to find a good .net 4 host) Do you really start a company thinking you'll be alone forever ? 

kschroeder
kschroeder moderator

 @GothAlice Support and maintenance costs are definitely one of the reasons why enterprises choose PHP.  In my own discussions with customers that often comes up as a significant factor in their purchasing of our PHP solutions.

 

And no, you could not convince ANYONE to start a new project using Python.  The reason that PHP is being chosen over Python to run web-based applications is not because someone didn't have the right presentation in front of them.

upr0
upr0

 @savire  @Mr CSharp 

 

You speak too much ... if you think php is a programming language I offer you object oriented languages then you will understand what our programmer's world works. if you claim php is object oriented I should tell you until you can not use page life cycle feature of object oriented programming method in php you can not claim that php is an object oriented language. php is a good language JUST FOR WRITE tiny exploit . I understand you son, I have so many students like you, please search more and write more program with object oriented languages I am sure you will notify how world works, or you can emphasis on your opinion and earn some little money.of course for those kind of programmer which compare any thing with money this is usual to be satisfy with some Peny or Cent. good luck Young Programmer. :-h

savire
savire

 @SeanJA  @upr0 I'm now lvl 99 with all those Microsoft certified thingy, lulz, ROFL.

GothAlice
GothAlice

 @savire  @kokopelli If there was any one single factor which clients would flock to, there would only be one programming language for any given problem domain.  Fact is, there's enough work to cover them all!  :)

 

As for haters saying stupid things, well, they have valid points, too.  The more time you have your nose buried in documentation means the less time you're actually solving your client's problem.  (Digging through docs = solving _your_ problem, not your client's.)  Having excellent documentation is one thing, but needing to use it often is a bad sign.  Again, from the PHP fractal article:

 

"A language must be predictable. It’s a medium for expressing human ideas and having a computer execute them, so it’s critical that a human’s understanding of a program actually be correct.  [PHP is full of surprises and unintuitive behaviour.]

 

"A language must be consistent. Similar things should look similar, different things different. Knowing part of the language should aid in learning and understanding the rest.  [PHP is wholly inconsistent.]

 

"A language must be concise. New languages exist to reduce the boilerplate inherent in old languages. A language must thus strive to avoid introducing new boilerplate of its own.  [PHP has more than its fair share of boilerplate, most of which is used for safety and security.]

 

"A language must be reliable. Languages are tools for solving problems; they should minimize any new problems they introduce. Any “gotchas” are massive distractions.  [PHP can be quite flakey, reference that odd MD5 as a number issue I mentioned earlier.]

 

"A language must be debuggable. When something goes wrong, the programmer has to fix it, and we need all the help we can get.  [PHP can be quite opaque with a lack of stack traces and overly complex error handling and reporting.]"

 

Debugging your code is likewise solving _your_ problem, not your client's, and is a direct symptom of a failure to adhere to the rules above.  Of course, given enough time you'll learn the quirks, the irregularities, the gotchas, and begin to code more defensively.  All of that headspace dedicated to the exceptions to the rules (or every single instance if there is no rule) can be put to better use more fully groking a problem domain, groking algorithms and patterns, etc.

 

Fact is, for me at least, in Python I very rarely, if ever, need to revisit a line of code I've written.  I've written a complete MVC web framework with grade-A features in the course of two nights, and that framework has been stable and nigh-on bug free (one security issue, two performance rewrites of specific functions, etc.) for three years.  I've written a hybrid async+threaded C10K HTTP/1.1 web server in pure Python in one day.  (It compiles to 171 opcodes!)  Boilerplate?  Near-zero.

 

Of course, use the tools you are most familiar with.  Use the tools that best fit the job.  Dismissing valid complaints because a "hater" doesn't agree with you, however, could pass for the definition of folly.

 

(And yeah, pairing hosting with project development is a pretty awesome way to maintain residuals after initial development is complete. :)

Alvaro
Alvaro

 @kschroeder I just said the truth. If you can not stand that, I am not going to waste my time with you. Time puts everyone in the right place.

GothAlice
GothAlice

@kschroeder @Alvaro I was initially worried about my posts being redacted, and I greatly appreciate the fact that they haven't been despite not agreeing with the principle of the article. :)

asusmx
asusmx

 @bourgarelremi   

 

I might not be alone forever, but I may not be with php forever either. At this point in time it is. A business plan is always changing. I have put aside .NET cause it wasn't the best tool then. If things changes and .NET ends up being the right tools, I will use it again. 

savire
savire

 @GothAlice  @kokopelli Yea anyone wish that for a language which can solved all problem. But the truth is "none" so far had been really done that. Because well "the universe" do love chaos because it's bringing new opportunities for new "thing" to be unfold and so the human problems is.

 

I do understand that python is had it's own advantages because well Google pick them as one of their based development languages besides Java. But to wrapped all your posting (Sorry I was away for this couple weeks due to my offline clients), I does not really care what languages used really as long as the problem solved with a fair discretion then it's fine because there's no such thing as 100% perfect codes, they will fail over time. Recently I do have developed using Python, PHP, Java, C at the same time for a client project since it's incorporating different platform and I could say that I love them all. Since I'm into game development I do use python and lua for scripting along with some C#. 

 

I'm also had done development in Pascal/Delphi, VB/VB.Net,C#,Java and many other languages peoples might does not heard of, lol, yeah I mean that and down to assembly languages for Micro-controller and say what I do loves them all because they had their beauty. Some of you called it their flaw but I called them it's their uniqueness. Each had it's own distinctive usefulness because each problem had their own set of  constraints. So it's actually depend on you how to use your experience on picking which of those languages can be used optimally to solved the problems in moderately optimal solution.

GothAlice
GothAlice

 @Alvaro  That was simply unnecessary.  <insert random personal attack here>  Note that by saying you're not going to waste your time you have proven yourself to be a liar… by wasting your time.  Good day, sir.

GothAlice
GothAlice

 @savire I don't, I really don't.  I've programmed PHP for about 10 years.  Python for nearly as long.  Perl for four years before PHP—I dropped CGI for mod_php like CGI was on fire.  Basic/Pascal/C since I was a child.  Interestingly enough, all of these things are free.  Unfortunately, maintenance isn't free, even if the language is.  No PHP code I have ever seen (and I'm probably up to the billions of lines at this point, what with running a shared hosting service) has been what I would consider easily maintainable.  I do honestly wish it weren't so.  :(

savire
savire

 @GothAlice Point is, don't judge any languages easily. The thing is you got time or not. Clients won't bother which languages you used. They just want their problems solved. So why bother being picky with the languages? It's just the tool, what's important is your programming skill. Yes I used most of the languages mentioned here with different projects either on inside a company or like now when I'm self employed. True when we self employed we will think about the budget since why spend thousands of $ when we could solve a problem with free $? That's what's called smart decision is.

GothAlice
GothAlice

 @kschroeder 1:1 mapping is why I switched from PHPAMF to PyAMF, also, performance since the PHPAMF PHP extension (at the time) broke associative array encoding terribly and Python has native support for compiled C extensions with dynamic loading at runtime.  (C modules are just like Python modules.)

 

I also use a dynamic endpoint configuration manager (with heavy caching, obviously) with the only drawback that misnamed calls only error out at runtime.

kschroeder
kschroeder moderator

 @GothAlice Too bad.  The Zend_Amf integration in Flash Builder for PHP had direct 1:1 mapping of PHP objects to ActionScript value objects and the PHP service endpoints were automatically added into the ActionScript/MXML code.  

Latest blog post: Loudness Wars - Premonitions

GothAlice
GothAlice

 @kschroeder Alas, no, I switched to Python long ago and added PyAMF support to my web framework, WebCore about two years ago.

Trackbacks

  1. [...] Comments I recently read Kevin Schroeder's blog post about 10 Reasons To Use PHP. Then — silly me — I started reading the comments. It only took a few before the obligatory [...]

Post Navigation

Web Analytics