Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

PHP vs. Java - which is better?

I have a former client that has a customer. This customer asked them - "so when are you migrating from Java to PHP?" So evidently this person has the impression that the next wave of web applications will be written in PHP. My former client has asked me to provide an answer for their customer. If I translate it, I think they mean to ask "what is different between Java and PHP and why should we use Java over PHP." Here are my opinions - please add yours as you see fit. I must admit I don't know a whole lot about PHP, except that it's widely popular among the Linux/Apache/MySQL crowd and that it's similar to ASP in it's lack of a MVC architecture (yes, I know about the PHP MVC project).

  • I think Java is more of an industry standard, whereas PHP seems to be popular among hackers and hobbyists.
  • Java provides better separation of layers - key for testability. PHP has all the code embedded in the page, so you have to run it through a browser to test if database connections work (for instance).
  • Java is more scalable.
  • More folks know Java and it's easier to qualify someone's Java skills. How do you test someone knows PHP? Is there a certification?
  • More for-profit organizations use it.

If you're a Java or a PHP-lover, I'd love to hear your opionions (facts are always better). I'm going to point my client to this post, so keep it clean.

Posted in Java at Aug 22 2003, 03:52:33 PM MDT 98 Comments
Comments:

Not sure if these are relavent to the project in question ... * Multithreading not supported in PHP. * PHP has a confusing and inconsistent class/object system (defaults to passing copies of objects rather than passing/returning references to objects). While this can be overcome by learning the "gotchas", writing reusable components is rather difficult. * Classic object-oriented vs. procedural argument. * Livecycle of JVM vs. webserver process/thread and it's impacting on caching.

Posted by Layton on August 22, 2003 at 05:23 PM MDT #

First and biggest difference, you don't have a notion of application in PHP. Each page is a script, executed in its own memory environnement. That means PHP is great for dynamic web site, whereas server Java is "sold" for server-centric applications, which is a different class of problem. For a "pure" website, development in PHP is way faster, and performance and scalability is easier to achieve than in Java. For heavy applications (multi-user workflow, XA transactions, distributed objects... as soon as you really need an application server, and *not* just the HTTP layer), the "application" notion is needed and thus PHP is more cumbersome to deal with. Regarding your points : * Java hasn't really a better separation of layers. The view/control separation in JSP is perhaps the worst example of all. You can achieve good separation of layers in PHP with classes, or by managing cleanly the namespaces of your functions. You are not more forced to test code in the server environnement in PHP than in Java. * The cost for Java scalability is high (clustered appservers with high price tags). PHP scalibility is cheap. * More for-profit organizations like professional support, it's a chicken and egg problem.

Posted by Damien Bonvillain on August 22, 2003 at 05:44 PM MDT #

I'd take issue with the assertion that PHP has all the code embedded in the page, and you must test code on a server. Certainly, PHP's methods for seperating logic from presentation are less elegant that Java's, but they do exist. If you have correctly seperated the two, then you can easily run PHP applications as scripts, by inserting a #! in a similar manner to perl.

Posted by Chris Davies on August 22, 2003 at 06:50 PM MDT #

as we joke around the office with the perl folks - Personal Home Page ;-)

Posted by rich! on August 22, 2003 at 07:15 PM MDT #

I am not sure if I agree with all your points either. Both Java and PHP are widely accepted. Many organisations use PHP for their web applications, not just hobbyists (and arguably one of the reasons why Java has so few hobbyists is because it is much harder to do simple things). It is also much easier to find a good third-party host for PHP /MySQL than Java.

I do agree that Java provides for a much greater seperation of layers, although there are some neat templating systems for PHP (Smarty, for example). JSP with taglibs is OK, but Struts/Webwork/etc/etc provide fantastic architectural support. Even with extensive use of PHP's object model, you are still tied to scripts (which you can include and reuse, but it gets messy reasonably quickly). With proper seperation, testing in Java is a breeze. I use Webwork, and I can test Actions with JUnit directly from Eclipse. I test my data tier directly as well. I can't see how you can test PHP outside of the server environment (unless you move to command-line PHP interpreter?)

Scalability is a whole other f*cking can of worms. Yahoo selected PHP for their systems, other companies use Java (parts of eBay, Dell). Any system (within reason) can be made to scale ... I have scaled ASP/VBscript on IIS. Get some routers, buy a bunch of web servers and the biggest database you can afford.

Testing developer skils is a challenge regardless of the language. Certification is no real indication of expertise, just an indication of passing an exam (and keep in mind that if you get 50% and pass, it is also another way of saying that you know HALF of the subject material) . I cannot comment on the numbers of developers, but in my experience finding quality Java people can be a challenge (finding people who have touched Java is easier).

Personally I think that language is just one of the many factors that need to be considered when desiging a system, and they should be subsidiary to the business case.

Posted by Toby Hede on August 22, 2003 at 07:25 PM MDT #

"Much harder to do simple things"? That's a load of crap. You can write the same extremely difficult to maintain code in JSP that you can in PHP. You can leave out all the OO techniques and embed all your logic into your presentation layer if you want to. The syntax is so similar that you could pretty easily convert between the two. Show me in PHP where you can compile an object and use it from a web interface application or a gui application. Show me where you can take a PHP application and install it on a system where PHP isn't installed and get it working quickly. PHP is a real pain to get installed. Try getting PHP working with Oracle on a Unix system and you'll see something that is pretty challenging. Not so with Java. Stick a jar out there and you have instant Oracle support. PHP is good for making quick one time systems. Java is good for enterprise systems. That's the main difference.

Posted by No one on August 22, 2003 at 08:02 PM MDT #

Toby and "No one" are both correct. One of the things that "No one" missed was that the install base of PHP on webhosts is HUGE. Far greater than Java. I would like to add a couple of things that I have noticed from my experience with PHP and Java. I currently have two deployed PHP web applications that I have to maintain. I also have three java web application that I maintain.

PHP is such a head-ache that I would NEVER suggest to a client that a web application be written in PHP. "No one" is correct about installation. If you don't have PHP installed with Apache, you are in for a long ride. Nothing can beat the installation of Orion. Unzip. java -jar orion.jar. Instant Java Web App.

Database access has not been standardized. Every database has its own set of functions, and they are not always named or perform the same type of functions. Oracle's functions are so different it boggles the mind.

PHP has OOP, but it is not like any other OOP I have ever used.

PHP's XML support is antiquated. No JDOM for PHP.

PHP is a mish-mash of functions that have been thrown together in one library without any care given to convention or standards. Just check out the number of functions that have been written for arrays: Array Functions and notice that some begin with array_ and some don't. Session handling in PHP is a real pain as well.

PHP does have a couple of pluses. It is easy to learn. The documentation is good and in one place. There are a bazillion scripts that are already written. There are a bazillion web hosts that already have it installed.

Can things be done "correctly" in PHP? Yes. But once your developers learn how to do things correctly, they will be asking for Java. When they overload a function, they will not want to count the number of parameters that were passed to determine which function should actually be called. They will tire of trying to avoid the circular includes. They will tire of the constant ftp to the server to test out the latest changes. And they will want a real IDE.

I suggest using PHP to learn the fundamentals of web based applications. Use Java to actually build systems.

Here is an article discussing why a largish hardware site switched from PHP to Java. It disusses the virtues and vices of Multithreaded (Java) and Multiprocess (Apache/PHP) systems.

Posted by Carl Fyffe on August 22, 2003 at 08:55 PM MDT #

In my mind, its simple. I did PHP for a long time, and my job requires Java. I was a big supporter of PHP until I got into Java, and its like this: Using PHP is like trying to do CAD with crayons. Java is so much more robust, and scalable. It's a no brainer. I will say, if its just a website that displays info and has a form for customer contact, it can be done in PHP faster, but if it has logins, and sessions, Java is the way to go.

Posted by Marc Adams on August 23, 2003 at 09:49 AM MDT #

I'll say only one word: standards. PHP is lacking of any, while Java has plenty. Apart from that, you can do as an excellent work with PHP as with Java. The best proof is www.infobae.com.ar (a news site in Argentina), I know the guys who did it and its a great work. I disagree with the people who says it´s difficult to install, it's not. Even though native database calls are non-standard, there are a few excellent abstraction classes for databases. What's wrong with session handling in PHP? I find it quite similar to Java's. And to avoid circular includes, just use require_once. However, I agree with that once you learn how to do things correctly, you realize that most things are already done in Java: standard libraries, MVC, IDEs, etc. I don´t think migrating a well working application from Java to PHP is a good idea, there´s no reason to. I know PHP is coming strong, and with version 5 due out in a few months, I´m sure it´ll be a more interesting choice for the corporate world. But to reach the level of standarization and tools available to Java, it´ll be years, if ever.

