7

A client asked us to estimate effort when selecting PHP as the implementation language for his next web-based application. We spent about a week exploring PHP, prototyping, testing etc., We are quite new to this language - may have hacked around it in the past but, let's go with PHP-noobs but application development experts (for the lack of a better, less flattering word :)

It seems, that if we write, clean maintainable code, follow separation of concerns, enterprise architecture patters (DAOs etc.) the 'effort' in creating an object-oriented PHP based web-application seems to be the same for a Java based one.

Here's our equation for estimating the effort (development/delivery time):

ConstructionEffort = f(analysis, design, coding, testing, review, deployment)

We were specifically comparing effort estimates in creating an enterprise application with the following:

  1. PHP + CakePHP/CodeIgniter (should we have considered others?)
  2. Java + Spring + Restlet

It's an end-to-end application:

  1. Client: Javascript/jQuery + HTML/CSS
  2. Middle tier/Business Logic - (Still evaluating PHP/Java)
  3. Database: MySQL

The effort estimates of the 1st and 3rd tier are constant and relatively independent of the middle tier's technology. At a high level with an initial breakdown into user stories of the requested features as well as a high-level SWAG on the sheer number of classes/SLOC that would be required for PHP doesn't seem to differ by much from what is required of the same in Java. Is this correct?

We are basing our initial estimates on the initial prototyping/coding we've done with PHP - we are currently disregarding fluency with the language as a factor, since that'll be an initial hurdle and not a long term impediment IMHO (we also have sufficient time to become quite fluent with PHP).

I'm interested in knowing the programmers' perspective with respect to effort when creating similar applications with either of the languages to justify choosing one over the other. Are we missing something here? It seems we are going against popular belief of PHP being quicker to market (or we being very fluent with Java have our vision clouded). It doesn't seem to have any coding/programming effort saving from what we/ve played around with.

2
  • 2
    You'll always be faster to market using a language/framework where you have deep experience. The only possible exception to this is where a tool (like Rails) does most of the work. In other words, there is no objective justification.
    – kdgregory
    Feb 11, 2012 at 20:26
  • 1
    If you are experienced in Java web development, then for a new web application you should strongly consider Groovy/Grails. You will get all the benefit of a dynamic language while reusing all your knowledge of the JEE stack. You can write any performance-critical code in Java if necessary. Feb 11, 2012 at 22:32

5 Answers 5

5

Your answer: Not at all

I have extensive experience with both PHP and Java and I can tell you that if you know PHP well enough and you are not a total noobie and know that PHP can do classes, interfaces (and soon now even traits for horizontal reuse), exceptions, automatic class loading, etc., your PHP code can look better than Java code, and even work better.

Don't believe me?, check the Symfony framework to see (IMHO) the best architected piece of PHP software out there, look at its manual for code examples.

The real problem behind PHP

Noobies, script kiddies and mediocre programmers... there are a lot, and they all seem to turn to PHP for being too easy. PHP is too easy indeed, and that is not a bad thing (blame the excellent language documentation).

Every language has its flaws and as a matter of fact, one of the most flawed languages around is javascript, and look where it is now (hint: everywhere).

