Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Why PHP won (startuplessonslearned.blogspot.com)
100 points by eries on Jan 16, 2009 | hide | past | favorite | 59 comments


This article is totally barking up the wrong tree. PHP's growth had little to do with its appeal to programmers, and lots to do with its appeal to shared hosting providers. Safe mode is what I'm talking about.


I have been a coder all my life and PHP very much appeals to me. I used Assembler, Basic, Pascal, C++ and a couple of other languages and now that I code in PHP, its the best part of my life.

It enabled me to write multiple hugely successful websites that make me enough money for me, so I can do whatever I want. For the rest of my life.

I really love Linux, Apache and MySql. So doing things in LAMP is just great for me.

Hosting is a big part of my business, so yeah - its cool that PHP is all around. You can get new servers for no money in seconds.

Its a wonderful world. Im so happy, there is LAMP. I never used Perl, Ruby, Lisp or Arc. So I cannot say anything about these. I can only say I dont miss a thing with LAMP. I have a LOT of complaints about HTML and Javascript. I hated using Microsoft stuff. LAMP was the breaktrhough.


Wait, was this a joke? I honestly can't tell.


I don't think it is. The bleeding edge of Web 1.0 or even Web 2.0 development required a LAMP stack.

The author says that compared to programming desktop applications (all of the languages he mentioned), the web based stack of MySQL, PHP, and Linux better allowed him to create apps that users wanted.

Developers who started with PHP and moved up to Ruby and Python may not realize that older developers who started with Assembler, Basic, and C++ find any kind of web development a huge improvement for them. And, a productive single person would by definition try to extend and improve their app instead of learning new languages unnecessarily every 6 months.


Not only compared to desktop applications was LAMP a huge advantage, but also compared to Microsofts Web-Technologie (IIS,MS-Server,ASP and later .NET). I was able to create apps the user wanted in the years I used MS technologie, but I did not like it very much. When I discovered LAMP it was like YEAH! and I stayed at home and coded away for weeks and some great stuff came out of this.

As for the language (you mention moving "up" to Ruby or Python), I dont really care if I do

  str_replace('stuff','zen','stuff and the art not to care');
or

  'stuff and the art not to care'.kickasstransform('stuff','zen');
or whatever the latest hottness is :-)

When it comes to things that matter, I dont miss anything in PHP. For example, Javascript is a cooler language, because it has first class functions and all that crazy shit. Ok, I dont mind that. But on the other hand, I HATE with a passion that "a=7" will by default put "a" into the global scope in Javascript. That outweights all the advanced tech in Javascript.

But the language itself is not the most important factor. Most important is all the stuff that surrounds it. When I use PHP, I get new servers within a click with any company i choose. I get the LAMP stack installed by putting an Ubuntu CD into any machine, install it and do "apt-get install php5". On IRC, there are tons of people on freenode#php (there aint many for Ruby for example). And there is a very nice manual at php.net and so on.

And VERY important to me is the whole feeling about how L,A,M and P are implemented. How I can use php on the command line, how I can start mysql from the command line and give it commandlineparameters, how one table is represented in MySql (one file for the structure, one file for the data and one for the indexes), how a database is represented in MySql (a directory)... There are millions of things I like. And they make me feel that the people who wrote L,A,M and P at least partly think like me. Thats cool and makes me productive.


There must be something about a language that helps it map to our brains. The creators of the language must be "like" its users in some way for the language to make sense. Or perhaps it's the language that is the mapping between the way the world works and the perception of that world in the minds of the users and the creators.


I didn't mean to imply PHP couldn't be used successfully (it certainly can), rather the post sounded blissfully ignorant to the point of sarcasm. Perhaps "ignorant" isn't the right word, though ignorant of the "better" languages.


I think I know what you mean. When I read it, I got the same impression. It's not ignorance, because what the post is saying is true. LAMP does do all those things and it is very smart in many ways. But the things listed are equivalently true of other languages and programming platforms as well.

I don't understand though, why PHP is being compared to JS, when they solve different problems.


> It enabled me to write multiple hugely successful websites that make me enough money for me, so I can do whatever I want. For the rest of my life.

Very interesting. Please elaborate!


I prefer to stay anonymous. But its probably a very typical Nerd 2.0 story like the ones you hear at this website often. Only that I always stayed in my room and didnt connect to any other web2.0 people. No Blog, no press releases, no ycombinator, no investors. I just wrote some stuff that people want and got some good return from it.


