CMS News, Reviews and Resources

Content Management Matters ™

Home > Archives > Industry News
 Looking for a job? Check out the CMSWire Job Board.



PHP vs Java vs Ruby

By Staff Writer
Nov 15. 2006

With Sun GPLv2’ing its Java software this week, a lot of focus is on the other open frameworks that have risen during the same era, and their comparative value in a post open source Java world. One such take is from well-known Sun insider, Tim Bray, who spoke at last week’s International PHP Conference in Germany.

Bray, who is Director of Web Technologies at Sun Microsystems, co-creator of the XML 1.0 and XML Namespace standards, co-founder of Open-Text, and contributor to the Atom Publishing standard (whew!) spoke in a presentation entitled “How to combine PHP technology with Java based on Enterprise Systems” (download PDF).

SPONSORSHIP
CMSWire speaks to a specific audience of professionals and opinion makers focused on content management, publishing and collaboration.
Learn more.

In the slide below, Bray outlines the basic advantages of each of these three platforms (or rather the two languages and one framework if you are scoring at home). In perhaps in a nod to his new employer, Sun, Bray totally omits any mention of .NET or smaller products like Adobe’s Flex/ColdFusion platform.

His idea, if you are able to take it on the surface only, is to rate your priorities of: 1) Scalability, 2) Dev Speed, 3) Dev Tools, and 4) Maintainability. In this highly generalized approach, you could theoretically pick your web application building language/framework based on only these priorities.

Tim weighs-in heavy on the maintainability side, and we’d tend to agree with him. To quote:

“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.”

On the maintainability side Tim places Ruby on Rails out front. Quoting him again, Tim describes why RoR is in the lead here.

“Mostly because there’s less code. The fact that Ruby forces MVC on you helps too, also the fact that the templating and [Object Relational Mapping (ORM)] and testing and application code are all so tightly integrated helps. Bear in mind that we still don’t know how well Rails is going to work outside of the CRUD-centered greenfield app space where it shines.”

Tim’s metrics don’t really exist on a quantitative level nor are they based on any published statistics — just a very informed intellect and a privileged position. Obviously, additional parameters such as total cost of ownership and native security (PHP, we are looking at you) should also play a big role the decision making process.

As you can probably guess, in response to this presentation, the proponents of Java, PHP and Ruby are lighting the Internet aflame in defense of their platform of choice and at the same time nay-saying their fellow players. While very entertaining and sometimes educational to follow, not much is going to be gained from this bickering.

Bray concludes the presentation with the Rodney King-esque statement “One way or another we all have to integrate.”

The reality is that there are a great number of ways to hone-in on the language or framework choice for a web application. Many factors have to be considered and weighed against each other. The beauty of what we have today is that there ARE a great many choices out there, much more-so than even a few years ago.

The fact that open source options are being stacked up against the likes of Java and .NET, and have a similar levels of support is a blessing. Today, with the open-sourcing of Java, we have a new entry onto the field. Rather than exclude one or another, this arrival is going to make the open source web world, warmer, more sophisticated, and for better or worse, a little sunnier.

Was this article useful?

Comments

Scaling for PHP projects is better
then for Java project??!!
ROTFL !

Posted by: Pawel on January 30, 2007 4:50 AM

Please see my view in:
http://in.geocities.com/rsramsam/why.htm

Posted by: MATHEW on January 31, 2007 9:47 AM

Use Perl. It is the best of the lot.

Posted by: Jon on February 1, 2007 8:04 PM

Nice read. You make it much easier to understand the differences. I have dabbled in all three but could no way articulate the way you have. Thanks.

John
http://www.monomachines.com

Posted by: John on February 1, 2007 8:18 PM

Eh Jon, I dunno about perl being the best over all, personally I think database support in perl is lagging behind all three of these, however text file support and implementation might be superior.

Posted by: Motorcycle Guy on February 1, 2007 10:46 PM

A good example of a non CRUD app developed with Ruby on Rails is www.zoomin.co.nz, an online mapping site. It seems to work well and has recently be adopted by TradeMe (also .co.nz) for their mapping.

Posted by: Nahum Wild on February 2, 2007 1:31 AM

