Java vs. PHP vs. Scala

I have a bit of a dilemma with programming languages. Next year, I expect to be able to free up a little extra time for a private programming project (call me an optimist!) and I am wondering which language/technology to use. The project is quite straightforward. It's a business application that I use for my own work as a software engineer. It consists of four components. There's a contact manager component (or CRM as it's now fashionably called), a project management component, a time tracking component, and a billing component. That may sound like a tall order, but obviously I don't need the full-blown functionality of applications like Siebel, MS Project, or SAP. I just need an application that brings certain functionality together in a quite specific way to suit my needs.

The software I am currently using for this purpose consists of two different programs. The CRM and billing components are contained in a Delphi application which I wrote more than 10 years ago. The time sheet and project management components are part of a PHP application that I developed in 2002. Needless to say that these two programs are neither cutting-edge, nor are they well integrated. The Delphi application uses an outdated Borland Paradox DB  and the PHP application contains large swathes of ugly procedural code. Although the whole shebang fulfils its purpose, I feel it's high time for a replacement. Of course, I could acquire an existing software package and save a lot of time writing code myself. But hey, I am a software engineer. I do like a creative challenge and I want something that fits my needs. I also want to learn new technologies.

The question I am asking myself now is what to use for the task. I am considering Java, PHP, and Scala. There are pros and cons for each of these:

(1) Java, JSP and a web framework with an app server. This is the obvious choice. Most of my professional work is JEE-based these days. I believe that I can work productively with Java, although the language inevitably involves a lot of boilerplate code and redundancy, which has a negative impact on productivity. In spite of this, it would be an good opportunity to deepen my knowledge of JSF (Java Server Faces), Hibernate, or try out some other persistence layer. It would also offer an opportunity to learn a new Java web framework that I haven't yet worked with such as Spring or Tapestry. From a business point of view, this may be a good choice because Java technologies are in high demand and it is also a very robust platform. The JEE universe is really quite large and there's enough territory that would be fun to explore. The downside is that Java, the language, is slightly tedious.

(2) The second choice is PHP and the Zend framework in combination with some AJAX toolkit, such as YUI or Dojo. I have the feeling this would be the most productive way to go; the biggest bang for the buck so to speak. For a project of this size (around 50 kloc), the development time may be even half of that with Java. PHP 5 and the Zend framework are mature technologies and I am quite familiar with both. Another advantage of PHP is that it's wide spread. Almost every hosting company offers PHP, whereas the number of Java hosting companies is considerably smaller (and usually more expensive). So, there wouldn't be any problem hosting the finished product anywhere. The downside is that PHP, being a dynamic language, is less robust  and slower than JVM bytecode. The language is also less expressive. But the biggest disadvantage is that I'd hardly learn anything new in the process.

(3) The third alternative is using Scala in combination with the Lift framework and a standard web container. I find this the most exciting choice, but it's very likely to be the most time consuming. I am rather new to Scala and functional programming. What I have seen so far is great. Programming in Scala is much more fun than coding in Java or PHP. I am afraid though, it would take a bit of time to wrap my head around it and work productively. Scala is still a foreign language to me. Another downside is that there is a limited choice of frameworks, APIs, and tools available at this point. Actually, Lift is the only Scala web framework I know of. Another question I am asking myself is whether acquiring Scala skills does make any business sense. I haven't seen too many Scala job offerings so far. Seems like the most fun choice, but also the least promising from a business point of view. Decisions, decisions, decisions…

12 Replies to “Java vs. PHP vs. Scala”

  1. Hi, your choices are good – in the Java camp I suggest JBoss SEAM and IntelliJ IDEA.
    SEAM has this concept of “conversations” which keep hibernate objects around between requests which is really good. Conversation is not transaction, its the entity manager containing the objects, so you can navigate the lazy relationships across requests without lots of reloading from database.

    I use all three you said, but in Java I use SEAM. I think its really a choice between Spring camp or SEAM camp now.

    I’m moving towards Liftweb for the long term. In PHP I use Zend Framework, the only problem with it is the bootstrap isn’t standardized and you tend to have to write your own bootstrap php file.
    Good to find an existing ZF project to build upon I made this http://www.orsa-studio.com/phptaco/ but I don’t suggest it anymore! you can look at its bootstrap.php

  2. You should research Adobe Flex Framework for a functional, rich presentation layer and using object oriented php5 code; having the benefits of programming in PHP and also the full richness of a unmatchable GUI looking more enterprise than enterprise in the fraction of time it takes to implement any of the competing technologies for presentation, including java and javascript+css+xhtml

  3. JBoss Seam is not a real choice. I would use it only if I know for sure that I need JSF (which I really-really don’t like) and that want to run it with application container. But hey, why should I do that for pretty trivial web application?
    I would not go any further than Java, Spring, Hibernate in a Tomcat. Ruby on Rails can do the same job, by the way, probably faster. With JRuby you can get it into Tomcat very fast and easy. From my experience of Scala – it is a nice language, with nice things, but Liftweb does not seem to be ready for the “prime time” yet. It’s not documented good enough, and some steps are not obvious.

  4. Today PHP is a serious language. PHP 5.3 offers so many new features which will help you to build large, maintainable business applications.

    And with Zend Framework you can build very good and fast applications within a short time.

    @phillip: That with the bootstrap isn’t right anymore. See version 1.8 and Zend_Application – the bootstrap behavior has totally be changed!

  5. I had a similar dilemma some weeks ago and have chosen the 3d option. Indeed it takes some more time that it could, but the language is so amazing and powerful, that I have no regret at all. I’m enjoying every minute of writing in Scala.

  6. Nice high level comparison among heterogeneous languages. I only want to make a point regarding one of your statements on Scala and frameworks.
    -“Another downside is that there is a limited choice of frameworks, APIs, and tools available at this point. Actually, Lift is the only Scala web framework I know of.”

    To me this is not a downside. If you consider the hundreds-thousands of orphaned Java frameworks and how they have shaped the Java landscape, it really convoluted things w/Java. If I want to deploy a web-app, I need a framework to work with, just this decision could take months to research.

    If Scala can start out small and concise, and remain that way throughout it’s maturity, it will have the potential necessary to replace existing Java applications. Have a limited number of options isn’t always a negative thing. It makes your decision making a lot simpler.

    Just my 2cents.
    Thanks.

  7. Thanks for your comments. Greatly appreciated!

    Just an update to keep you in the know: I’ve decided to go with Scala. The language is just too elegant and too much fun to program in, so I could not resist.

    Cheers, Thomas

  8. I think that the remark about there being a limited number of frameworks for Scala is artificial at best. Afterall, what is to keep a developer from using the Java web frameworks like Wicket or Struts or Tapestry or (insert your favorite here) with Scala?

  9. Of course, nothing keeps you from using a Java web framework with Scala.

    However, there’s a bit of a mismatch, because Scala has traits, pattern matching, actors, etc. which a Java framework cannot take advantage of. Something more scala-ish would be nicer…

    Cheers, Thomas

  10. You can use Scala in Tapestry framework. This will give you benefits of both great lang and FW. cheers

  11. Hey,

    even if you’re now going with Scala, you probably want to have a look at the play framework.

    It has Scala support, but stable versions are mainly for Java so far.

    If you prefer easy to use and elegant APIs over bloated stuff like JEE(sorry), have a look. 🙂

Comments are closed.