Without revealing your identity, perhaps you can share what mistakes you made, what you learned etc...?


OK, then we don't know if you're really a loser trying to appear successful so we'll listen to you on PHP.


One of the aspects I love about HN is that nobody here has to prove anything to anyone else. Maybe I'm terribly naive, but it feels like lying happens far less here than in other corners of the tubes.

So I believe icode, personally. My feelings are "good for him" and "I hope he enjoys his steak and strippers".


True. Usually because it's very easy to identify and call out anyone who doesn't know what they're talking about.


Very true. And you bring up a good point. If nobody was accountable for posting nonsense, then the discussion would probably contain a lot more of it.

I'm just making a personal choice to give icode the benefit of the doubt. If he's uneasy about broadcasting his difficult struggle to tens of thousands of people, then that's entirely his personal choice, and I'm happy he was willing to share few details about his experience.


Any tips or a blog where you share your ideas for the ones who want to follow your steps?


Im not that good with words. That outburst of delight I wrote above is probably one of the better posts I wrote. Who knows, maybe Im getting better at this. Then I might start a blog one day.


You're killing us here :)


Suspense. Well done Icode.


I wish I could upmod you more points. That's 50% of the reason right there.

mod_perl was a far superior solution, and you didn't have to restart Apache every time. However, this was not the default configuration, which is apparently enough to deter decently smart people.


I think your point can be summarized most plainly by saying PHP is cheap to host. I don't doubt that is a large part of its continuing popularity. But it is begging the question: Hosting providers didn't force PHP on the world, they met a demand. Where did that demand come from?

I don't think its technical merits (such as they are), community, documentation, or appeal to hosting providers is to blame. I think the answer is rather simpler: PHP was the only language that tied itself to the "build a website" niche in both its implementation and its marketing. Sun's contemporary efforts with Java were scattered and, even in the web domain, more focused on applets. PHP had "build a website" written all over it.

In short, I think it comes down to the old adage: location, location, location. PHP was perfectly positioned. The web boomed, and PHP rode its coattails. Anything with even the slimmest virtues could have succeeded with such good placement. In fact, it did.