Posted by Ale Sarco on August 23, 2003 at 03:08 PM MDT #

Both languages serve their purposes. If a programmer is proficient in both languages, then PHP is almost always quicker to prototype with. The same would likely be said for Python vs. Java or Perl vs. Java. I think that comes down to the whole interpreted vs. compiled and static vs. dynamic debate. I think Java and PHP have different markets in mind. Sun points Java at everything, while PHP is content on being a web oriented tool. I've done projects in both languages and can tell you there is no silver bullet. There are things I love about both languages and things I hate about both. As long as the technology choice is not limiting your business, then use what seems to work best for you. The only time you should consider switching technologies is when the technology cannot meet the needs of the business in a reasonable manner. This means the technology should be reasonably efficient in all areas: stability, development, scalability, performance, etc. That's my take.

Posted by Joshua Hoover on August 23, 2003 at 10:29 PM MDT #

There are much more libraries for java, than for php. Is there something like a persistance library for php? I didnt use php since quite a while, but when i used it (about 2 years ago) there was nothing like that around. so basically when you do something more advanced with php, you end up doing stuff over and over again, which just exists as several library implementations for java.

Posted by csshsh on August 24, 2003 at 10:38 AM MDT #

Every PHP opposent here seems to want one thing, that PHP matches Java point for point. PHP is not a replacement for Java, it's a language for websites, and it's still less cumbersome than Java for that. Do you need MVC for a website? For a web application yes of course, but for a website?
You can isolate a class of web "applications" where you feel that Java is overkill, PHP fits this niche.

Posted by Damien Bonvillain on August 24, 2003 at 02:51 PM MDT #

If the project is mostly content-based, maybe you need a pre-existing CMS and not a raw language.

Posted by Adam Vandenberg on August 25, 2003 at 01:42 PM MDT #

Probably the talk was more about the next PHP, which will be inspired by Java.

Posted by Olivier Rossel on August 26, 2003 at 07:09 AM MDT #

PHP5 alone has the same strong difference with J2EE as PHP4: there is no notion of application. The planned major step is that you can make PHP5 be called in an application environnement (either J2EE or .Net or whatever), and provide its flexibility and raw performance that JSP for instance can't achieve.

Posted by Damien Bonvillain on August 26, 2003 at 04:14 PM MDT #

For more imformation, look for the articles about the exciting new features in PHP5. For example, PHP5 will have Exceptions! Wow...yeah. Which I assume means that PHP4...didn't have exceptions. Take a look at the other new features which simply bring PHP5 closer to java.

Posted by Paul Rivers on August 29, 2003 at 07:30 PM MDT #

Dunno why Rich thinks the phrase "Personal Home Page" is a joke--that *was* the original name of the language after all.\n\n PHP is easier to learn and use. One example: string handling in PHP. The other day I wanted to use a regular expression in Java and struggled for about 45 minutes with the docs before giving up (I still don't know if it's possible). In PHP? "preg_replace("|old|","new",$mystring);" That kind of thing is much easier in a loosely-typed language like PHP than in a strongly-typed language like Java. I am sure I am not the first person to have been driven nuts by the amount of wrapping and type-casting necessary in Java.\n\n But it's very hard to code well in PHP. The very idea of OO is one that the language is still struggling with. I recall reading a quote recently from one of PHP's developers saying something like, "PHP is written in C. Why do you-all need objects anyway?" Geez...\n\n I disagree with Carl Fyffe on the relative difficulty of installing the two languages. Sure, with Orion you just unzip the jar and plug it in, but just try getting support for it afterwards. OTOH, recent versions of Red Hat already come with Apache and PHP pre-installed and configured; I've rebuilt PHP from scratch too, and it was no biggie even without the nice tools that are available for Java (Ant, Maven).\n\n The installation base is the primary reason I'm using PHP for a project now; it's intended for use by novices who most likely are in a virtual hosting environment without access to a servlet container. But whenever I'm working on it I find myself longing for a lot of the features of Java.\n\n Simply put, Java is a real programming language and PHP isn't. While you can code in a non-OO way with Java, anyone that uses it much has the whole concept drummed into their heads at an early stage. So even a rotten app written in Java is generally much more maintainable than one written in PHP. The language is bigger, it's more flexible, and it gives you much finer-grained control over what's going on than does PHP. Want a GUI? No problem. Database connection pooling? Ditto. A multi-threaded app? Objects that persist between server calls? To use XML and XSL? You get the idea.\n\n And there are so many fantastic open-source resources for Java. Jakarta awes me, and so does a lot of the stuff on sourceforge. I'm learning Ant, Hibernate and the JSTL right now--it's like being a kid in a candy store. By contrast, what's available for PHP is a joke. Sure, Metabase and Smarty are both good projects, but I have a hard time thinking of any other decent PHP libraries (and that includes what's in PEAR). And those examples aren't anywhere near the functionality and maturity of Eclipse or Cocoon, just to name two.\n\n My thought: if you want to hack out a webapp in a weekend, definitely go with PHP. If you're building anything you're going to be stuck maintaining for a while, or even rebuilding a Java app that completely stinks, salvage as much of the code as you can and stay with Java. You'll be much happier in the long run.\n\n

Posted by Dianne Schoenberg on August 30, 2003 at 07:23 PM MDT #

Disclaimer : I earn my bread thanks to Java. a. Most small applications do not need the multithreading, session pooling, standardised, 1000 standardised APIs due to 500 JSRs and another 500 sourceforge.net projects, distributed caching, cluster through multicasting features of java b. For most small applications the benefits of structured and clean code are high. OO or non OO makes a lot less difference c. PHP apps need much fewer resources. Many more virtual servers (dynamic websites) can be created on a single physical server using PHP. d. PHP developers do not demand a lot of $$ e. PHP code is easy to learn and understand Bottomline : There is a size/complexity threshold under which PHP rocks.

Posted by Dhananjay Nene on September 03, 2003 at 01:49 PM MDT #

I'm a Java programmer by day and a PHP tinkerer by night. As Toby and Carl have both pointed out, PHP is the defacto standard on web hosting companies. This fact alone made me choose PHP as my hobbyist language. As a scripting language, it has some nice features that you can't do in Java. It's easy in PHP to dynamically include files, but not possible in Java (that I know of). Also, it's fast to develop in. Whereas in J2EE, you'd have to compile, deploy, wait for JSP to compile (if you didn't precompile them beforehand) and then you can test it. As for installing PHP, it's not too bad. Certainly not harder than installing any J2EE app server. Another nice thing is that the PHP environment is much smaller than a J2EE environment. I need at least a gig memory to run JBoss, a database, and Eclipse. Whereas I can run PHP/MySQL and Quanta in my 128 M laptop with no problems. But, for me, the most frustrating limitation of PHP is it's dismal I18N support. When it can natively support Unicode, then it can be a real contender.

Posted by Oliver Tseng on September 12, 2003 at 09:27 AM MDT #

Discerning hackers choose Python over both Java and PHP.. Python has a rich set of libraries, clean object orientation and organisation of namespace, multithreading, and integrates very well with Java where you need it. Plus, its syntax is way more elegant and clear than those of PHP and Java. If you are free to choose, go with Python.

Posted by Michael on October 28, 2003 at 09:14 AM MST #

you are a moron. none of your opinions are relevant to the question of which is a better platform for developing web application. java weenies are philosophy majors that couldn't find jobs - that - or offshore scabs that are sucking the life out our computer industry by creating crap software for coconuts. Take java offshore with all the customer service reps who speak some god-knows-what language who might as well be telling us all in the US to go eat crap and die. I could teach you why Java is crap and why anything, including PHP is better, but it would be an exercise in futility. Just keep debugging your java garbage, sucking up every cycle and chunk of memory a system has and running your IDE's that consume all available resources in the universe and make it incredibly difficult to build even the most trivial application. while you are doing that i will quietly use my reliable old tools to build software that matter. java sucks, you suck and this thread is moronic