PHP is more scalable than Java? I think this guy is joking!

Posted by: albel on February 2, 2007 1:57 AM

Uhhhhhhhhhhhhh

You're comparing two languages to a framework in another.....

How about struts vs cakephp vs rails?

anyhow, ridiculous comparison.

Posted by: Anonymous on February 2, 2007 2:44 AM

How about availability?

All hosting companies can probably deliver a low cost PHP server environment (shared), however, not many have Java or RoR.

Posted by: Mark on February 2, 2007 3:40 AM

ASP.Net is the fastest in development man! + tools(Express)

Posted by: Hasan on February 2, 2007 3:41 AM

"Bear in mind that we still don’t know how well Rails is going to work outside of the CRUD-centered greenfield app space where it shines.”

A project I have just finished work on involved a very complex legacy database schema running on SQL Server. Rails includes many small tools that allow you deal with an old, non-ideal database, and where you have to deal with many foreign keys out-with the standard model structure, you can revert to using good old SQL.

The MVC allows you to demote such nasty bits to the models, leaving your controllers and views totally unaware of the database structure they are working on, allow work to be carried out in the normal way.

I have to say I was impressed by Rail's ability to cope in situation, as having come from a mostly Java background (Some PHP too) I previously thought that any framework would have difficulty without it's own database schema paradigm. Kudos to DHH and the other Rails developers, they truly have built something that can be used everywhere.

Posted by: Douglas F Shearer on February 2, 2007 4:45 AM

I had my site(mysafebox.com) originally done in ror and decided to port it to java and it was one of the best thing that I did. It took a bit more time to develop it but the end result was worth it.
The only issue with Java is the hosting which is not as cheap as php ror etc but once you get a good one, you are all set.
Php more scalable than java?? that's a news to me !! Also, Rails is a fw and not a language, please get your comparison right.

Posted by: Jyot on February 2, 2007 10:25 AM

He forgets a few very important aspects important for very large scale applications:

- Java scales MUCH MUCH better than all those other languages... just google it
- Java has static typing that is a big advantage for large projects because it results in Contract-Programming. The compiler can check for much more human-errors. Sure it takes more time to develop java code in comparison to php and ruby... but on the longer run java wil prefail because your applicaiton is rock solid due to static typing and programming by contact.

Therefore i vote for separe charts like this for projects that are small ( php will win ), larger ( ruby will win ), or extreme large and compelx ( java will win ).

There or just too many parameters, a vew simple charts like this is not at all sufficient.

Posted by: Tjerk on February 2, 2007 11:21 AM

Another crucial element to consider is availablility of talent. While Rails is easier to maintain, the real trick is finding someone who can do the work.

Posted by: utw on February 2, 2007 11:33 AM

I don’t think one language is better than another.
I used to be a Java programmer for 8 years, but am getting tired of it. Java tries to solve too many issues, and it is getting too much complex.
PHP is very simple and easier language, and also have lots of Open Source Project out there when it’s needed. Ruby has nice framework.
I can’t choose one, but I will probably choose ROR for most of the project.

Posted by: Steve on February 2, 2007 12:58 PM

Not only is ASP.NET faster, it's also easier to administer than Java or PHP, and I've done them all.

I still use PHP where cheap and easy is the goal, and I'll never knock how strong it is as a web-app platform, but if I had the run of the lot, and no budget, I'd do ASP.NET every stinkin' time without a second thought.

I was born and raised (in college) to hate MS, and everything Windows, including VC++, VB, VJ++, etc... but when C# and the .NET framework made it's debut, I was hooked. Long live MASTERPAGES!

Posted by: The Average White Guy on February 2, 2007 4:14 PM

Some one is bringing up .NET. Where was that mentioned? Am I missing something? Who is .NET. Move on. Average dude.

Posted by: Oscar on February 2, 2007 9:02 PM

Not impressive,
how this comparison was calculated and based on which type of project?
these 3 platforms have different advantages and usages. why we need comparison. rather we want to know the right usages on right project.

if you want to host a small site, why will you prefer java? go for php or ruby on rails.

similarly you need a lot of optimization and many Enterprise Architecture integration, so why will you go for php or RoR?

