Loud thinking declares that Java has lost its aura of invincibility. Jason Hunter sums it up nicely:
Ruby on Rails today looks poised to eat Java’s mindshare on the web tier. If not Rails, then something else.
It does seem like Java’s mindshare is on the decline, along with sun’s fortunes. There is some evidence that rails is drawing mindshare from PHP as well. (Mind share is the grown-up way of saying “what the cool kids are doing.”)
So why isn’t PHP that something else?
i think its the unit testing, “You aren’t gonna need it,” “Do the simplest thing that could possibly work” folk that are dismantling Java’s mindshare. As they gain it, Java loses it. Some of that is showing up in the java community itself in concepts like POJOs and dependency injection. Some of it shows up in an exodus from Java to dynamic languages.
So why are the agile leaders like Martin Fowler and Dave Thomas working with Ruby instead of PHP? David Heinemeier Hansson directly credits these guys with influencing his decision to stop programming rails in PHP and move to ruby. I suspect that its the dynamic, smalltalk, like features of Ruby that appeal the the agile methods leaders.
Rails could have been a PHP framework, but wasn’t. Although, I’m not sure that it would get the attention it is if it were a PHP framework. The rails, ruby combination may be greater than the sum of the parts.
I can’t speak for anyone else, but I have some ideas about why PHP might not appeal to the agile method and java is too complicated folk:
- Too many globals – globals make unit testing more difficult and prevent integrating work from different developers, let alone different organizations.
- No culture of objects – PHP has made great strides in this area, but I don’t get the impression that many of the folk that work on and with PHP really buy into object oriented programming the way that the agile methods folk do.
- Crowded namespaces – How many functions is PHP up to? Constants?
- incomplete component model – This is another integration thing. PHP has too many islands and not enough continents. (I’m talking beans here, but definitely not EJB.)
- No mature frameworks – Ruby has been around a long time, but didn’t really start gulping mindshare until Rails came along. See The Value of MVC.
- No closures – Its a dynamic thing.
- Expert level gotchas – hopping on the learning curve is easy. Reaching the top, not so much.
I’ll elaborate on each of these points in a series of upcoming posts.
I’ll close by saying that life is not a zero sum game. The success of Ruby and Rails does not diminish the success of PHP. The cool kids were doing Java and now some of them are doing Ruby. Oh, well. Its disappointing that more of them aren’t doing PHP, but PHP has many things going for it. That, however, is a different series of posts.
I think that the recent thread on Sitepoint is much more a microcosim of why there is a dearth of things like Rails in PHP. It is a difficult to create standards that appeals to a large group of PHP developers because of our diverse backgrounds. And the bigest divide in PHP is from those coming from Java/.NET and those who do not.
There is also a major flaw in your premise. Java is primarily used for coporate web development and as a general programming language. PHP one the other hand is a language that has allowed millions(?) of people, from non-programmers to enterprise developers, to build web applications. So you have a bunch of domains here and you haven’t indicated specifically which one(s) you are talking about.
I think you are specifically addressing the group of developers for which something like Rails solves problems in the domain in which they program. I would say that a better analysis is that Rails meets the needs of developers who are not well served by Java or PHP because their application are not so large or so small as to fall neatly into those camps. And that the purer OO of Ruby has an appeal to those with strong OO opnions.
Perhaps another point against PHP is it doesn’t really free you from C the way languages like Perl, Python and Ruby try to.
Consider Perl’s LWP (http://cpan.uwinnipeg.ca/module/Bundle::LWP) for example – at a guess it may be the most widely used networking API in existence and the layer your scripts will interact with are all written in Perl. Can think of many similar examples.
But PHP is a different story. Yes there are good libraries written in PHP but I can’t think of any that have the relative acceptance of something like LWP. What library API, written in PHP, is everyone using? Perhaps the closest is Johns ADOdb but still not everyone’s taste – by contrast, although perhaps not a fair comparison, DBI is effectively the only way you’d talk to a DB in Perl (of course DBI isn’t all Perl – PDO is closer to DBI).
Essentially if you want to write an library / API that PHP coders will adopt, you have to do it as a PHP extension.
Reasons numerous but when you consider fundamental silliness of http://www.php.net/soap (which is in itself useful), arguments about performance fly out of the window (who cares about 0.1ms here or there when you’ve got network latency?). PEAR::SOAP was way more mature when ext/soap got under way. Even wierder side note is ext/soap never spun off an HTTP client API, despite having done that from scratch as well (http://cvs.php.net/co.php/pecl/soap/php_http.c?r=1.78).
Not meaning to gain any credits here, but you may want to take this into account for your future ellaborations: There is a project called Cucua (http://cucua.tigris.org); it’s goal is to provide an enhanced class library for PHP5 based on the public Java API.
And about that ongoing Ruby vs PHP discussion (which has become a hot topic since Rails): For sure, the main reason for Ruby’s success regarding web development are the enhanced language specific functions implemented in Ruby which can make the developer’s life somewhat easier. I’m sure PHP could keep up with this, but I somehow have the feeling that PHP is right now split up into two divisions: The community, which proposes suggestions on how the language itself should change to extend the functionality and the handling of the new OM, and the core developers themselves who seem to act kind of bulky regarding those feature requests.
This might be OT, but if PHP wants to keep up with Ruby and does not want to become “your regular scripting language on a shared host”, then I see a strong need in a better community process and even more communication between the hardcore users and the core developers…
[...] interessante gedanken auf Professional PHP … welche sprache folgt auf java, warum ist php nicht für die agile entwicklung geeignet, wo liegen rubys stärken … ? [...]
Shouldn’t badmouth the language of my choosing, but cannot agree more on this one.
PHP certainly lacks the meta-programming (or if you wish “high-order programming”) power that Ruby, Phython, or even Javascript has.
The new object model in PHP5 certainly got us excited for a while, but the overall funtional programming gadgets are still missing (or may never come handy). The new reflection API and tokenizer extension (and perhaps also the classkit extention) may rescue us to a limited extent but all that does not amount to a nifty solution.
That said I am still a PHP lover. Proof is EZPDO.
I was a PHP enthusiast for a couple of years, to the point of developping yet another PHP object framework.
I stumbled on ruby on rails not on the web, not even in a technical magazine, just in an article of an ordinary news magazine (French Courrier International) !
Looked up on the web, bougth books, got hooked.
With PHP I had to bend the language to build an OO framework (names conflicts control !) and experienced the fact that apart from not having to worry about pointers code is pretty much like C++ (I do love C++, but not for Web dev.).
In contrast Ruby looks like a mature OO language and rails is what my framework should have been had I entirely succeeded (blame on me not PHP
. So It looks like the natural point where to start again from.
Though I could havelived with the language’s shortcomings be the lack of consensus around one OO framework (or a reasonably small number of them) will cause PHP to loose its momentum.
Now what has alredy started to happen is migration from PHP ro rails : keep the DB schema ans rebuild the rest thanks to ActiveStore.
So I’m afraid the problem with PHP is first ans foremost a fragmented community (procedural old-timers vs agile OO developpers).
The era of NukeXXX is coming to an end, what’s thefuture of the blue elephant ?
[...] Why isn’t PHP the natural successor to Java? [...]
[...] A Rails clone? It would be pretty obvious who the competition is then. [...]
I don’t know exactly but coming from PHP to Rails I can say a few things why I switched
1. I hate writing boilerplate code
2, PHP is very verbose
3. The OO features put in look like they are made to set a point for the Big Execs that “PHP is like Java”, not to be convenient.
4. I appreciate that you don’t have many concurrenting projects in Ruby and quite some class (compare PHPDocumentor and rubydoc, or PEAR and rubygems – not only as technologies but by mindset).
[...] O’Reilly radar has an interesting graph of 2004 versus 2005 book sales for a variety of languages. The big news is that Ruby books sales are up 1552% and Java book sales are down 4%. This would be consistent with my observations from Why isn’t PHP the natural successor to Java. A small cadre of agile minded developers are giving Ruby a spin. [...]
[...] The departure of the hyper-enthusiasts – “The Java hyper-enthusiasts have left the building” (along the lines of this.) [...]
[...] This is a follow up post to Why isn’t PHP the natural successor to Java? [...]
[...] PHP seems to be holding steady, or slightly declining. But, Java is waning, as I discussed in Why isn’t PHP the natural successor to Java?. C# seems to be steady and slightly increasing, while Perl is steady and slightly decreasing. So where are those Java programmers going if not PHP? Are they going to Ruby and Ruby on Rails? [...]
[...] I don’t disagree with the cultural grouping. PHP’s cultural heritage is definitely in the Unix programming, C/Perl camp as I suggested in building a culture of objects in PHP and Why isn’t PHP the natural successor to Java? [...]
I don’t agree with Julik on PHP verbose interpretation. Readability of the code depends mainly on the individual programmers. Documentation of Rails is not good. Must say that Rails framework is nicely done but if you take look from business side you will still go with PHP. Eventually, Rails is very good but not mature enough and framework is not that popular.
I think, as stated before, that most of PHP programmers do not use OOP and you have not some tools like EJBs and containers.
But PHP is still one of the fastest programming language i think.
I hope someone would improve these aspects in PEAR APIs, or something.