Posted by bubba on March 24, 2004 at 11:11 PM MST #

Java is a well designed language but php is extremely easy to use. It took me some time to figure out how to use servlets and jsp but only a few minutes to hack out a php script. I built a whole online booking/ reservation system using php in under 2 weeks. Don't think that would be possible with jsp. I suppose there are merits to both, but for my money, I'll stick with php. It's fast, easy to use and easy to deploy.

Posted by kok koon leong on May 06, 2004 at 11:35 PM MDT #

You might want to check out CEP (http://sf.net/projects/cep).

It addresses many of your gripes about PHP in respect to Java. that leaves you with a very rapid development language and still logical code-reuse and seperation of layers.

It also have a component event cycle similar to .NET which provides a very simple suggested coding standard.

-Jackson

Posted by Jackson on July 16, 2004 at 03:14 PM MDT #

I think it is difficult to compare two programming languages if there is not a specific framework to do it. What is better, C/C++ or Java? Well, for real-time applications C/C++ is the way to follow. No doubt! For web-based apps Java is the way to follow. No doubt! The same happens with the issue PHP vs Java. Therefore I propose to focus a little more the question. What is the best language to implement, e.g. a web-based ERP+CRM program? And what is the best language to implement a fancy web-site?

Posted by Nick Parca on September 29, 2004 at 01:04 PM MDT #

<font face="arial" color="blue"> Nice focus Nick, I agree, and here is a scenario I'd love to see discussed. I currently have over 150K lines of Kylix running dozens of extremely different webstores and lead generators. Our distributed system runs on a combination of Sun/Solaris and I386/Linux boxes in a job-based-clustered environment. I am researching hard on a new direction which is what lead me to this thread.

My primary focus includes scalability, true object orientation and performance. Other factors: We are currently all MySQL but want to migrate to Oracle, we see anywhere from 30-80K surfers per day depending on the season, and I must create an upgrade path that blends in with the existing system - I will not have the luxury of a "Next Release Cutover" scenario. All communication is performed between systems via HTTP with XML as the interaction language - that being said, I still need to communicate with a variety of other systems using and equally wide variety of protocols (merchant processing, currency conversion, GeoIP et al...). There are no proprietary forms/apps/methods that talk to the system, everything is done via HTML. As an aside, I would REALLY not like to go to two languages, provided I can do this without breaking my "Best tool for the job" ethos. Any coder worth his/her salt can learn a language/framework given some space, so the ramp up time is considerably less important than the result (Frankly, I think the zealotry in several previous posts demonstrates more about one-trick-pony coders than architecture and framework effectiveness).

My immediate experience is that a Tomcat/JBoss deployment has a bunch of overhead that seems to be less than exciting from a performance perspective, but I am concerned about PHP systems not being built from a class hierarichy (I love the Delphi model where everything decends from TObject...). I would really enjoy seeing both a Java and PHP expert argue why I should go with their platform. Clearly, Yahoo and Friendster think that PHP is the way to go, but the list of J2EE folks is getting huge.

Thanks for the space,
-EP</font>

Posted by Ed Purkiss on December 09, 2004 at 11:39 AM MST #

I think you can equaly use php an java for the same purposes. You can create extensive applications with both php and java. The whole problem is the reputation of php. Sure there are things you can't do with php and surely that works two way's

Currently i am developing a php framework in php5 that is completely class based and communicates only using xml. Php CAN be used to make very clean, reusable and maintainable software BUT the level of dicipline needed to do that is WAY higher than needed when useing java. The rules you must set for oneself are harsh and you must abide by them strictly otherwise your php app wil degrade very fast into a bunch of scripts that are not very usefull.

Posted by Quinn on December 16, 2004 at 08:39 AM MST #

I've looked at PHP. It may be fun, but not on the level of java. PHP is very messy and lacks the structure of java. Some say it's easier to use PHP, but there is always a learning curve for all languages. So to say PHP is easier, not enuff! Besides, JAVA has been proven and tested. Unless it can do something JAVA cannot do, why would I switch. PHP for me is just an interest thing. A new toy.

Posted by Michael Clayton on January 25, 2005 at 04:34 PM MST #


I'd like to comment on Permalink's original article:

>>I think Java is more of an industry standard, whereas PHP seems to be popular among hackers and hobbyists.

This is not a reason to do anything. Don't do stuff because others are doing it, that's for lambs. Do what you must. In fact, choosing technology X when your competition is using technology Y might be a competitive advantage (or it may be a fatal flaw - depends on what are you choosing over what).

>>Java provides better separation of layers - key for testability. PHP has all the code embedded in the page, so you have to run it through a browser to test if database connections work (for instance).

True to some extent, but that depends more on how do you design your PHP-powered system. If, for example, you keep all your database abstraction layer separate, you can test separately.

You can also use Smarty or other template systems to completely separate code from display, so you can have programmers write PHP code and web designers write HTML/CSS, change look or behavior separately, etc.

>>Java is more scalable.

Not true. Java applications tend to be state-based. PHP applications are stateless. It's far easier and cheaper to set an array of very cheap (even second-hand!) PCs running Linux+PHP, than Java clusters. PHP is scalable right-away, you don't have to design your applications to be so!

>>More folks know Java and it's easier to qualify someone's Java skills. How do you test someone knows PHP? Is there a certification?

There are PHP certifications, check out Zend's website. Java is, indeed, more widely known (although this is changing), but PHP is ridiculously easy to learn as opposite to Java. Besides, any Perl programmer will have it very easy to learn PHP, and Java/C/C++/C-like language programmers already know the syntax.

>>More for-profit organizations use it.

See my first comment.


IMO, Java will be better (and perform better) for very large applications, but elsewhere, I wouldn't doubt using PHP, for the following reasons:

1. It's far more productive than Java, and I mean far more. What it takes 10 hours to develop in Java, you can easily do in 1 hour in PHP. Time is money. This alone makes me like one language over another.

2. It follows the KISS principle, as opposite to Java which tends to produce bloatware and blOOatware.

3. This is part of the reason for points 1 and 2, but it deserves special mention: the PHP APIs are simple and productive, unlike Java's blOOated, cumbersome, needlessly complicated APIs. It's so overgeneralized you can't do anything quickly. It pretends to solve so many problems it doesn't solve anything easily. You can't possibly memorize all that and be productive with it. Think parsing a URL. In Java you have to create a new object and call methods with illogical names to do it. In PHP, all you have to do is call ONE function - parse_url - then simply access whavever you want as a hash, using the names you actually know and use everywhere, like port or host.

4. It's cheaper. Any cheap Celeron with 100% free software will be a great PHP server for a site/web application with tens of thousands of hits a day! As you need more power, scalability will be cheaper and simpler too - but there are few things a dual Xeon with PHP won't take! PHP can be ridiculously fast for small to medium-large applications in real environments.

Posted by Wiseman on May 15, 2005 at 09:22 AM MDT #

Whilst bubba is a bit brutal he is spot on, whist kok koon leong is way off the beam. Java is a terribly designed language. Here are some examples: C had case sensitivity because the complier had to be really small. C++ kept it to be compatible with C. So why does Java have it? Because it is very badly designed. There is no EOF function, so code bloats due to nasty tests. The substr function doesn't work properly as it cannot access the last character position (by design for crissake!) The complier is too smart (sorry dumb) to see variable definitions inside of if .. else constructs so you end up going through hoops to get different values into arrays. The inline array specification is a real bitch and causes tons of irritation. The = operator doesn?t work properly (instead of doing equals it does same as which is === in other languages), (again by design) which results in code littered with x.equals(y) These are just some of the absolutely absurd design decision that were made for Java. As an aside, the one thing that Java claims to have above other languages is portability. Een Java people admit that java has big design flaws and performs like a dog with no legs. Its object system isn't that great either. But it is portable. Honest. No real. PLEASE! P-system was portable. Early C was fairly portable but Java IS NOT. I have the misfortune to have to use Java (frankly I'd rather use VB or Assembler) and I have never seen a single non-trivial program that is portable between different version of the JRE running on the same platform, never mind on different boxes / OSes. The portability benefits are a myth. On one team we ended up with source code that had, in effect, 17 different braches for the 17 different JRE / platform / OS combinations that we had to support. I have never seen such a mess in my entire life. And the Java guys were still singing a happy tune about Java's benefits even as the Titanic went down. If you really, really want Java then be aware that you will suffer a world of pain, and gain nothing for your efforts. Java, like C++ and BASIC should be relegated to the garbage can of history.

Posted by liam on July 20, 2005 at 08:34 AM MDT #

java

Posted by Labros on May 02, 2006 at 07:42 PM MDT #

It's 2006, and PHP 5.1, a lot has changed since most of these comments were written.

PHP is pretty damned easy to install.
1. Install Apache
2. Install PHP with the windows installer
3. Add PHP's apache configuration lines. All 3 of them.
4. Restart apache.

Database access is now standardish. You have PDO (PHP Data Objects), PEAR::DB, and Zend_DB. Any of these options allow you to connect to any kind of database and go.

PHP has OOP. PHP doesn't (yet) have namespaces. It fits very well, barring that.

PHP now has SimpleXML. XML in PHP is easy.

A few other of Carl Fyffe's comments niggle me.

> They will tire of trying to avoid the circular includes.
PHP has had require_once, include_once forever. If you don't know about those, you haven't RTFM.

> They will tire of the constant ftp to the server to test out the latest changes.
It's too hard to set up your own apache + php installation? Four steps!

> And they will want a real IDE.
Maybe. I can't stand the damned things. My coworkers all use Zend Studio, and it's alright. The only thing it gives you is the ability to tab complete, and shorthand code completion. The rest... well the rest can be done with a decent text editor and a collection of command line applications. PHPUnit, ZendCodeAnalyzer. Doxygen.

The beauty of not using an IDE means you stay focused, your functions/classes/methods HAVE to be easy to remember and make sense, and if you don't KISS you dig your own grave. PHP used like that results in a very handy tool.

Posted by Daniel O'Connor on August 24, 2006 at 01:05 AM MDT #

@liam wow, i was reading this thread for fun, every body had a point except what is posted by liam, I have never heard such ridiculous argument. if your group has the same knowledge of you about basic programming (which is 0) your company is in deep shit! c++ is compatible with c??? why java is case-sensitive?? why .equals() instead of ==!!! wow!!!!!!! Amazing!

Posted by someone on October 20, 2006 at 03:11 PM MDT #

In web development PHP is the king. PHP and Java is different kind and class. PHP has a good MVC application eg. cakephp.org . Only typed and name space if lack from general point of view. Hope these features will be added soon, may be in PHP 6. A good programmer always deliver good code whether in PHP or Java. Today PHP is also web industry standard. Web jiant like yahoo and others using it. PHP has lot of certification method, best is Zend certification - world recognised. I myself know 14 languages and worked in more than 4. I have found many PHP programmers are novish or fresher, their lack of knowledge, should not be responsible PHP. Faster web development and free, powerfull site can be made by PHP. Only need constant new features to be added, what is always going for PHP and need good programmer to work with best programming way to deliver good code. Java is definitely leader in languages but PHP is the king of web development languages.

Posted by DHIRAJ PATRA on November 30, 2006 at 03:21 AM MST #

How dare you give an evaluation involving PHP when you are not familiar with the technology. You don't even know that there is a PHP certifications when there is. Your comments are nothing but ignorant. The rantings of a java programmer with no clue. I'm a developer who has worked with java programmers and I can tell you that I perfer PHP over Java any day for the simple fact that code a site in PHP is less complicated, less expensive and less bugs in the end. PHP is a powerful technology and I have never had any problems with my site that's coded in PHP. However, I have had endless complications with my java site and their endless variable declarations and classes. THE HELL WITH JAVA!!!

Posted by david on December 03, 2006 at 02:44 AM MST #

I think Java and PHP are for different things. I have been a Java programmer since 1997. I do coding on my job and make a living with it. Recently, I wanted to create a website for kids' math, I couldn't find a good open source java package for it. I searched on the web and found there are many good open source PHP packages there that may be good for the purpose.

I spent a month (a couple of hours each day) on creating www.mathpotd.org with Drupal. I think Drupal is well suited for the job. I don't believe I could do it in Java.

Java may be just for so-called enterprise applications -- companies hire high paid Java programmer for their good or bad systems.

Posted by Paul Z. Wu on December 04, 2006 at 01:34 PM MST #

i studied all the people comments . finally i came to one decision that is php is always better than java. what u say. ok agree

Posted by kiran on January 09, 2007 at 06:00 AM MST #

PHP and JAVA is different toys. PHP more rapidly to creating dynamic web site and only for web site that running on browser. But, today PHP has been regeneration to make client application using gtk. JAVA its also rapidly to creating dynamic web site using JSP, but many think you have to learn like a servlet, jsf, jstl and more, which is different every technics. So, my opinion is, for creating dynamic web site, i'll be using PHP for more more rapid development, cause of time is money, when you creating or developing the application which is should be run on website, taking a longer ... hmm... your money will be lost. PHP and JAVA, in my humble opinion is like a JAGUAR and MERCEDES BENZ....

Posted by Man'z on January 16, 2007 at 02:08 AM MST #

Stop trying to make PHP something it is not. PHP SUCKS! PHP has evolved (poorly I might add) from a set of PERL scripts and is best suited for small sites. It's a toy language, poorly written, poorly maintained. I could go on for pages about what a hack it is and ALWAYS will be. It's the VB3 of the web. Lots of people like it becuase you can be a rotton programmer and write in it. It's a weakly typed scripting language best suited for high school hackers. END OF DEBATE.

Posted by MG on February 05, 2007 at 11:07 PM MST #

Poor MG. I have personally written great web-based applications in PHP that surpasses anything Java-like we had, especially in terms of speed. PHP evolved from the web. Java came to the web, and did a top-heavy effort at that. Java reminds me of Dreamweaver. Since Adobe has taken it over, it takes 20 minutes longer to install/unistall, and the added benefits is useless as far as I am concerned. Same with Java. An overkill for web-based applications. PHP drives the Internet, Java desktop apps. There is space for both. Oh, and BTW, PHP has evolved greatly since 2003 when his thread was started. Do yourself a favor MG and read a bit more before you just shoot it down. You can program in PHP these days, you can program in Java. Your if's and my else's are exactly the same. And O (as in OO) there's much more to it than what I feel like typing now, trying to convert Mr Programmer De Lux to open his mind.

Posted by me on May 24, 2007 at 07:13 AM MDT #

i believe that PHP is Suitable for someone that needs to make a Website more quickly "take a look" - there so many php scripts that u just install (forums,chat,webmail,news,photo albums) they are free and u can just install them by no one knowing if the script is yours so ! i can make a website with forums chats -webmaiil photo albums and database articles in just a two hour time ! so I believe that php is just A something to do quick Java is Better ! more eficiently but there are no ready source codes to install for your website i believe that java is more professional on constructing a intranet .:))