i think comparing between RoR and PHP is fine enough, java is better for comparing with lot of other features.

Obviously java should be compared with .NET, because this is growing as one of the alternative of Real Java stuffs.

thank you for your post.

Posted by: nhm tanveer hossain khan (hasan) on February 3, 2007 5:31 AM

PHP has more tools than Rails, come on.

Posted by: flash devs on February 4, 2007 4:16 PM

ASP.NET is not Open Source, and it's only an option on windows... which not everyone uses, despite your limited point of view. It's not even considered. Fools.

Posted by: Bob Dobbs on February 4, 2007 5:44 PM

I think that comparing 3 languages/framework is already difficult, but become ridiculous in such a short space. Each has its own benefits / drawbacks, it should have been better give the best tool for project typologies... but then you would have to compare PHP frameworks with Rails ;o)

Posted by: Franck on February 6, 2007 3:41 PM

How many exampes/scripts are there for PHP?
How many are for Rails?

Posted by: Alex on February 12, 2007 12:51 AM

This article is just out there to stir the soup. The author knew it would do something. Heck, someone could write this article in a few weeks or a month, and it would get attention like bees to honey. the beauty of it, is that its attracting developers for all of these languages, to come here and read it... its not really giving us anything we didn't already know... Whoopee Doo.. Bray speaks, and pretty much tells us nothing.... No matter what our opinion is, or whatever his is... nothing is going to change.... absolutely nothing...

Posted by: Jason Michael on February 12, 2007 10:39 PM

Anyone knows what languages are used by the big web2.0 sites today or at least a few examples?

Posted by: David Zonsheine on February 16, 2007 5:26 PM

Nice article.
I agree to every word.

Posted by: Eylon on February 22, 2007 8:29 PM

If we want to compare the frameworks precisely then I believe it should be using CakePHP, RoR and Spring MVC.

Posted by: UnicMan on February 28, 2007 8:57 AM

how do you measure these things? it's subjective.

Posted by: add on March 21, 2007 6:42 AM

I use Java and PHP at the same time after moving away from ASP.NET. ASP.NET is slow, use much memory and hard to be as scalable as Java and PHP.

Posted by: vnjug on April 23, 2007 4:19 PM

I have experience in all 3 areas.

My rating is PHP > Java > .NET

Why? see below:

1) PHP is easy to learn, fast to deploy, highly scalable
and extensible. We also can do load balancing with
PHP like Java. Further we can develop enterprise class
applications with good security etc.all. We have
cakePHP and Symphony web frameworks that are
really good. Smarty is good templating engine. But,
the downside is we can't do certain things in PHP like
knowing how many bytes of a file are transferred to a
server when uploading a file.

2) Java is good at everything but the problem is a
typical J2EE developer needs to read 1000's of pages
about various web frames works, template engines to
make choice and do perfect deployment. Few people
have that patience. Also, we need more investment to
buy superior hardware (Good RAM etc) that is a must
for J2EE applications to run faster. I learned hard to
find that JSF + velocity is a good choice. May be u
disagree and think Java + Flash is a best choice.

3) Microsoft .NET is excellent but then again issues of
hardware like Java for speed and OS specificity.

New features to a language and new frameworks come with time. I believe PHP, an unarguably easiest language to learn, will also get all the just mentioned desideratum with time. So, I think I will always be with PHP.

I love PHP. :-)
Jesus loves PHP. :-)
So, you all should love PHP. :-)

Posted by: sammy on June 21, 2007 5:34 AM

You can't really compare scalability with rails and pure php/java.

It's ridiculous. rails is a framework, it goes through many computations and object related mapping, of course it will be lower than the pure languages. If they checked out pure ruby (the programming language not the rails framework) I'm sure the results would be different. Script running for ruby has been proven to be faster than php on most occasions.

Why are they comparing a framework to languages anyway? They can compare frameworks to frameworks. Php has symfony (and I hear some kind of zend framework will come out soon), and java has tons.

I'm a little confused here, do they even know the difference between ruby and rails?

Posted by: hmm whatever on August 10, 2007 1:49 PM

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=php&lang2=ruby

