Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
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 '12 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. –  kevin cline Feb 11 '12 at 22:32

6 Answers 6

up vote 5 down vote accepted

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.

share|improve this answer
    
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 '12 at 4:53

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.

share|improve this answer
    
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 '12 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 '12 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 '12 at 14:24

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.

share|improve this answer
    
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 '12 at 21:49

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.
share|improve this answer

We are basing our initial estimates on the initial prototyping/coding we've done with PHP

Using that as an estimate is only correct if your team is only responsible for the prototype.

If the team is responsible for a large application, the estimate is not determined by the cost to prototype, but the cost to continually implement features and ensure code quality across a large feature list.

The question asks us to assume quality architecture, but the difference in effort is, primarily, the difference in creating and maintaining one architecture over the other.

A team that is skilled in a dynamic language, that institutes quality procedures and testing can be just as effective as a team using a static language. The problem is that many teams underestimate this process, treat a large application like a large prototype, and quickly get over their head.

The lack of detail here raises the same concern: How is code quality accounted for across an initially large set of features? What are you doing differently to account for the tradeoffs that a dynamic language presents? Those details will provide the difference in effort.

In general the estimation for a team going from Java to PHP would entail:

1) Understanding the common issues with maintaining large codebases, specifically in dynamic languages.

2) Determining if it is suitable to build a new toolchain.

3) Determining who will accept the costs of the change.

If this has not been detailed yet, the estimate is most likely of the prototype, not the application.

Reference:

Why do dynamic languages make it more difficult to maintain large codebases?

http://www.reddit.com/r/programming/comments/1waw0o/why_do_dynamic_languages_make_it_more_difficult/

Is there a correlation between the scale of the project and the strictness of the language?

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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