Posted by peter_kosmas on September 04, 2007 at 07:11 AM MDT #

I suggest -that's for many posters- that you don't post *any* comparative comment if you don't REALLY know both languages.

Posted by Lox on September 12, 2007 at 06:44 AM MDT #

well php is good... java is good. i have experience in both. currently im making webapps written in php and all of them works pretty fine, apart from apps im maintaining. though i might not have so much extensive work with java than php. php has greatly improved since ive known writing php (2004: with java 2002). though im not so familiar now with how java works over the newer versions but php is pretty easy to use... also, whoever reads only the first few comments is not worth while being noted. both has so many changes overtime... and so much more to learn.

Posted by bluejay on September 18, 2007 at 04:24 AM MDT #

Hi, it was a great read. Could any of you guide me which language is best to develop an ERP comparable to SAP or Oracle/Peoplesoft/JDEdwards?

Posted by Amir Ali Tayyab on October 10, 2007 at 02:24 AM MDT #

Hey, you are talking about how easy or comfortable it is to program in both languages and how hard it is to put up their platform. In my opinion PHP is far more superiour, for the client! Java has a slow start up and requires more from the client's computer, as php is server side only and gives client a maximum ease of access. I like programming in PHP also, c for example is much harder. Never tried java though, as I don't like the idea of needing to own java platform for it's applications to use.

Posted by Madis on October 16, 2007 at 09:58 AM MDT #

Best Penis Enlargement Methods. Guide to Choose a Penis Enlargement Product. Advices for Men Who want to Make a Penis Size Larger.

