Traditionally, it seems like Java is the web language of choice for corporations, and PHP has been the web language of choice for people who own their own websites (i.e. small scale websites). It also seems like both of these groups will swear by anything that their language, whether it be PHP or Java, is the supreme language of the universe. I personally have experience with both PHP and Java, have owned my own websites (like www.webkrunk.com), and have also worked at a large corporation as a Java developer. The purpose of this post is to help explain the apparent segregation between both groups while providing some guidance as to which platform to choose depending on your situation.
Two sides, two perspectives
If you ask most Java developers what they think about PHP, they will probably tell you that it’s a very basic, unprofessional language that can be messy, lacks structure, doesn’t have a good IDE (integrated development environment) like Eclipse or RSA, and isn’t a good platform for a real website. If you ask most PHP developers what they think about Java, they will probably say that it’s overly complex and cumbersome, and that it isn’t a good platform because development time is just too slow and tedious. Which side is correct?
The difference between PHP and Java
The root of this dispute boils down to the development of IDEs (integrated development environments) and how each language has handled objects over time. Originally, PHP didn’t support OOP (object oriented programming) until PHP4, and didn’t have a strong IDE. Since PHP 5.3 however, its support for OOP has improved tremendously. Furthermore, in the past year or so, some really great IDEs have emerged to support PHP development. Java on the other hand has always been uniquely defined by its OOP nature, and has has always had great IDEs.
Most new web programmers will turn to PHP simply because the language supports both OOP and proceedural programming, in which case the latter is easier to learn. Novice web programmers often times don’t yet understand MVC architecture, and just build their web pages by querying a SQL database and printing the results with for loops directly, all within one PHP file.
Java developers, on the other hand, are usually well trained and very familiar with OOP. Since Java seems to be the most common web language used in the corporate setting, these groups of people usually work in teams and fully utilize the conveniences of IDE’s and OOP.
PHP vs. Java in the past
Two years ago, this debate ultimately boiled down to how large your development team was. If you were building an entire website by yourself, or with a group of less than three people, PHP was probably a better route because development was much faster, and you were less likely to step on your team member’s toes as you developed. On the other hand, if you were building a very complex system requiring a large team of developers, say five or more people, you would have needed a very well structured, standardized architecture, to ensure that all of your developers were on the same page, especially in a corporate setting where you could have dozens or even hundreds of developers working on the same website. In these cases, Java was a much better choice.
PHP vs. Java today
Now that PHP has a variety of wonderful IDEs to develop in, and now also supports OOP just as effectively as Java, why aren’t more coporations switching to PHP? The answer is simple. Change happens very slowy in large corporations. Furthermore, if your corporation is made up of hundreds of Java developers, and your entire system is already built in Java, how could it possibly make sense to suddenly switch to PHP? It wouldn’t make sense. As a result, most larger corporations are essentially locked into Java development, while smaller companies are more capable of building a foundation for their systems in PHP.
The future of PHP vs. Java
In my opinion, at the time of this writing, both languages are nearly on an equal footing, although PHP is easier to deploy because there’s no pre-compilation required. We will begin to see larger corporations adopting PHP only when Universities begin to include it as a major part of their curriculum, and as the smaller companies that hire graduates fluent in PHP grow into large corporations. In short, it could take many years before we really start to see a PHP presence in larger corporations.
Tags: best, Java, java vs php, language, PHP, platform, vs, web
Im a java programmer mainly, but I’ve been looking at a lot of posts of java vs php, and all of them say that java is more for the enterprise than php, but give NO reasoning for this.
IMO, Java has been better for the enterprise because it had robust ORM solutions (i.e. Hibernate) that let you change the database you are working with by changing just one line of code. Java has also had very mature reporting tools (i.e. JasperReports), but PHP now also has them… ok not as mature, but they are there,.
But searching in google, you can find now several ORM solutions for PHP too, you can use JasperReports with PHP (Calling Java Code, but anyway) and PHP has his own Reporting Tools (i heard about Agata).
So ok, my reason would be: Java has been MORE TIME in the enterprise and has more mature and tested frameworks and tools, but that doesn’t mean PHP doesn’t has them. Googling a little tells everything.
One downside I see in PHP is that setting up a debugger is a little difficult. Im not telling it is not possible or hard, but when you download even the more recent Eclipse Helios PHP or NetBeans for PHP (haven’t used zend ide yet) it doesn’t have a “Clic and you’re debugging” like Java has… a minor downside, but with Java you download and debug instantly.
It’s just preference, both of them are good, we’re hoping Java brings functional programming natively so I don’t have to use pyhton or something extra.
Java downside: hosting is more expensive. All hosting support php + mysql very cheap, Java with tomcat (private, not shared) is about 5 times the price.
PHP downside: Threads are not natively supported (that is what i have read) or work only on Linux with workarounds. With Java, the threads are emulated so they work on any OS. Maybe I haven’t investigated enough in PHP threads, but if I want a synchronized method, in Java i just add “synchronized”. Not as easy in PHP I think.
Cheers man ;)