PHP vs JVM for Web Development

I’m being brave and asking this in the Java section, as I want to gauge the response from actual JVM web developers, to a couple of opinions I have in regards to PHP and the JVM.

First of all, to set the background, I work for local government as one of only two systems developers. My background is PHP (4 years experience) although recently I’ve been exploring a couple of JVM languages (none of which were Java). My colleague who’s actually my supervisor, is an experienced Java developer, and ideally, would like to stick to the JVM for web development. We’ve been discussing what language(s) we should standardise on, as we both agree that sticking to our preferred language is going to cause problems, especially in the long run.

After spending a couple of months playing with JVM languages like Scala and Clojure, I can certainly see that the JVM is certainly a powerful and robust tool. In the other corner though, there’s PHP. Not all that suitable for heavy processing, but shines in terms of integration with web technologies and it’s incredibly scalable nature (can be used for single-line scripts, or large and complex applications) - PHP is light and dynamic, which to me makes it a perfect match for the web. With these two things in mind, I’ve formed the opinion that PHP is a more suitable choice for web applications which don’t require heavy processing (which makes up probably 90% of web apps), as it’s rapid development, ease of deployment and general flexibility are ideal for web development, while on the other hand, the JVM is best suited to applications where heavy processing is required, or in mission critical, enterprise level web applications where strict business models rule the roost.

So in conclusion, I’m of the opinion that PHP is the best tool for general web development, where as the JVM is a perfect compliment for handling the background services and heavy data processing side of things, which could be off-loaded to it by PHP if required. So in a nutshell, PHP for frontend processing, JVM for background services and heavy data processing.

What do some of you JVM developers think of this? Do I make a fair point, or is my lack of JVM knowledge skewing my perspective on this?

I used to be a Java developer. I got frustrated with the lack of server support, documentation, general resources, and so on. PHP…had all that in spades. I still wish PHP had some aspects of the Java language built into it

Granted–there is a lot of opportunity for bad code in PHP, since its flexibility is both a benefit and a downfall, whereas Java would force you do to certain things a certain way and help you avoid bad/messy code.

I have noticed a lot of enterprise applications do rely on Java (ebay comes to mind) or ASP.NET (a few major insurance companies come to mind). Even facebook, which is largely PHP, wikipedia mentions that the back-end also uses C++, Java, Python and Erlang.

So, maybe it’s time for some prototyping and benchmarking?

It’s not the Java language that I’m comparing in particular, but rather the JVM virtual machine as a web development platform, but thanks for your reply none the less.

A JVM, or Java Virtual Machine, is an interface between a specific set of hardware and Java bytecode. The hardware might be a PC or a digital watch, it’s up to the JVM developers to adhere to the JVM specifications in order to present a consistent, Java-friendly interface. By asking “is the JVM a good web development platform”, you’re essentially asking “is a Mac a good web development platform” (or a PC, or a Java-enabled toaster)

In other words, the JVM isn’t a specific platform. This is why Java is portable. In theory, the code you write to run on a java-enabled calculator should run on a PC, a Mac, and that darn toaster.

But you’re not concerned about that, you want to know if Java is the right tool for you to use for web app development.

Realistically, that decision is between you, your application needs and your willingness to learn how to use Java (which, I might add, you cannot sidestep by trying to use non-Java Java languages - you’ll still have to learn something and you still won’t know Java, which is used throughout the following)

Here’s a few things you should be looking at:

For the web, by combining, minimally, Tomcat (or another Java server of your choice), Java Servlets, JSP and a database of your choice, you have a full featured set of tools that will handle anything you throw at it. From single line scripts via JSP to full blown, secure credit card account applications.

Beyond the basics, there are frameworks, such as Struts, to help you design and organize your code, within the frameworks, there are more tools, such as Struts Tiles, that allow you to create and reuse visual objects on your pages. Spring and JSF are other members of this category.

On the database side, there’s Hibernate, which, once you understand how to use it, you’ll wonder why you used to spend all that time trying to interact with the database.

I know exactly what you mean by JVM web developers. Such as JRuby uses JVM but coded in Ruby. A lot of people tend to focus on which “programming language” is better but forget to ask “which language you know the best and can it do the job?” This question depends a lot of things. Such as due date, other peers language confidence, and such…

So is your solution viable? PHP with Java Web Service like solution? Sure! But, would I say PHP is better in terms of web development compare to Java? Absolutely No! Again, this question is more like “How comfortable you’re in the language and can it do the job?”. Since, I’ve done Java for past 10 years, it’s very natural for me to create web using Java. But, if you’ve done PHP and comfortable than go with PHP. If you have a Java guy then let him create backend service codes, which will be also fine.

Anyways, my short answer is “No and it depends on each person”. I surely do not want to learn PHP to create something I can do in Java. This would be vice versa for you.

Honestly, if I’m brand new to web technology then I would pursue Ruby on Rails.

It also depends on what you’re trying to do. Some things are much easier to do in PHP than in Java; some I’d prefer to do in Java and not in PSP. Although, to me, PSP is easier to learn and understand than Java. It really depends on your programming background and preference.