Posted by David Hill on October 25, 2007 at 11:59 PM MDT #

Java as a solution for a website is soooooooooooooooooooooo slooooow... What would be interesting to know is what web applications can be made with java and not with php or vice versa. Greetz, Iwan

Posted by Iwan on November 04, 2007 at 03:58 PM MST #

I'm migrating from J2EE to PHP, I think PHP is:
- more scalable;
- more simpler and fast;
- fast to develop;
The customers always ask to make a site with good performances, and java is not the right choice.

Posted by mike on January 22, 2008 at 04:20 AM MST #

The truth is: many people using php don't have any clue about java and many people using Java don't have any clue about php but both are quite the same in a web context with a few things that make them more liked in different situations.

I personally believe as i'm a php guy that php is a much better choice for any web app/site needs, just because it has been a great part of my experiences while the few experiences i had with java were about highend big company webapps built in the early 2k. I'll try to say a few things about what i know better, wich is php:

-php isn't a pure oo language, wich imo is the main reason why many php apps are faster than any java concurent (because java object model and framework is so rich that it's just oversized as a response to web's small needs)
-php let the developpers do as much mistake and design errors as they want. This is actually a big advantage because it also means it's easier to learn for the beginners and that doesn't means that an experienced developper will engineer a bad an lacking performance or maintenability code.
-php offers a response to most of the needs one can have. Including offline and asynchronous tasks and permanent session (that would be with some work done with the operating system but still it's not a really hard thing to obtain) as i see it those 2 are the main reasons for an enterprise to go the java way in a web based application.
-php is widely available and used over the web, much more than java and increasing, there isn't much more to say here that's just a fact with natural consequences to expect.

Now as i see it, java has been created to handle domotic needs in the first place and still is a common used language in many industrial companies, like cars etc, that isn't imo a domain php is suited for, even for traditional heavy client market java is much more used than php will probably ever be. Php has a big advantage on the web mostly as it is used in apache as a module zeroing any VM launch time, but in any other context Java and php both take time to run comparing to any compiled program, as far as i'm concerned i see no problem saying java is better than php when it comes to anything but web things, i could mention tho, that there is a lot better than java there with C++ or C but that is another troll i guess :)

Posted by 41.208.139.136 on January 22, 2008 at 10:58 AM MST #

As you said...

* "I think Java is more of an industry standard, whereas PHP seems to be popular among hackers and hobbyists."

-- I believe Java is more popular among the industry who can afford high bucks. While PHP - Powerful Hyper Text Processor in my opinion is most popular among web-applications.

I personally used both Java and PHP for same web-application and found PHP processing the data much faster than anything else in near-by competitors.

Regarding security, I do not think anything Java, ASP or PHP can secure 100%, once door to internet gets open while connecting to World Wide Web. When no one can guarantee 100% security or bug-free version, why not to go for an open-source.

* "Java provides better separation of layers - key for testability. PHP has all the code embedded in the page, so you have to run it through a browser to test if database connections work (for instance)."

-- Not necessary, PHP codes do not require to embedded in the web-page. As PHP has choice between include() and require() function.

* "Java is more scalable."

-- Personally, I could not find anything PHP can not do that Java can do. But, as a matter of fact I could not found any Java based online shopping-cart application which is fast and popular.

* "More folks know Java and it's easier to qualify someone's Java skills. How do you test someone knows PHP? Is there a certification?"

-- PHP runs on Zend Engine, Zend offers PHP certification and Zend is founded by Zeev Suraski, Andy Gutman and Rasmus Lerdorf who invented the PHP.

* More for-profit organizations use it.

-- If we look at the statistics provided by third party, PHP installations on web-server keep increasing day by day because of more than one factor. The one factor is easy to learn. Syntax is very similar to C++ and Java programming. Plus it's really fast interpreted language.

Posted by SID TRIVEDI on February 10, 2008 at 11:42 PM MST #

Yes whatever written above is totally agreed , i am working in both domains , but I thing i want to say , php programmers salaray is much less in comparisons to Java developers , any comment guys

Posted by rajeev on March 03, 2008 at 04:16 AM MST #

I know how to code in PHP, and I make my online applications in PHP. Java and PHP has certainly similar syntax, and PHP and JSP can do pretty much the same thing. PHP is easier to learn, no doubt, but by the fact Java is more powerful. By contrast I think PHP is better for general online scripting, whereas complex and large online applications need the help with Java.

Posted by Ben on March 12, 2008 at 06:44 AM MDT #

yeah PHP programmers salary is low in comparison of java programmers.

Posted by prabhat on March 31, 2008 at 05:38 AM MDT #

I'm sorry I've been working in Java for years, since the beginning it was a crap in performance, just to go to database, take 10 rows and display it on a grid needs a lot of time and memory, in a normal computer deploying an app, just around 10 seconds, that´s a lot, even using oracle, now using php + mysql even on windows is faster, as fast as the click of the button. About the future Ajax is very good performed with php5, a response is very fast even in a network production environment, in java ajax is another delay in time, it doesn't makes sense to use a technology to make things faster if the java virtual machine just delays 4 seconds just to respond, so I have to say I work in Java and companies go by that side, but the future is in very big internet companies like google or yahoo, and guess what, they aren't going with java because java is not enought fast, worst for thousands of users. PHP is there for the future RIA in LAMP, well even in web 2.0 java is lost.

Posted by maharba on April 01, 2008 at 07:07 PM MDT #

If your vm is taking 4 seconds to respond, you don't know what you are doing. Comparing languages is pointless. Each has their own pro's and con's but for the most part you will get the same results, provided you code efficiently in the language you do choose to use.

Posted by random on April 24, 2008 at 02:43 PM MDT #

Can abybody tells me that what the salary and designation scope in PHP. Which companies are working in PHP in NCR region

Posted by Manju chauhan on May 14, 2008 at 02:36 AM MDT #

Can abybody tells me that what the salary and designation scope in PHP. Which companies are working in PHP in NCR region

Posted by Manju chauhan on May 14, 2008 at 02:37 AM MDT #

Can abybody tells me that what the salary and designation scope in PHP. Which companies are working in PHP in NCR region

Posted by Manju chauhan on May 14, 2008 at 02:37 AM MDT #

Lots of *very* insightful comments. I will now add my own:

I drank too much Java. Now I have to PHP.

Goodbye, you self-serious clods!

Posted by all i know on May 23, 2008 at 02:30 PM MDT #

How penis enlargement pills work, check penis enlargement techniques.

Posted by Extenders on August 11, 2008 at 01:25 AM MDT #

> [In Java] take 10 rows and display it on a grid needs a lot of time and memory, in a normal computer deploying an app, just around 10 seconds. That?s idiotic. I can tell you this is unequivocally false. I?ve written dozens of Java web applications and never once had a problem with performance. In ten seconds, on an ?average? corporate network, I can retrieve and display several hundred thousand rows.

Posted by Bob on August 12, 2008 at 08:59 AM MDT #

so what about future of fresher developer or a job searcher in development who wants to work in php it will be equivalently secure like java and .net developer and wht about salary ?

Posted by raj on August 17, 2008 at 11:18 AM MDT #

so what about future of fresher developer or a job searcher in development who wants to work in php it will be equivalently secure like java and .net developer and wht about salary ?

Posted by raj on August 17, 2008 at 11:19 AM MDT #

so what about future of fresher developer or a job searcher in development who wants to work in php it will be equivalently secure like java and .net developer and wht about salary ?

Posted by raj on August 17, 2008 at 11:20 AM MDT #

so what about future of fresher developer or a job searcher in development who wants to work in php it will be equivalently secure like java and .net developer and wht about salary ?

Posted by raj on August 17, 2008 at 11:31 AM MDT #

I would say, java is worst for web application development. You can say java was used for corporated and php is just for web site. That's not true ... what php cannot do compared with java ? you might mentions many bloated technologies behind java ... but I would say ... php can accomplish the same task just in different ways :) I have experiences with both php and java. I can create a web apps in php 3x faster than using java :) I was using JSF at that moments. If you are love java ... I would suggest you to try groovy and grails. they are great !!! groovy was based on java and its language was dynamics ... less formal and easier to understand :) They are looks like ruby on rails... using Spring and Hibernate technology ... but LESS XML STUFF ... that's the fun thing !!! I use grails and codeigniter (php) for developing everydays web apps ... if my customers ask to use java .. i use groovy ...

