Why PHP won
startuplessonslearned.blogspot.com
startuplessonslearned.blogspot.com
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.
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.
Very interesting. Please elaborate!
So I believe icode, personally. My feelings are "good for him" and "I hope he enjoys his steak and strippers".
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.
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.
I don't understand though, why PHP is being compared to JS, when they solve different problems.
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.
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.
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.
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.
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.
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/
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.
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.
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.
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.
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 )
Maybe all the "better" languages are a case of misdirected optimization, where the critical resource is developer time?
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.
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 :)
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.
This article is just for a bunch of fan boys to pat themselves on the back for picking PHP.
PHP hasn't won anything.
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.
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.
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?