On Wednesday in Frankfurt at the PHP International Conference I gave a fairly general talk on issues in Web frameworks. I had fun making a graph comparing Java, PHP, and Rails, and you might enjoy it too. [Update: Theserverside.com has a grossly inaccurate flame-bait take on this, and won’t let me sign in to comment; won’t take my password, and also won’t take the one they email me when I say I forgot. Grr.] [Update, February 2007: There’s now a Korean translation by CHOI Jae-Hoon; thanks!]

The Context · The problem at hand is Web Application Building. Thus we are not considering general issues of compute performance, because in Web apps, you don’t do much computing. You get some values from the browser, you use them to pull some info out of a database, you report them to the user, maybe you update the database, and that’s about it.

Here’s the graph, followed by some applications.

Comparing Web Frameworks

Scaling · If you’re actually doing any computing, Java is obviously the fastest. For running web apps, the maximum scalability is probably about the same, because there’s not much computing there. After all, Java runs EBay while PHP runs Wikipedia and Yahoo! Finance. Both clearly scale “well enough”.

For Web apps, I’ve given PHP the edge, because I think building scalable PHP is a little easier. By default, PHP gives you a “shared-nothing” (or at least “shared very little”) architecture, which means you’re going to scale out pretty well until your database hits the wall. Java is a much richer system and assumes you’re smart enough to know whether a shared-nothing architecture is appropriate or not. The effect is, you have to be smarter to get the same kind of scaling out of Java.

As for Rails, I think it’s probably the case that you can build a Web-scale app, just like Java and PHP, but we don’t know because nobody’s done it yet. Also, we have to penalize Rails a bit because most apps end up having a little computing in them, and Ruby is quite a bit behind the alternatives in that department.

Development Speed · The question is “All other things being equal, how fast can I get my Web app on the air?” I think Rails has set a new benchmark here; you keep hearing astounding stories of serious applications going up in days rather than months and weeks rather than years.

Having said that, Rails’ sweet spot (CRUD-oriented greenfield apps) is well-understood; but still, it seems obvious that Rails has some lessons to teach that the rest of the frameworks would do well to learn from. And I’d argue that the current direction of Java EE is evidence that that learning is happening.

PHP’s original claim to fame was that it was the quick-and-dirty way to get a Web app on the air. There’s no point trying to sweep the “dirty” bit under the carpet; a lot of those quickie PHP apps are butt-ugly. One of the reasons Rails is interesting is that it’s quick and clean.

Developer Tools · Application building and maintenance isn’t a sprint, it’s a marathon. Your overall results in the long term are going to depend a lot on the quality of your tools. Happy developers are productive developers.

Java is the obvious winner here, by a mile. Granted, Rails has TextMate and PHP has the Zend stuff, and while there is work over in Eclipse to add support for both PHP and Ruby. But the comprehensive, integrated, polished, fast support that a Java developer gets from NetBeans or Eclipse or Idea is miles beyond any of these things. I’m not really up-to-date on Eclipse or Idea, but if you look at the recent NetBeans 5.5, the amount of automated support for Web-app development is astounding; if I’d been graphing NetBeans instead of Java, I suspect it’d have equaled or passed PHP in the development-speed department.

Maintainability · Good apps, once built, tend to be in production for an astonishingly long time. Which means that they have to be maintained for an astonishingly long time. Which means that maintainability is important. There are a lot of things that go into maintainability, but I suggest that the biggies are object-orientation, MVC architecture, code readability, and code size (less is more, a lot more).

This is PHP’s Achilles’ heel, of course. Yes, it is possible to write clean, object-oriented, modular, MVC-style PHP applications. But most people don’t; the majority of apps that I’ve seen have spaghetti PHP code wrapped around spaghetti SQL embedded in spaghetti HTML. Also, a lot of the people who really understand O-O and MVC and maintainability would rather work in Java or Rails.

I’ve put Rails ahead of Java just because there’s so much less code. The maintenance cost of code is strongly related to its size. Clearly, Java’s excellent developer tools make a difference, but still, I think that this is another area where Ruby and Rails are teaching lessons the rest of the industry would do well to learn from.