Posted by adwin wijaya on September 17, 2008 at 05:12 AM MDT #

I would say, java is worst for web application development. You can say java was used for corporated and php is just for web site. That's not true ... what php cannot do compared with java ? you might mentions many bloated technologies behind java ... but I would say ... php can accomplish the same task just in different ways :) I have experiences with both php and java. I can create a web apps in php 3x faster than using java :) I was using JSF at that moments. If you are love java ... I would suggest you to try groovy and grails. they are great !!! groovy was based on java and its language was dynamics ... less formal and easier to understand :) They are looks like ruby on rails... using Spring and Hibernate technology ... but LESS XML STUFF ... that's the fun thing !!! I use grails and codeigniter (php) for developing everydays web apps ... if my customers ask to use java .. i use groovy ...

Posted by adwin wijaya on September 17, 2008 at 05:15 AM MDT #

For Layton on August 22, 2003 at 05:23 PM MDT: Layton, what you said (defaults to passing copies of objects rather than passing/returning references to objects) is right with the php4 but not with php5; in php5 it passes references of the objects only same as java.

Posted by Nehatha on October 16, 2008 at 04:30 AM MDT #

Fact 1:
PHP programmers are by far the worst programmers of all. No other programmers have the capacity to produce gazillions of terribly mediocre script as PHP programmers do.
Fact2:
PHP is easy to learn. That's its streagth and in there lies its weakness too. Because every hippy with a notepad can write php code and get instant gratification of being able to echo out HELLO WORLD in a minute or so.
IT also means these same hippies are the ones who after writing few extra lines of code consider themselves programmers and start up their own blogs to share their knowledge of PHP via tutorials and scripts and litter the internet with criminally mediocre code.
There's nothing terrible than seeing a whlole page being bulit with PHP ECHO statements.
eg. echo "<HTML><HEAD>.......". And that's exactly what hippies do when they realise they can use PHP to actually output html too. U see, hippies are not aware of the benifit of separating applications into layers for managebility, maintainability and flexibility. Hippies do live in their own world u see....

Fact 3:
Zend framework is crap. there I said it.... And it comes out of a company run by the inventors of PHP. Though I tried so many times, I just can't seem to bring myself to use it....
Fact 4:
In fact pretty much all PHP frameworks are crap.
Fact 5:
Pretty much every JAVA frameworks suck too. :-)
Fact 6:
All the improvements that gets put in new releases of PHP is just a catch-up game with JAVA.
Fact 7:
Any language that doesn't have native support for namespace is a language for amateurs :-)
Fact 8:
PHP can't do everything java can, not by a long shot. Multithreading ?? hello! Try writing an applet :-)
Fact 9:
I like Java and I like PHP too. But if someone tries to tell me PHP is better than java or PHP is inpar with java , I always beg to differ. Its like comparing a bicycle with a car..... not quite but close :-)
Fact 10:
Netbeans has released a FREE IDE for PHP. Its got all great features like code completion, syntax highlighting, marking of occurrences, refactoring, code templates, pop-up documentation, easy code navigation, editor warnings, a task list, as well as a debugger. F
Fact 11:
Netbeans is a product of Sun Micro Systems. Yes, hippies, that's right, they are the folks that gave you java and now they are trying to turn hippie PHP programmers into real programmers by providing a productivity tool with a standard project structure and heaps of goodies to make PHP software development so much better.
Fact 12:
Zend IDE from the hippies that brought us PHP is a commercial tool. and even then it sucks big time. I haven't even started on the commercial Accelerator that Zend provides to speed things up in PHP, and why greed is a bad thing for hippies and why such greed only harms the cause og PHP as a language.
Fact 13:
FACT 11 & 12 point to the fact that java community is making a greater contriution to PHP than hippies that run Zend.
Fact 14:
Netbeans PHP IDE is the best thing to happen to PHP programmers after sliced-bread.
Fact 15:
If you don't like Netbeans PHP IDE, u r a hippie!
Fact 16:
: I have to admit , I like PHP too. I program in both languages and I can switch languages with equal ease. Not just that I use combination of both sometimes to get things done. And both java n php programmers might find it horrifying but I like JavaScript too. I like to write language agnostic web applications. I use a lot of javascript and good database domain model. If you have a rich set of javascript library and a well designed database model, server-side language merely acts as a service layer.....and I can throw away PHP and use java when I need java's power and flexibility, without rewriting my whole application.

Posted by anjan on October 21, 2008 at 08:42 PM MDT #

"Fact 7: Any language that doesn't have native support for namespace is a language for amateurs " Only a little comentary: C and assembler are for amateurs? hehe... i love these kind of amateurism boys!!!

Posted by Gabriel on November 06, 2008 at 01:02 PM MST #

@Gabriel You are spot on with your comment. C and Assembly language are absolutely not for amateurs. I should have rather stated - "Any HIGH-LEVEL language that doesn't have native support for namespace is a language for amateurs". But even then it will still be incorrect. Erlang anyone?? perhaps I should have stated " "Any HIGH-LEVEL language that doesn't have native support for namespace is a nightmare for large projects". Even then there are shitloads of large projects done in functional languages where namespace issue is no issue..... Damn it... its getting tricky... Perhaps, the most politically correct statement would be " Any High-level language that pretend to support object-orientation without support for namespace is a language for hippies." Now, I'm not sure if hippy is a politically correct term here......

Posted by anjan on November 13, 2008 at 06:36 PM MST #

Thanks to all of you for your contributions (except for the very few that are obviously jerks).

Java vs PHP is a debate that is here to stay, the reason I am looking at this page is that I got sucked in to a large Java project and I have found it absolutely incredibly hard to do stuff that in php is quite simple. mysql_fetch_array in php for instance, vs no such thing in java, unless I've been looking in all the wrong places.

I've done a lot of programming, from assembler to C, php, basic and a whole slew of other languages but I do not remember anything quite as 'verbose' as Java code, it looks like classes are endlessly repeating chunks of code that are handled quite easily by utility functions in other languages but which are either not present in java or nearly impossible to implement. Portability seems to be another issue, switching from 'resin' to 'tomcat' caused all kinds of build issues, changing a single class and redistributing it requires a server shutdown and so on.

I'm sure I'm still doing lots of stuff 'wrong' from the java point of view but I have a feeling that PHP has improved a lot in the last few years whereas java has more or less stood still when it comes to doing web development.

I'll keep revisiting this thread from time to time to see what else comes up, it sure has been an interesting read.

And now back to java coding :(

j.

Posted by Jacques Mattheij on December 28, 2008 at 05:03 PM MST #

If you are a developer who works for others, then Java should be the language of choice because it pays more and it always has some hype and buzz around it to attract the big enterprise community . If you work for yourself and you know both Java and PHP, most likely you would be using PHP for your web applications. Due to the hype or whatever, I did Java for some time. Then I started to work for myself and I spent a lot of time deciding which Java technology (I had assumed I want to use Java) to use for my own firm. It was really horrible. Every time I came up with an IDE/Framework of my choice, I would come across something totally new (buzzword, framework, specification, server etc). Then I just wanted to give a thought to PHP and realized that PHP can do everything that I needed minus most of the headaches. For web development, I think PHP will always dominate because it is cheaper and easier to write web applications in PHP than in Java or .Net. Most people like free/cheap and simple stuff like craigslist, google, wikipedia, joomla!, linux, MySQL etc. I see a very bright future for PHP as long as it does not follow the same path as Java in terms of complexity.

Posted by Cifar24 on January 25, 2009 at 02:45 PM MST #

I purely agree that PHP will be the language of next gen for web development. I've been a hard core java developer for years but now i'm designing a site for which i had to learn php. After building few pages with php i've seen there z a lot of reduction in development time compared to that of java and php is faster than java at times.(NO vm required for php)

In terms of scalability php scales more than java. (Read it in a recent study article published by the architect of XML and co-founder of OpenText). Java is next to php in scaling, but yes maintaining php files is a bit confusing than java packages. Until or unless you aren't developing web apps for a company which has its own dedicated server and own resources i would preferably say php will be a better choice.

Posted by Kailashnath on February 16, 2009 at 02:36 AM MST #

Well, I appreciate thought expressed by various people here, I came to this thread because I had dilemma what to use for server side development when we are going to convert our delphi firebird C/S application into a web application. This thread gave me fairly good idea about pro & cons of PHP and Java as server side technologies and I have decided to go by PHP way since I am working for my own firm and I have to deliver the application as fast as possible. But I am not really brushing off option of Java as server side technology I am just postponing it till we gather experience about PHP as server side technology. BTW this is the First web application we writing so we chose on simple and fast productive way rather than on technically superiority of these technologies. Thanks all the guys who contributed to this thread.

Posted by Raja S Patil on April 17, 2009 at 03:13 AM MDT #

>> It's easy in PHP to dynamically include files, but not possible in Java (that I know of) Try the below <%@ include file="somefile.jsp" %> <jsp:include page="someFile.jsp" /> >> Also, it's fast to develop in. Whereas in J2EE, you'd have to compile, deploy, wait for JSP to compile (if you didn't precompile them beforehand) and then you can test it Check out "Sysdeo Eclipse Tomcat Launcher Plugin" or "MyEclipse Plugin". >> It took me some time to figure out how to use servlets and jsp but only a few minutes to hack out a php script. If you compare just PHP script with JSP script, then the learning curve and will just be the same. And with the extension lib from Apache Commons Lib, it will be as easy to use JSP as PHP. http://commons.apache.org/components.html >> Java has a slow start up and requires more from the client's computer, as php is server side only and gives client a maximum ease of access Hi, I think you miss the point. Both J2EE and PHP are use as a server side programming and sends only client side codes like html and javascript to browser. Most people here did not mention Java applet as it is mostly use as a heavy client purpose. >> php isn't a pure oo language, wich imo is the main reason why many php apps are faster than any java Sounds logical. But does that means anyone who use OO in PHP5 will experience slower response that is comparable to Java?