Ruby is faster than php? Where's your evidence. Look at this URL. The ONLY thing ruby beats php at is startup time, which in afast-cgi or mod_apache setting is meaningless. Yes php consumes more memory, but that's because of all the builtins. There are a myriad of ways to mitigate that: custom compile php with only the extensions you really need, use an opcode cache (more speed too). By the time you throw rails on top of ruby, it will be even slower and more memory consuming. So if we're going to compare php to rails as the RoR camps likes to do, they fail...

Posted by: me on August 25, 2007 4:34 PM

There is no need to compare, because each one has their own advantages and disadvantages.

In terms of speed, I would say:
PHP < .NET < JAVA

But in terms of maintainability:
JAVA < .NET < PHP

So, they have pro both cons.

Posted by: Ghanshyam on August 30, 2007 3:35 AM

different people are saying language 1 is faster than language 2 or language3. How can we trust that this is the case in reality? this is just based on their own level of experience with each particular language. i.e they may be stronger in one language than the other, and so produces better code in that language and less efficient language in another language.

why don't we bring a so called expert in each language and give them the same requirements and get them to produce the code to meet the requirements and then run their programs and see which is faster or more maintainable ?

mind you there is still a problem if a so called expert in one language may not necessarily be at the same level of expertise of another expert representing another language.

in which case, we can replace the experts with 3 people who claimed that they have worked on all 3 languages and get them to write their code in all 3 languages and then compare the performance of the code generated by all 3 people for all 3 languages i.e altogether there should be 9 programs produced (3 x 3) and compare them. that would allow us to be able to see what their level of expertise is and also the performance of the code they produced, and maybe the performance of the languages

Posted by: my2cents on September 1, 2007 9:14 AM

flash devs: PHP has more tools than Ruby?

More people drive a hyundai than a Maybach.
Does that make Hyundai a better car?

Come on!

Posted by: OutThere on October 1, 2007 6:20 AM

Ruby's dynamic typing means you don't repeat yourself: How often in Java have you had to suffer through verbose code along the lines of XMLPersistence xmlPersistence = (XMLPersistence)persistenceManager.getPersistence();? Ruby eliminates the need for the type declaration and casting (as well as parentheses and semicolon): a typical Ruby equivalent would be xmlPersistence = persistence_manager.persistence.
Ruby's dynamic typing does not mean weak typing—Ruby always requires you to pass objects of the correct type. Java, in fact, enforces types more weakly than Ruby. For example, Java evaluates "4" + 2 as "42", coercing the integer to a string, while Ruby throws a TypeError, telling you it "can't convert Fixnum into String." Likewise, Java, sacrificing correctness for speed, can silently overflow an integer operation, producing weirdness such as Integer.MAX_VALUE + 1, which equals Integer.MIN_VALUE, while Ruby simply expands integers as needed.
Despite Ruby's advantages, Java's static typing does give it one ability that leaves it as the preferred choice for large-scale projects: Java tools understand code at development-time. IDEs can trace dependencies between classes, find usages of methods and classes, auto-complete identifiers, and help you refactor code. Though parallel Ruby tools exist with limited functionality, they lack type information and so cannot perform all these tasks.

Posted by: Vishwajeet on October 10, 2007 4:14 AM

LMAO.

Rails is a framework and it is a layer between the parser language and the programmer and dependence on it is IMHO silly as you are putting your faith into one basket that the developers of the "Rails" you use have taken care of possible hack and security.

Like all language layers they come bug ridden. So your stuck when one exists.

Rails IMHO is pointless , another money making enterprise in the programming market and when people wake up and see exactly why they are bad, they will realise that their entire workforce is dependent on a system that offers no skill diversity nor any real programming skill.

Sure it may speed things up but it comes at a skills cost.

I am old school, learn ground up first, NEVER rely on some layer to do what can be done efficiently in the parser as the parser as the rails needs to be run then the output to the parser for the remainder of the process.

Posted by: Mark on October 16, 2007 7:31 AM

Asp.net is open source under mono. It's still not 100 % finished since webparts is missing, but that's not a problem for most projects.

http://www.mono-project.com/ASP.NET

Posted by: Fred on October 16, 2007 7:24 PM