Omissions · .NET and the Python frameworks, starting with Django, are notable by their absence here. Sorry; I just don’t have any first-hand knowledge on them. And .NET isn’t open-source, so why would you use it?

Irritants · I’ve already got people mad at me, because they think I said “PHP is faster than Java” (I didn’t) and because I said Rails is faster to build and more maintainable than PHP (I did, and I stand by it).

Obviously, there are edge cases; I’m sure you can find examples where Rails runs faster than the alternatives, or a Java app can be built fastest, or there are superb PHP dev tools for some type of app, or there’s a horribly-architected unmaintainable piece of Java framework crap.

What Matters? · The question “Which of Java, PHP, and Rails is best?” is just silly. The answer, as with so many engineering questions, is “it depends”. My personal opinion is that for most Web apps, scaling isn’t really a good basis for making a choice; if you have a decent application architecture, you can make any of these scale enough, and if you don’t, you can’t.

Importance of Web-framework issues

In recent years things like PHP and Rails have taught us that development speed is more important than we thought it was. On top of the obvious business value of delivering functions faster, there’s the Agile/XP view that you really don’t understand a feature till you’ve built it, so the faster you can build them the faster you understand them.

Developer tool quality is something you ignore at your peril; application development and maintenance is an endless grind, and you’re going to be a lot happier at work, long-term, living in a tool like NetBeans or Eclipse.

Maybe it’s just because I’m a grizzled 25-year veteran, but my feeling is that in the real world in the long term, maintainability is a really really big deal, the biggest of all.

Out there in the wild woolly “Web 2.0” world, maybe getting it built quick is all that matters, because after you’ve knocked ’em dead and been acquired, you can use the money from the Yahoo! buy-out to rebuild everything right the second time. In the enterprise though, I kind of suspect that smart developers and smart managers know that for real apps, the big development cost starts to happen after they’re delivered.

Whatever; you have to make your own choice based on your own application, business, and people constraints. That’s not controversial.

PS: Integration · This stuff was only about half my talk. The other half was about integration; your stack’s internal integration, about integrating with Identity technology, and about the general problem of heterogeneous framework integration across the network. That part was actually more interesting.


Comment feed for ongoing:Comments feed

From: John Cowan (Nov 10 2006, at 10:29)

I look forward to a fragment on the other half, then.


From: A Happy One (Nov 10 2006, at 11:19)

Regarding scalability:

It always surprises me why people always compare Rails "framework" with other programming languages that are not frameworks by definition. If you take bare-bone Ruby and compare it with PHP, you might be quite surprised. Assuming that you are using as much of native extensions as possible which is the case with PHP. From my experience, Rails adds a huge overhead to the request processing. Also try to compare something like CakePHP with Rails, you will be even more surprised.


From: Bill Pierce (Nov 10 2006, at 11:20)


All good stuff.

You and Jay Fields are slowly bringing me around to Rails, but I have to keep you hones when you say things like ".Net isn't open-source, so why sould you use it?" Did they make Java open-source without telling me?

Plus with tools like Reflector, .Net is open enough.



From: Chris Ryland (Nov 10 2006, at 11:44)