Posted by Ryan on April 19, 2009 at 08:48 AM MDT #

-- It's easy in PHP to dynamically include files, but not possible in Java (that I know of) Try the below <%@ include file="somefile.jsp" %> <jsp:include page="someFile.jsp" /> -- Also, it's fast to develop in. Whereas in J2EE, you'd have to compile, deploy, wait for JSP to compile (if you didn't precompile them beforehand) and then you can test it Check out "Sysdeo Eclipse Tomcat Launcher Plugin" or "MyEclipse Plugin". -- It took me some time to figure out how to use servlets and jsp but only a few minutes to hack out a php script. If you compare just PHP script with JSP script, then the learning curve and will just be the same. And with the extension lib from Apache Commons Lib, it will be as easy to use JSP as PHP. http://commons.apache.org/components.html -- Java has a slow start up and requires more from the client's computer, as php is server side only and gives client a maximum ease of access Hi, I think you miss the point. Both J2EE and PHP are use as a server side programming and sends only client side codes like html and javascript to browser. Most people here did not mention Java applet as it is mostly use as a heavy client purpose. -- php isn't a pure oo language, wich imo is the main reason why many php apps are faster than any java Sounds logical. But does that means anyone who use OO in PHP5 will experience slower response that is comparable to Java?

Posted by Ryan on April 19, 2009 at 08:49 AM MDT #

-- It's easy in PHP to dynamically include files, but not possible in Java (that I know of) It is possible. Java have the syntax to do that. -- Also, it's fast to develop in. Whereas in J2EE, you'd have to compile, deploy, wait for JSP to compile (if you didn't precompile them beforehand) and then you can test it Check out "Sysdeo Eclipse Tomcat Launcher Plugin" or "MyEclipse Plugin". -- It took me some time to figure out how to use servlets and jsp but only a few minutes to hack out a php script. If you compare just PHP script with JSP script, then the learning curve and will just be the same. And with the extension lib from Apache Commons Lib, it will be as easy to use JSP as PHP. http://commons.apache.org/components.html -- Java has a slow start up and requires more from the client's computer, as php is server side only and gives client a maximum ease of access Hi, I think you miss the point. Both J2EE and PHP are use as a server side programming and sends only client side codes like html and javascript to browser. Most people here did not mention Java applet as it is mostly use as a heavy client purpose. -- php isn't a pure oo language, wich imo is the main reason why many php apps are faster than any java Sounds logical. But does that means anyone who use OO in PHP5 will experience slower response that is comparable to Java?

Posted by Ryan on April 19, 2009 at 08:51 AM MDT #

-- It's easy in PHP to dynamically include files, but not possible in Java (that I know of)

It is possible. Java have the syntax to do that.

-- Also, it's fast to develop in. Whereas in J2EE, you'd have to compile, deploy, wait for JSP to compile (if you didn't precompile them beforehand) and then you can test it

Check out "Sysdeo Eclipse Tomcat Launcher Plugin" or "MyEclipse Plugin".

-- It took me some time to figure out how to use servlets and jsp but only a few minutes to hack out a php script.

If you compare just PHP script with JSP script, then the learning curve and will just be the same. And with the extension lib from Apache Commons Lib, it will be as easy to use JSP as PHP. http://commons.apache.org/components.html

-- Java has a slow start up and requires more from the client's computer, as php is server side only and gives client a maximum ease of access

Hi, I think you miss the point. Both J2EE and PHP are use as a server side programming and sends only client side codes like html and javascript to browser. Most people here did not mention Java applet as it is mostly use as a heavy client purpose.

-- php isn't a pure oo language, wich imo is the main reason why many php apps are faster than any java

Sounds logical. But does that means anyone who use OO in PHP5 will experience slower response that is comparable to Java?

Posted by Ryan on April 19, 2009 at 08:53 AM MDT #

hi frd m very confused in java and php . which one is best ?...m intersted in software making,hacking,and virus making ...plz tell me which one is best for me java or php?

Posted by pankaj on April 20, 2009 at 03:04 AM MDT #

I have read most of these comments and still not sure to start learning more java or get to know php coding at an expert level. Am actually a masters student. We have been taught JAVA and is very boring when it comes to write codes. After Masters, my intentions to pursue a carrier in programming. Right now, I have to start my final project of web application for a shop and have only 3 months to complete it. Should I continue doing JAVA as I have learned it some how in the past 6 months, or work on PHP for it if it's more demanding at a professional level. cheers :)

Posted by Shah on May 30, 2009 at 09:49 AM MDT #

I have read most of these comments and still not sure to start learning more java or get to know php coding at an expert level. Am actually a masters student. We have been taught JAVA and is very boring when it comes to write codes. After Masters, my intentions to pursue a carrier in programming. Right now, I have to start my final project of web application for a shop and have only 3 months to complete it. Should I continue doing JAVA as I have learned it some how in the past 6 months, or work on PHP for it if it's more demanding at a professional level. cheers :)

Posted by Shah on May 30, 2009 at 09:50 AM MDT #

I have read most of these comments and still not sure to start learning more java or get to know php coding at an expert level. Am actually a masters student. We have been taught JAVA and is very boring when it comes to write codes. After Masters, my intentions to pursue a carrier in programming. Right now, I have to start my final project of web application for a shop and have only 3 months to complete it. Should I continue doing JAVA as I have learned it some how in the past 6 months, or work on PHP for it if it's more demanding at a professional level. cheers :)

Posted by Shah on May 30, 2009 at 09:51 AM MDT #

Note that most of comments were made more than 5 years ago, both Java and php went a long way since then. There really is no wrong or right, the is only "right for you". I have been working with php for almost 10 years now and with java for 7. Clearly when it comes to server side programming and stand along apps (not web), php should remain out of the picture, but the topic is about web applications, so let's see. Java is clearly easier to test, has better development tools, but is slower to write code in, harder to learn, more complicated to deploy. Php suffers from so called "hobbyists" - people who wrote their first "hello world" in php and never seriously learned it. With some skill, planning and patience people could and do write their own frameworks or use existing ones, but at most there is 1% of them (really!), the other 99% will write one webpage or a couple and call themselves php web developers, sorry, but that is where php is getting bad rep from. If you forget about human side of programming and look at language as a tool, both php and java serve well when requirements are different. If your project is relatively simple and has limited use, need fast development in small team - use php. If you need a bigger corporate level app with extensibility and high quality in mind, clear winner is java. I have php web projects that started at 10 pages and grew to 100s of variable complexity with internationalization, heavy db use, caching, heavy on dynamic graphics, you name it really and a lot of times I wish I had done everything in Java, but there are other times where if I did it in java, project would took years to complete and would have been useless by that time. The bottom line really is - both java and php are good as long as you have brains and know how to use them.

Posted by Tadas on November 30, 2009 at 10:56 AM MST #

You don't know that much about PHP yet you make statements like "Java is more scalable". Now, I'm not going to argue on these points as each language has its merit (having worked with both). I prefer the structure and strong-type of Java, but PHP is far better for rapid development (Frameworks not included in this comparison). I can't help but feel that this is a troll post, and I've been sucked in. Regardless, please research the techs you want to compare ;)