I am surprised you have no Python framework in the picture since there are more frameworks in python than in any other languages and Python is know to be much faster than Ruby and cleaner than Perl. Anyway, if I may, I would like to suggest Gluon, http://mdp.cti.depaul.edu, since it allows you to byte code compile production applications and I would like to see some benchmarks.

Posted by: Massimo on November 6, 2007 9:42 PM

rails is more faster.. pls look for the rails2.0.2 documentations and refer these
http://www.youtube.com/watch?v=n1NVfDlU6yQ
http://www.youtube.com/watch?v=Ld919lziKgE
http://www.youtube.com/watch?v=GQXqWkWqnSw

Posted by: saurabh purnaye on January 16, 2008 2:58 AM

What are the comparison goals?
What are the factors to be studies to achieve these goals?
What are the methodologies to measure these factors?
How the tests had been done? on which platforms, with which version of OS, platforms, frameworks?
What are the sizeS of projects under testing?
We first need to clearly identify the above mentioned issues to give the comparison its credibility!!!

Posted by: mrmind on March 13, 2008 5:51 AM

First of all - .NET is not a real choice. Once you use Microsoft product you're stuck with all of their other shitty products, especially 'wannabe' servers like Windows.

Java is parody of a good language. It's incredibly slow (for a compiled language used in virtual machine) even with JIT and Sun's JavaVM for x86 likes to hang. We have a kind of myspace social network in Poland, which used to run on Java (grono.net). Even with Oracle database and a huge cluster network of servers it suffered from major performance issues.

PHP is not faster, but it's more scalable IMHO. Another social network with 11 millions of users works on cluster server with PHP. PHP is not well-written but every release gets closer to be a good enterprise-level web programming language. Besides - there are tons of good soft based on PHP.

Ruby on Rails it's just a framework. And Ruby...nah, it speaks for itself. How many corporate websites runs on it?

The more interesting alternative would be Python, but only if next releases of mod_python for apache 2 allow to easy use of it on vhosts.

As for Perl, it's too complicated to be web programming language of choice for many developers.

Posted by: H, The Anonymous on April 2, 2008 9:59 AM

RailsEnvy.com: All Ruby on Rails Commercials:
http://413x4nd3r.blogspot.com/2008/04/railsenvycom-all-ruby-on-rails.html

Posted by: Alexander on April 7, 2008 9:55 AM

I'm really feeling PHP lately with all these super frameworks (Code Igniter, Cake, Symphony, Zend Framework, etc.) out there. Now that a lot of web apps will be saying goodbye to PHP4, I expect better things in a hurry -- especially with PHP6 on the horizon.
Also, a new generation of web hosting outfits like Media Temple with their grid computing server architecture means that PHP web apps will be even more desirable to programmers and consumers alike.

And yes, Rails is just a framework. It should be compared to CakePHP, Struts, Symfony et al.

Happy Computing!

MaxTheITPRO

Posted by: MaxTheITpro on April 16, 2008 3:12 PM

See, The Whole Point is this it is not just about writing a small code or making a highly OOP code that can be managed well because at the end of the day it is still a web based applications
so inconsistencies are apt to happen be it JAVA PHP ROR or EVEN ASP.net

Lets talk of Performance PHP is 36 times faster than RoR , and much faster than java only because Compiled Cache and stuff is bullshit for web Apps Every time a user access a page if under certain conditions the app has to be compiled on the fly as an interpreted code. Even java has to do it and what java does can be easily done using any php accelerator and cache managers available in php.

Trust me there is nothing out there to beat php in terms of language features and superiority.

And as the language php was built on an incremental basis
It has features to support OOP, Extreme, Ajile Development Methodologies ....

But Still has Good old way of procedures there for you, It dosen't force OOP on you like java or RoR.

Because Not Every One is looking forward to writing an enterprise Web App so PHP serves the purpose for all variety of users although it still has to mature a little further in terms of tools like editor etc and synchronizing software coupled with testing and concurrent version software to be enterprise ready. Other wise the langusge is alredy Very much Enterprise ready.

Posted by: pankaj on May 2, 2008 5:01 PM

Add a Comment

Email:
Web Site:
Comments:
Security Code:
  Remember me?
  


topics
Advertise on CMSWire





Add to Technorati Favorites