Nice piece. But I think you're ignoring one huge aspect, which is overall complexity. And that's where Java EE solutions fail miserably by comparison. The sheer size of required knowledge for that space defies belief, or, rather, requires a career-sized commitment (which isn't all bad in some cases).


From: Bill de hOra (Nov 10 2006, at 11:46)

Sure, but *which* Java framework are you talking about Tim? There's dozens, and at a least half a dozen worthy of mention.

On the maintainability dimension. Has rails be around long enough to say either way? I've seen the Rails core code, and of all the web frameworks I've used (too many), the it reminds me most of is - Zope2.


From: Andrew Phoenix (Nov 10 2006, at 11:57)

I think one of the most interesting things here is that your graph gives you a really good idea of how to pick the right tool for the right job. Of course, for many developers, you pick one thing and stick with it, but sometimes one has the option of selecting from multiple tools for projects. A contractor could look at spec from a client and this chart (or they could draw up their own, taking into account their own experiences) and figure out what language is best suited for their needs.

Of course, I don't think that'll actually happen (people tend to stick with one framework), but one can hope.


From: Mikael Gueck (Nov 10 2006, at 12:10)

Shared nothing is more scalable? Yeah, because spreading scalability to tiers doesn't multiply it, or anything. That's exactly why Tangosol is selling middle-tier caches as fast as they can to banks and credit agencies, and others who can afford their product. And obviously, it's easier to build a shared-nothing architecture in PHP than Java because... hmm, can't think of why. Great argument, thank you for knowing what you're talking about and helping your Java developer customers out.


From: Laurence Powers (Nov 10 2006, at 12:18)

Why are you comparing the PHP *language* with the Rails *framework*?

Doesn't it make more sense to compare a PHP framework with a Rails framework? How about a PHP framework that ports the Rails functionality like Cake?

It seems to me you are being deliberately disingenous.


From: Jason R Briggs (Nov 10 2006, at 12:48)

The best of the flame-bait stuff in Theserverside is the comment that starts (quote):

> Pretty shallow analysis by Tim. Very disappointing.

And then goes on to say:

> 3) Integration. Outside of WS-* and Rest SOA styles, there are

> other significant integration challenges that neither PHP or

> Ruby can tackle.

I guess he thinks a 'shallow' analysis deserves and equally shallow comment...? ;-)


From: Frank Bolander (Nov 10 2006, at 12:49)


Thanks for the update. The TSS thread did seem a little dour on Java.

As far as maintainability, don't you think operational concerns weigh in more than code maintainability. I mean to say JMX extensions for monitoring, an actual container that manages orthogonal enterprise endpoints(security, resource management, etc...) and an overall platform that does allow for various integration endpoints? And even though people sneer/hiss at specifications, they do allow for a substrate for a common mindset for growth and financial survivability of applications(less sudden End of Life risk). The development concerns you mention are definitely valid but the overall lifecycle of software resides in the operational domain, not the development domain. I'm not sure where the opportunity cost crossover is though.

I like a lot of the stuff RoR is doing and they definitely project better onto the presentation domain than J2EE does, but I'm not sure RoR is more readable and maintainable. My first look-see was with Typo and I'm not sure I would classify it as easier to read than a Java app. RoR is definitely way ahead on Web 2.0 stuff but we've been there already with the Ajax stuff and I'm not sure all the demons that reared their head six years ago aren't still lurking with Javascript.

As far as PHP, security issues have soured me to the point where I will push back hard on any PHP deployments. It may be nice to just FTP php files back and forth, but a mistake on security is a lot more deadly than having to go through a little pain on configuration and deployment. I'm not sure how you can quantify an intangible like that.


From: The Geek (Nov 10 2006, at 15:52)

Just a little bit about tools....

MyEclipse has virtually everything you could want in a java IDE, and since it's an eclipse plugin you can use eclipse for everything. The rate that they add new features is also astounding.


For PHP, there's PHPEclipse, which is pretty good but doesn't offer real debugging... only Zend does that.

For Rails, there's the RadRails plugin for eclipse, which is phenomenal.. the only thing missing is true debugging support.

There's also the Ruby in Steel plugin for visual studio that is really great, and will soon offer native debugging.

I'm using a combination of MyEclipse, RadRails and PHPEclipse, so I don't have to leave Eclipse no matter which language I'm working in.


From: Evan Light (Nov 10 2006, at 18:56)

Very interesting! I couldn't agree more. I recently performed a similar study for a customer of mine and came to the same conclusions. However I took scalability for granted as it can be readily resolved by throwing more hardware at the problem -- and hardware is so cheap these days!


From: Michael Bernstein (Nov 10 2006, at 20:29)

<blockquote>.NET and the Python frameworks, starting with Django, are notable by their absence here. Sorry; I just don’t have any first-hand knowledge on them.</blockquote>