Posted by kirk bushell on March 18, 2010 at 06:50 PM MDT #

I just want to than all the guys who posted here.I am working on php but I was'nt sure how good is php from a career's point of view compared to java.you guys have answered a lot of questions.Thank you very much .great blog.cheers

Posted by rakesh on April 19, 2010 at 09:50 PM MDT #

In 2003 Java is far better than PHP but development in PHP is increase rapidly as compare to Java Through all comments .... I would say, java is worst for web application development. I m developing web apps in PHP to start my career in web apps then i migrate to web apps to mobile apps because of using of mobile apps increase vastly. As far as i know there is no support in PHP to develop mobile apps. So i migrating to .NET Silverlight to develop apps for Windows Phone 7 . Share ur opinions is that right? Thnx for all comments above

Posted by Ali on April 23, 2010 at 04:30 PM MDT #

In 2003 Java is far better than PHP but development in PHP is increase rapidly as compare to Java Through all comments .... I would say, java is worst for web application development. I m developing web apps in PHP to start my career in web apps then i migrate to web apps to mobile apps because of using of mobile apps increase vastly. As far as i know there is no support in PHP to develop mobile apps. So i migrating to .NET Silverlight to develop apps for Windows Phone 7 . Share ur opinions is that right? Thnx for all comments above

Posted by Ali on April 23, 2010 at 04:31 PM MDT #

I am a php developer for 4 years now and a Java J2ME developer for 1 year now and I think this comparison is pointless. PHP is THE web programming language. Java has many many other purposes, but sucks pretty much for web development. So to say.. if I want to handle a SOAP Client request in php I need 3 lines of code (YES - only 3) in Java.. around 80 lines of code... if I want to develop a mobile application which has to run on 1000 models of devices, php will not help me. The best thing of php is the freedom, the freedom to choose and the freedom to think differently. It has a magnificent OOP model, brilliant frameworks and design pattern implementations. It will soon have namespaces and more deeply object related functionalities which are now available as functions. And lets not forget the FOREACH ;) You should use each of those languages in its best, they both have a perfect philosophy in its own manner, so dont be a horse with panels!

Posted by Ivan Ganev on May 03, 2010 at 02:06 AM MDT #

How you can compare the Hypertext Preprocessor with a compiled language ? So your next comparison should be: JavaScript versus C++! which one is better for web apps?

So the Java is to develop any cross platform application. The PHP is to develop websites.

Yes, you can do websites using JAVA as you can walk on the beach wearing ski boots :)

I worked for one big company for 6 months so I'd say: that company is developing lot of webapps or websites and all of them using JAVA,why? because they can hide the code against customer, even the client can decompile the app cannot re-use simple way. And as far I remember it was painful for us and almost everyone asked: why not in PHP?

The funniest was: the company website was written in PHP ;)

Posted by daniel on May 07, 2010 at 04:52 AM MDT #

I think it's interesting to see how Facebook compiles their PHP to C++ in order to increase performance.

Posted by Matt Raible on May 07, 2010 at 10:28 AM MDT #

Bottom line.. a developer will try to sell the solution they are comfortable working with. Should make little difference to the end user..unless the user has a very specific platform prefrence

Posted by Yogesh on June 13, 2010 at 11:00 PM MDT #

I think new version are coming in for PHP, Now, soon it will be possible that what we can do with Java we can do it using PHP as well. The new version of PHP i.e PHP 6 will be coming with better and better features.

Posted by Anirudha on August 19, 2010 at 06:02 AM MDT #

I think new version are coming in for PHP, Now, soon it will be possible that what we can do with Java we can do it using PHP as well. The new version of PHP i.e PHP 6 will be coming with better and better features.

Posted by Anirudha on August 19, 2010 at 06:02 AM MDT #

Great comments, its pretty easy to identify the PHP'ers who don't really have the capacity to understand true application requirements.. And you Java guys who hav't really used PHP commercially, just glossed over the feature list, you ain't much better comparing the two.

But I can honestly say I'm qualified to make a point. 10+ years exp biulding internet apps of ALL types, started with PHP4 back in the day, built many an app, and administration system (50+). PHP was fine while the job was small.

Then evolved into Java which is now the bread and butter. Built real apps, multi-tiered, distributed, cached to the shit for some of the bigger brands in the country. And it is the shit.. if the client wants it, it can be done in Java.

But I'm not gona pointlessly highlight pro's and con's of each. They're both bloody good at what they do, which is why so many of you are red-faced defending your babies... as you should.

However the question is, which do you recommend to the client?

Well... the answer is... WHAT ENGINE OF CLIENT DO YOU HAVE?

Both will do the job, BUT, if your client is a notorious tight arse who bitches and moans with every cent they spend irrelevant of the bigger picture, and the job isn't massive, go with PHP. You'll be able to get dev's, and if they are half descent occasionally will deliver on the promises they gave with naive arrogance.

But if the client is willing to invest, has realistic expectations, has priorities squarely focused on long term goals, and has hopes to build on their investment over time, go with Java. By commiting to Java you're generally agreeing to a more structured approach, not just in code (which for a few of you clearly still think is all that matters), but also a more structured build process, with some sort of actual methodology, architectural consideration and design phase, documented requirements and signoff points.

And the end of the day the client needs some sort of assurance before the nerds start bashing out code, whatever language they choose. So make sure whoever you hire is not the sort of amature that spends all day on forums blindly defending the only programming language they know!

Posted by ExperiencedDude on September 01, 2010 at 09:42 PM MDT #

I think when looking a Java versus PHP, both a capable programming languages. Saying Java has better separation isn't necessarily true. It has good separation when using Struts or something similar. But now you're not making a fair comparison because you're talking about more than just Java. If you are looking at Java+Struts, then you need to look at PHP+Zend. The Zend Framework adds a great deal of separation and ease of coding to PHP. I personally like using .php file to represent classes or logic and .phtml files for layouts and view code. So PHP can be MVC when using a quality framework, just like Java.

Posted by OneComment on November 11, 2010 at 10:14 AM MST #

HipHop for PHP transforms PHP source code into highly optimized C++. It was developed by Facebook and was released as open source in early 2010.

HipHop transforms your PHP source code into highly optimized C++ and then compiles it with g++ to build binary files. You keep coding in simpler PHP, then HipHop executes your source code in a semantically equivalent manner and sacrifices some rarely used features – such as eval() – in exchange for improved performance.

Facebook sees about a 50% reduction in CPU usage when serving equal amounts of Web traffic when compared to Apache and PHP. Facebook’s API tier can serve twice the traffic using 30% less CPU.

https://github.com/facebook/hiphop-php/wiki/

http://en.wikipedia.org/wiki/HipHop_for_PHP

Posted by 121.97.136.228 on April 22, 2011 at 08:12 AM MDT #

i would suggest you to check following pdf for your answer

http://www.cs.montana.edu/~tosun/phpvsjava.pdf

Posted by mack on April 11, 2012 at 06:59 AM MDT #

To quote the last comment "i would suggest you to check following pdf for your answer"

http://static.zend.com/topics/0200-T-WP-1107-R1-EN-PHP-is-not-Java-Seesions-in-PHP.pdf

After doing my own DD, I beleive both (specifically HipHop vs EE) have there applications and it depends on the requirements of the application. I dont think any one in the EE camp can argue with the scalability of FB, just as anyone else can argue with the maturity, security, & distributed architecture with application persistance that EE has and is the backbone of Amazon. I believe that the two together can do some real magic depending on the application requirements.

Although, i have to say it, PHP is more applicable to Agile Projects, you can hit the ground running with rapid prototyping...

But good grief forbid even the thought of re-engineering/implementing any EE code into php!

Posted by DG on November 08, 2012 at 11:50 AM MST #

Post a Comment:
  • HTML Syntax: Allowed