Some of the advantages when selecting PHP

  • Wider and cheaper market for developers. Just look for PHP developers with OO background and a good attitude towards learning if you choose Symfony (you won't regret it, specially because of Doctrine, the ORM Symfony uses), but there is a learning curve (smaller than it appears, it does appear big sometimes).
  • Cheaper hosting services.
  • Easier to setup your developer and production environments.

So the effort could be about the same, but the previous perks are what separate it from Java, and I'm sure there are more.

1
  • Pretty much the perspectives I was hoping for from someone adept at both the languages. Yes, I agree that PHP may look more beautiful than Java at times - even in my small time of prototyping! I liked your dimensions of "some of the advantages of PHP" which we can consider complement to our effort estimates to discern whether PHP is worth it. If not too much to ask, could you suggest some more - just a simple bulleted list would suffice?
    – PhD
    Feb 12, 2012 at 4:53
1

I'm not familiar with any formal studies regarding PHP and Java effort or productivity explicitly - most work looks at languages of different generations. I know that Java is a third-generation language, and I'm pretty sure that PHP is also a third-generation language. This says that, all other things being equal, the inherent effort needed to produce the same product with both languages is close enough to not have a significant impact on the project.

However, knowledge of programming languages has been shown to indicate an difference in productivity of 1.20. It's one of the smaller factors: the capability of the team, the complexity of the project, even the tools used have a much greater impact on project performance than programming languages.

So, in short, the choice of programming language will have a difference in productivity. However, it's one of the smaller differences. I would be far more concerned with the other aspects of the project.

If you're interested in more, I'd look into tools such as COCOMO and SLIM and the underlying research that went into them. These estimate modeling tools allow you to take into account your knowledge and capabilities in different aspects of projects and determine how they impact your schedule, budget, and effort/productivity levels.

3
  • I've looked into COCOMO and SLIM but they don't state much provide much information - I'm looking at it from the purpose of entering SLOC into COCOMO to get an estimate and it seemed PHP and Java were similar from that regard
    – PhD
    Feb 12, 2012 at 4:55
  • @Nupul I'm using the COCOMO estimation tool provided at their website. For a 50000 SLOC project with no reuse or no modified code, and all of the cost drivers set to Nominal, effort is about 217 person months. If I change "Language and Toolset Experience" to "Very High" (your Java example), effort drops to 183 person months. If I change "Language and Toolset Experience" to "Very Low" (your PHP example), the effort increases to 260 person-months. You can also adjust the other parameters as appropriate for your team.
    – Thomas Owens
    Feb 12, 2012 at 14:20
  • @Nupul From a purely SLOC-approach, you would suspect that they are very similar. Just like I said in my first paragraph, both are third-generation-languages, so the SLOC count will be on the same order of magnitude. However, when you start adjusting other parameters, such as experience with the language, or the experience on the target platform, you start getting variations. Now, the variations by only changing language are less than 100 person-hours: negligible in the grand scheme of things.
    – Thomas Owens
    Feb 12, 2012 at 14:24
1

It will take less time to develop application in PHP, but, most probably it will not be architecturally consistent enough and, therefore, it will have more bugs. Nevertheless, cost of the change of PHP application will be lower comparatively to Java application.

On the other hand, Java application will take more time to design and develop, but it will be more robust and consistent. Most probably it will have less bugs, but it will be more difficult to implement changes.

Even though it might seem that languages are equal in the terms of time and efforts estimation, that's not true. It really depends on the specific application domain whether it will be good to use PHP or Java. Language does not matter, technology does. And there are PHP-technology and Java-technology. That's what you really need to take into account because both PHP-technology and Java-technology cannot be applied to some specific domains due to the language-technology specifics. For example, I would not ever try to apply PHP-technologies for Natural Language Processing. While it would be an overhead to develop simple admin panel in Java.

Application domain is what really matters.

1
  • Your expanded answer is much better. The original version wasn't helpful without something to back it up, either research, experiences, or other facts. You added that, so it should be good.
    – Thomas Owens
    Feb 11, 2012 at 21:49
0

In general, you will be more productive in a language / framework you know well. This will likely be a bigger factor in productivity than any intrinsic differences between the language / frameworks.

Regarding the particular languages you are considering.:

  • PHP is good for quick, dynamic web sites. This is where PHP has its roots.
  • Java is better for more robust enterprise applications that need to be maintained / developed over the long term

It's worth noting that the Java platform (which you can consider separately from the language) is extremely powerful with probably the world's best GC, exceptional JIT compilation and a huge ecosystem of libraries and tools. In the long run, this is probably going to be a more attractive strategic choice for serious applications.

Since it sounds as if you already have Java platform skills but don't really know PHP, I would definitely pick Java over PHP for your middle tier implemetation. If you are interested in high productivity, you might also want to consider:

  • Dynamic JVM languages like Groovy or Clojure - these offer all the high productivity of modern dynamic languages with the advantages of being well integrated into the Java platform.
  • Modern Java web frameworks such as Play or Vaadin - the newer frameworks are IMHO much more productive than J2EE. J2EE is probably overkill unless you are building a mission critical enterprise application.
-1

Quick Short Answer

PHP, is easy & fast for the first time, but, if becomes complicated when updates to code are done. Java may seem complicated at first, but, it will help things later.

In both cases, consider, not just the progr. lang. plus frameworks, also, specially if you go for PHP.

Not the answer you're looking for? Browse other questions tagged or ask your own question.