Fair enough. So come to PyCon next February:


There will likely be presentations about all the major Python web application frameworks, and some stuff about IronPython (the port of CPython to the MS CLR) as well.


From: Lukas (Nov 11 2006, at 03:05)

Rails is innovation in framework development for scripting languages. While it draws on Ruby for many aspects, there is so special about it and as a result the technology is available in PHP already. This highlights another key aspect of PHP, its simply the fastest in adopting new technology.

As for maintainability I think this forgets a key detail. You talk about how easy it is to mess with existing code. Maintainability however often also means keeping the old stuff alive unchanged and show horning something around it. There Java falls flat simply due to the complexity of the platform. This is an area where scripting languages shine.


From: Richard Brantley (Nov 11 2006, at 07:04)

I am a bit bothered by the off-hand dismissal of .NET simply because it isn't open source (as if Java is). My own personal experience, especially working in ASP.NET 2, is that development speed is actually pretty good; not as good as Rails, but just as good or faster in some cases than PHP (which I worked extensively in for about 5 years). Visual Studio is a really good development environment.

My only real complaint about .NET is that choosing it makes the operating platform choice for you. I'm still not comfortable with Mono's ASP.NET implementation to depend on it for production work.

I like PHP a lot, but it doesn't have the tools to enable back-end database and services integration the way .NET does.

The .NET framework doesn't yet have the immense overhead or conflicting domain specific frameworks that Java has. Give it another few years, and it will probably happen.

I really, really wanted to like Rails, but my programming projects invariably require interfacing with a legacy database that is not consistent with Rails' assumptions. At that point Rails goes, well, off the rails and actually becomes harder to use than simply building your own ORM.


From: Brian Swartzfager (Nov 11 2006, at 07:32)

You can add ColdFusion to your list of omissions:

--the CF language allows you to program in either tag-based synatax or scripting syntax. The tag-based syntax is very easy to pick up and makes it easy to develop applications quickly.

--CF runs on top of Java, so you can call and utilize Java methods for additional power and flexibility.

--CF scales well (examples: Adobe.com and the Voice of America website).

--There are several CF programming frameworks available (examples: Mach-ii, Model-Glue) that promote the MVC architecture and OO programming. Some of the framework developers are exploring ways to emulate aspects of Rails.

--The CFEclipse plugin for Eclipse allows anyone to write their CF web applications using Eclipse as their IDE.

--While CF is not open-source, anyone can download and install a developer version of ColdFusion Server (available at Adobe.com) and can execute CF code on their local machine. A company called New Atlanta also offers an alternative product called BlueDragon that executes CF code.

...ColdFusion doesn't usually get included in these kinds of comparsions, partly because it isn't open-source and partly because ColdFusion's been around for awhile (so it doesn't have any of that new-technology hype around it), but it is a player in this field and may well become more pervasive now that Adobe's tying it in with their other products such as Flash and Flex.


From: evanx (Nov 11 2006, at 08:44)

Great article, thoroughly enjoyed. I second you on the importance of maintenance in the enterprise - development might be 18 months, but maintenance is gonna be 18 years! ;) Also if the app is not maintainable it's gonna become a dead duck very quickly. Having said that, maintainability is mostly an issue in teams and large projects where no one wrote or understands all aspects of the system. In a PHP project for example, the original developer who wrote the application, will always be able to maintain it and refactor and rewrite it as they go to improve it, no matter how big the application becomes. But in enterprise environment, you need more determinism than that.


From: pwb (Nov 12 2006, at 11:28)

There finally exists a good light weight framework for php: CodeIgniter.


From: Ronald de Gunst (Nov 12 2006, at 15:03)

It is always nice to see the discussions on TSS.

The lines of comment on this thread, are more than the lines of source code of most Rails applications.


From: Brice Dunwoodie (Nov 13 2006, at 01:09)

Thanks Tim. Great post and discussion. Is it possible to access the full slide set? Thanks.


From: Asbjørn Ulsberg (Nov 13 2006, at 04:13)

Saying that .NET isn't open source is a bit inaccurate. The language infrastructure that .NET is built upon, CLI, is an open standard (ECMA 335). That standard has an open source implementation called Mono and Mono works fine. ASP.NET in Mono runs through an Apache module called "mod_mono" and you have excellent development tools for it on both Windows and Linux.


From: Christian Mueller (Nov 13 2006, at 08:18)

Really awesome presentation at the international php conference Tim! I enjoyed your speech...

After all you came to the same conclusion as Frederick P. Brooks more than 20 years ago:

There is still "no silver bullet".

PHP is no silver bullet.

Ruby on Rails is no silver bullet.

Java is no silver bullet.

However, after working more than 3 years on a enterprise PHP web app i absolutely have to agree with your point of view. PHP web apps are hard to maintain!

By the way, the next thing i will do is buy a ruby on rails book ... :O)


From: Tracy Snell (Nov 13 2006, at 17:49)

" After all, Java runs EBay while PHP runs Wikipedia and Yahoo! Finance. Both clearly scale “well enough”. "

Do you really feel these three are comparable? EBay is orders of magnitude more complex than the other two. Could PHP run EBay? (Honest question, I've never done PHP but I have my doubts). If you look at the sites doing more than DB dips and are doing more complex transactions are any running PHP?


From: James (Nov 14 2006, at 15:47)

"Could PHP run EBay?"

When it really comes down to it, any language can run any application. I don't think people choose a language based on its scalability (something about premature optimisation being the root of all evil?), and I think this fragment makes a good case that the other three factors outlined are more important. I guess this means that sometimes "throw more hardware at it" is the preferred solution.


From: Tim Bray (Nov 14 2006, at 18:00)

Speaking on behalf of Sun, I certainly agree that throwing more hardware at the problem is an excellent strategy.


From: Aristotle Pagaltzis (Nov 15 2006, at 10:34)

As for developer tools, I am most firmly of the beliefs that Steve Yegge outlines in <http://steve.yegge.googlepages.com/transformation>.


From: Mark (Nov 15 2006, at 17:50)

Wouldn't it be better if the scalability of Rails is represented by a question mark? By putting a concrete bar there, you are declaring that you've studied its scalability, but in your text you say that you simply don't know yet.


From: Henri Sivonen (Nov 21 2006, at 13:49)

If you are looking at Python frameworks at some point, I encourage you to check out TurboGears in addition to Django. Django has text-based templating. TurboGears has XML document tree-based templating.


From: Paul Browne - TIPE (Nov 22 2006, at 04:20)

Good post - goes some way to breaking down the aloofness that Java is automatically a superior solution (and this is spoken as a Java Developer).


From: Casper (Feb 05 2007, at 22:34)

".NET isn’t open-source, so why would you use it?"

1) Java isn't open source just yet and it has taken 12 proprietary years for it to come down this path, arguably because Java now is feeling the heat.

2) There are open source implementations of .NET and unlike Java, the API does not make you run away screaming in horror.


From: Andrew (Feb 06 2007, at 11:06)

> And .NET isn’t open-source, so why would you use it?

Because I want the best tool for the job. Most applications are inherently complex enough without introducing additional accidental complexity caused by arbitrary tool selection criteria. .NET is a very capable runtime that is tightly integrated with the most popular PC OS on the planet. It also has great tool support and is very well documented through both formal and informal mechanisms. Java is largely the same, especially with the recent efforts to become more tightly coupled with the Windows UI.

I completely understand why the business model of a big iron company like Sun wants software to be a commodity but to wrap that up in a bunch of FUD around non-open source software is disingenuous to say the least.


From: Bill (Feb 10 2007, at 18:53)

Re: Omissions, why no Perl?


author · Dad
colophon · rights

November 10, 2006
· Technology (90 fragments)
· · Web (396 more)

By .

The opinions expressed here
are my own, and no other party
necessarily agrees with them.

A full disclosure of my
professional interests is
on the author page.

I’m on Mastodon!