I agree somewhat but there are other factors. You can't tell me that every web host worth their salt didn't (or doesn't) offer up a cgi-bin directory.

I would characterize it as this: PHP is a Perl-like language that is entirely web oriented.

Because Rasmus built PHP to make web sites it was oriented towards the web from day 1. Since it's similar to Perl (dynamic typing, just-in-time, etc) it's easy to learn and flexible.

However, unlike Perl there was no existing community with a non web focus. This made it very easy for the PHP community to rally around web projects and achieve all the things that made it good for the web and hence extremely adoptable.


Good article. To add a few things:

1. PHP doesn't require routing. It's done for you by Apache to the PHP file at that location. Sure, you can go the way of nice frameworks like Cake and add routing for nicer URLs, but it's not required. PHP has some solution built in.

2. Deployment. The author touched on having to restart when using mod_perl, but it's more than that. In most cases, uploading files is enough. That's why it became so popular with shared hosts. Anyone with a little knowledge could do it without the host having to give them permissions to do stuff.

3. PHP was very big on re-use in the large. Basically, re-use in the large means creating a calendar app. Re-use in the small is more like creating a framework that makes it easier to create a calendar app (ala Rails/Django). So, when you're starting up, it makes it easy to show friends something really working fast. And that builds mindshare that continues on as programmers do more things.

4. Loose typing. This is probably one of the huge ones. Many languages are dynamically typed, but if you're developing in Python or Ruby, you have to cast between types. PHP says, "don't worry, I know what you mean!" I'm personally not a fan of loose typing, but I can understand why it helps PHP gain followers (esp those new at programming).

However, I kinda disagree with the author's thesis. The author argues that PHP's community backs the language so well. I'm less inclined to agree with that. During the day, I'm often working on PHP stuff and I'm constantly finding the code already written to be sub-par. Part of that is that PHP is accessible enough for those who don't understand program design to convince themselves that they're a good programmer. And so many things written in PHP might be from people who wouldn't be able to answer "what's the difference between a binary search tree and a linked list and give an example when you would use each." Not that data structures are the only thing to judge a programmer by, but you get a lot of people in the PHP world that use the guess and check method. So, the community isn't worth as much to me because I don't have such faith in their code (while I find the Python modules I look at to be of good quality).

PHP will continue to be a dominant web language because it's easy to pick up. However, I guess I'm looking for something else.


Agree with your additions completely and would amend your #3 to say that PHP was big on re-use in the small, as well. I've known folks starting out with PHP who cobble a script together by copy-pasting snippets of code from here and there. Inelegant, yes, but when you are working on a small project it was usually effective.

This leads me to one point about PHP's documentation that I was surprised not to see. Their documentation has always (as long as I can remember, at least) had public comments. On many occasions questions I have had or example code I needed was crowdsourced by the public and located in-line below the function reference. I have been surprised other platforms don't make more extensive use of this.

Finally, in response to your "I guess I'm looking for something else." Understand your discontent - I've felt it myself over the past couple years and have found myself toying with Djagno, et. al. This fall I found myself returning to PHP with a mission to create a framework that I could use and not feel shamed to be in PHP. It's still early in development (4 months) but I believe it is looking good and getting exciting. It's called Recess, check it out sometime: http://www.recessframework.org/


I'm a bit surprised that he didn't mention that PHP has very good documentation - virtually every function has a plain-english description (translated to multiple languages) followed by several usage examples and snippets that solve common real-world issues.


Yeah, clear documentation was _the_ reason I used php. In fact, it's the same reason jQuery has become my javascript lib of choice. When documentation is complete and centralized like that, the barrier to entry is vastly lower.

Rdoc tries to be that for ruby projects, but it still feels like a step backwards. Google lessens the pain somewhat, but it's still nice to just hit php.net/manual/en or api.jquery.com and find everything I need.


You can also just hit php.net/whatever_you_are_looking_for and it will either redirect to the docs for the most likely function or suggest functions with similar names.


I agree, the PHP documentation is pretty great. And the user notes, while sometimes hit and miss, are usually fairly useful too. Often you'll find someone who's trying to do exactly what you are, and they'll have a way to do it, and then other people will post better ways. It's a pretty cool system.


Item 2 should not really be a problem unless you are using cheap shared hosting. You should test your stuff on your workstation, not on the server. If you do not test on the server, the whole restart apache after you upload something becomes moot. Also, if you happen to change many files, what will users see in your application when half of the site uses new logic and half of it used the previous one? This is a nasty habit.

Loose typing is the cause of many, many very difficult to find bugs. Nobody should ever be exposed to that.

As for the code already written being sub-par, it comes with the low entry barrier. The easier it is, the more people who shouldn't program will program in it.


I think the point is that PHP grabs people when they're on cheap shared hosting and they continue using it as they build more complicated stuff.


And it's only recently with the rise of virtualization that we have any options besides cheap shared hosting and horrifically expensive dedicated server/colo.


To summarize it, I would say PHP is the "get shit done" language. It allows people who are just starting out with programming or people who aren't very technical to focus on what they need to have, rather than on the best way to do something. This is why so many websites (Flickr) and OS pieces of software are in PHP - they focused heavily on what users would be seeing, rather than what developers would be seeing and won out.

Of course, PHP doesn't preclude good design either. Once you have a working product that is excellent on the outside but ugly on the inside, you can start spending more time refactoring your code, or even slowly migrating your system piece-by-piece to another platform.


The question remains, "What did PHP win?"

I don't mean to be a jerk here, but just saying why something is good doesn't mean it wins. Lots of languages are good and I could list lots of good things about lots of languages that would make <i>them</i> win.


PHP is the language that got me to where I am now. In the last 2 months, I've started diving into server-side javascript and have been working with a couple of small projects that are working to bring out widely usable solution. Its really only been in the last year that I've started sniffing when I have to work in PHP. Its been my bread and butter for 4 years, but I've gotten to the point where the inconsistencies in the overall naming schema are annoying (is it "(x,y) or (y,x)" for this string method?). Deployment is super easy with PHP. I think one thing the author missed is that Java is (unfortunately) the primary language taught to most beginning programmers in college. This fundamentally shapes their budding programmer mentalities. PHP has served a similar role as a way for a lot of people like me to get into programming that didn't do much college and are completely self-taught.


"The platforms that win on the web are those that mirror its fundamental structure, not those that try to morph it into a more traditional "elegant" shape."

This reminds me of why C succeeded, because it mirrors Unix so well, that C and Unix succeeded hand in hand. So this part about PHP mirroring the shape of the web made the most sense to me, as someone who doesn't know any PHP.


>C succeeded, because it mirrors Unix so well

Actually, Unix succeeded after it was rewritten in C. (Not counting the very first Unix version which was done in assembler. See http://www.livinginternet.com/i/iw_unix_c.htm )


jimbokun's point was that C and Unix succeeded as a pair, which I agree with. C allowed Unix to be a portable OS, and the proliferation of Unix meant that everyone who did systems work learned C.


You know, after seeing over and over how the supposedly worse ways actually worked better - perhaps it's time to re-decide what is actually good and bad in a language?


It's the old worse is better thing all over again: http://www.jwz.org/doc/worse-is-better.html

Maybe all the "better" languages are a case of misdirected optimization, where the critical resource is developer time?


It just depends where you are in terms of experience. It's not that one is good or bad. PHP is easy to understand, and you can jump right into it with no experience. However over time if you have any potential as a serious programmer you will find the pain points and repetitive tasks.

In many ways, experienced programmers and language elitists are a lot like corporations. They are risk-averse. The reason best practices are what they are is to avoid known problems (sort of like bureaucracy). This will make you a better programmer to a certain point, but it's also so easy to overestimate risk. The painful truth is that a 20-year-old hacker figuring out things as he goes may be able to plow through the naive problems he inevitably creates and arrive at a finished, valuable product faster than a seasoned developer who writes uber-maintainable code with a comprehensive test suite and every best practice he can lay his hands on.


The ecosystem a piece of software is attached to is tremendously important. PHP did a great job with fitting into the existing one. It's not that PHP is better. It did a better job in the most critical ways. (It was also decently fast.)


the argument against this is usually performance and code maintenance. writing something in a strict but clearly articulated language means there's a better chance the next person looking at the code will be able to figure it out. that said, php in many ways better reflects the opportunists in us all and is more familiar because of it. by using a hodgepodge of conventions all abstracted away from their parent languages into the same compiler, php lets us pick from a much wider palette of metaphors when we're conceptualizing how we approach solving a problem. which can be pretty damn useful for those of us who don't know all the answers. it feels as though it's designed for us (messy) humans.


Most importantly, back in the day 1998/1999 there was not much around that could match up to the functionality of PHP. Java servlets were not supported widely, Netscape had their serverside javascript wich required you to buy into their servers... Going with PHP was a no-brainer for any small web-shop/startup. With all the web stacks that are available today, it wouldn't have been that clear.


I didn't realize that the game was over, and PHP won. Guess I should pack up and go home.


did you realize that no one can be a hacker if they don't think PHP is so l33t that ur just not cool if you don't get it! what do you mean have i ever used java? what does that matter, PHP is awesome, so java sucks.


Also, PHP runs everywhere. right now. Nothing to install in most cases. That's one of the reasons it is winning the open source code base wars (SugarCRM, Wordpress, Drupal, etc. etc.).


as a former client used to say to me, "if i wanted a django developer, i could hit a few websites or forums and maybe find one. if i wanted a php developer, i could walk out into the middle of the street and start shouting, and find several very quickly."


Without getting off topic about what a good programmer is etc - One thing to point out that is relevant is the fact that there are a lot more beginner programmers than non-beginner programmers out there - all the content being generated around forums for performing specific tasks (code snippets and QA) created an insane feedback loop for the PHP community - I think that this is where PHP really beats out everyone else - There is much more google searchable support than any other language out there. Fast ROI of your time/instant gratification which fuels beginners to learn more/ask more questions generating more content and answering more questions.


I'd love to refute this article, because it's incredibly depressing to suspect that it's on the money. There's not much hope for software engineering if the features that make for a poor language are also the ones that make it popular.


There's no much hope in engineering at all if you don't give what its users are looking for.

While I am on it, not one of the article's points is about the language design or syntax. Maybe the fourth, about OOP, but it says something else: It's not really about OOP, but making what users want to do (grab form data, insert into db) incredible easy. The author makes the mistake to confuse OOP with bloatness, which is wrong in theory but right in practice. A lot of people that make web apps in Java make it utterly complex.

My point is that Python, Perl, Java, or any other language can do points 1, 2, 3 and 4. But they didn't (not blaming anyone here, just saying that it wasn't done), so you can have a nice engineered language, but they need to provide these four things to be more sucessful on the web. One thing doesn't exclude the other... but someone needs to do it :)


It's popular because it's a great platform, not because of its poor language design.


In the late 90s, when I began making webpages, there was a mysterious folder in my shared hosting FTP account called "cgi-bin." What is "Bin." I was on Windows. What is "CGI." A friend told me it had something to do with Perl. I didn't know anything about Perl, and everything I found on the web about it was difficult to understand.

After some experimenting with FrontPage extensions, I began to experiment more. I found a site called Matt's script archive that had Perl CGIs that I could actually understand. It was slow, slow going. I was coming from QBasic. I scoured the Web, mixing and matching bits of example code I'd found to make things like random quotation generators. Then a friend showed me something called PHP.

PHP, to me at the time, wasn't just a language - it was an ecosystem of developers, example code, and practices that was flourishing. There was consolidated documentation. There were global functions for any string operation I could conceive. But most importantly to me at the time, there was an active community who was interested in more than showing off their most arcane, clever, and obfuscated programs. Very early on, the PHP community could be characterized as "welcoming."

I would argue that PHP "won" not because of any innate technical superiority over any of the other languages available for web programming in the mid to late 90s. It won because it had the right kind of community for a new breed of developer - the "web programmer." It didn't have the stigma of snootiness that came with trying to figure out Perl. PHP was not for geniuses or academics; PHP was for people who wanted to make dynamic websites and not have to catch attitude from some asshole in IRC about not knowing what tail recursion is.

I don't use PHP anymore. I don't like PHP any more. I got into Java, JavaScript, C, even Prolog; and now, I'm into whatever will save me time, and scale. Language agnostic. I'm into parallelization and web services; why would I use PHP for anything more than toy projects? Yes - PHP is "easy." But at my current (thankfully temporary) job, I'm in charge of adding features and debugging a massive functionally-written PHP codebase. It is horrifying.

I think PHP is a great language for anyone to learn how to program with. I think there's a lot of shitty PHP code out there and it's easy to make a living by billing yourself as a PHP developer. It introduced me to "C-like" syntax of brackets and semicolons. It's an easy way to learn how to do neat things with SQL. Beyond that, it really just sucks, and no matter how much more crap they add on to it, I think it always will.

So what is the lesson here? PHP won because it had an excellent community. The Ruby/Rails uprising of the past few years reminds me a lot of the early PHP days. PHP made it easy for independent, inexperienced programmers to create dynamic web applications. Which was great. But having grown up and seen the world, I've rarely seen or worked with small teams of professionals, fluent in several languages, who have decided that PHP is the best way to implement a website. But hey - whatever floats your boat.


Also, don't forget the nice support for php (using fastcgi) on iis 7/6 http://www.iis.net/php


Exactly what has PHP won? Most IT jobs aren't looking for PHP programmers. They don't make the most money. The most impressive websites are not built in PHP. PHP programmers don't have the most 'skills' so to speak. They aren't the smartest, contrary to their own opinion.

This article is just for a bunch of fan boys to pat themselves on the back for picking PHP.

PHP hasn't won anything.


It was the safe and easy install for shared hosting providers plus the easy deployment for web devs.

Really, it's a simple recipe. I'm still wondering why Perl/Python/Ruby/$fave_lang doesn't just mix together the same ingredients and do the same thing.


Some of the greatest works of literature were written in German.


PHP won because mod_php was well done. The language isn't especially relevant. Perl's mod_perl was simply a no go for the typical hosting scenario because it gives way too much power to users to screw up the server; you can't realistically set it up for basic shared hosting.

mod_perlite is a new piece of software that brings a php style system to perl. It's mod_perl made suitable for typical hosting needs.


Interesting. http://www.modperlite.org/

The interview by chromatic was quite informative. Unfortunately, they say that they're forced to repeatedly reinitialize the perl interpreter with every request. This would seem to defeat the purpose of having a persistent perl, no?


php's popular because it's easy to get started. name a file .php and put it on your shared host and your code runs. unfortunately php doesn't get anything else right. i say this having used php for years. eventually you find that it wastes more time than it saves in the beginning. it is a terrible language with a terrible history, and i expect the future to be similar.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: