PHP compared to Java/J2EE

M

Michael Fesser

..oO(Sherman Pendley)
I've yet to see a cross-posted language comparison that remained civil.
This may be the exception, but I doubt it will be.

It's just a question of when to leave the thread. ;)

Micha
 
P

Patricia Shanahan

flarosa said:
Hi,

I'm wondering if I can get a reasonably civil (without starting any
huge wars) opinion on how server-side PHP compares to server-side
Java.

I'd like to suggest a protocol for maintaining civility in this type of
conversation.

*Only make definitive statements about a language if you are an expert
in that language.*

If you are a Java expert who sometimes uses PHP, say things you know
about Java, but ask "How would that situation be handled in PHP?". Other
way round for PHP experts who sometimes use Java.

Patricia
 
M

Michael Fesser

..oO(Wojtek)
Michael Fesser wrote :


Hundreds is not a lot.

Doesn't matter. They're resolved by the compiler like all other symbols.
If you run into performance issues the first thing to do is to profile
your code to see where the real bottlenecks are. In most cases it's the
algorithm, not the language.

Micha
 
J

Jerry Stuckle

Sherman said:
I've yet to see a cross-posted language comparison that remained civil.
This may be the exception, but I doubt it will be.


Learn both - and Ruby, Perl, Python, C, C++, C#, etc. The more tools you
have in your toolbox, the better-equipped you'll be to apply the most
appropriate one for the task at hand.

The phrase "object-oriented programmer" makes about as much sense to me
as "brush painter" or "saw carpenter." I can't see the point in limiting
one's options so narrowly.

sherm--

Sherm,

Obviously you didn't grow up (programming, that is) in the age before OO.

Back in the 60's and early 70's, structured programming was a novelty! :)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
(e-mail address removed)
==================
 
J

Jerry Stuckle

Lew said:
It still is.

Naw, in the late 70's and early 80's it became more mainstream. It
still is in a lot of circles.

What I'm talking about it the age of GOTO's, etc. COBOL, FORTRAN, etc.
Much different than what we have available in a lot of languages today.

Even COBOL has an OO version now...

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
(e-mail address removed)
==================
 
J

Jerry Stuckle

Steve said:
i think lew was making a joke there.

I think you're right, Steve. But at midnight after a night out with the
guys, I'm not always in the right frame of mind to get the subtleties :).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
(e-mail address removed)
==================
 
S

Steve

Jerry Stuckle said:
I think you're right, Steve. But at midnight after a night out with the
guys, I'm not always in the right frame of mind to get the subtleties :).

s'all good, momma. hope you had a good time. it's good to get away from the
screen now and again, eh.

cheers
 
M

Mark Space

KDawg44 said:
This is an interesting discussion. I have used Java but never used it
for a web application. Can anyone point me to a good place to learn
how to use this? Is this using JSP and servlets or is this something
else?

Yes, web apps for Java mean JSP and servlets, plus some other stuff.
You could do it with just sockets, but your brain would probably explode.

Sang Shin is a technology evangelist who works for Sun, and teaches free
online classes on Java and J2EE. (J2EE = JSPs and the webby bits.)

His J2EE class starts in about a week. You should check it out.


http://www.javapassion.com/j2ee/
 
J

Joshua Cranmer

flarosa said:
Hi,

I'm wondering if I can get a reasonably civil (without starting any
huge wars) opinion on how server-side PHP compares to server-side
Java.

Civility in language comparison can be asking a lot sometimes.

I am going to start by saying that I have very limited experience in
this question: I've worked a total of 1 PHP projects and 0 Java EE projects.
I've been strictly a Java developer for almost 10 years now, and I'm
pretty happy with it. However, I can't help but notice that there are
a significant amount of PHP-based development projects where I live,
and I've also noticed when searching around the internet for ready-
made web applications that a lot of them are in PHP.

My general impression is "stay with what you are comfortable with if
feasible."
As an object-oriented programmer I've always assumed PHP was more of a
scripting language for doing things on individual web pages or writing
small applications and that Java/J2EE was better positioned for
writing large applications, but maybe that's no longer true.

PHP's largest use case may well be scripts or simple applications, but
that by no means indicates that it has to be used as such. At times, it
seems to me that PHP is torn between catering to scripts or catering to
large applications.

Above all, my biggest problem with PHP is how it appears to interact
with OOP. To me--this may and probably does vary between people--PHP has
a weary relationship: it wants to use it but doesn't quite want to go
that extra step. Since I came on to my only PHP project after the brunt
of it had been developed, this may simply be a manifestation of the
other developers.

My $0.02... not that it's worth much these days...
 
N

NC

I'm wondering if I can get a reasonably civil (without
starting any huge wars) opinion on how server-side PHP
compares to server-side Java.

The biggest difference is architecture. PHP does not have an
application server in the Java meaning of the term; the PHP
interpreter is either loaded into the HTTP server as a module at the
startup or runs as a CGI/FastCGI executable.

Both PHP and Java work well with Oracle; when it comes to MySQL,
however, Java (at least in its Tomcat implementation) tends to have
performance issues. One widely publicized example is Friendster; the
performance problems in its Linux/Tomcat/MySQL stack were so pervasive
that the whole application had to be rewritten in PHP. So for
applications where license costs are a factor (or, to put it another
way, for situations when you can't afford Oracle and a commercial
application server), PHP (or Python) is usually preferable.
I've been strictly a Java developer for almost 10 years
now, and I'm pretty happy with it. However, I can't help
but notice that there are a significant amount of PHP-based
development projects where I live

Maybe, but have you looked into going pay rates for those projects?
and I've also noticed when searching around the internet for
ready-made web applications that a lot of them are in PHP.

Well, PHP hosting is by far the easiest to come by...
As an object-oriented programmer I've always assumed PHP was
more of a scripting language for doing things on individual
web pages or writing small applications and that Java/J2EE
was better positioned for writing large applications, but maybe
that's no longer true.

It's never been true in the first place. PHP is easier to learn than
most alternatives, so there are a lot of inexperienced, yet eager, PHP
developers out there, who keep cranking out operational, but poorly
structured, code. It does not mean, however, that it is impossible to
produce a well-designed application in PHP...

Cheers,
NC
 
L

Lew

Joshua said:
Above all, my biggest problem with PHP is how it appears to interact
with OOP. To me--this may and probably does vary between people--PHP has
a weary relationship: it wants to use it but doesn't quite want to go
that extra step. Since I came on to my only PHP project after the brunt
of it had been developed, this may simply be a manifestation of the
other developers.

If we think of programming as flying, then we can think of PHP as a hang
glider and Java EE as a commercial jet airliner.

I wouldn't want to leap off a cliff hanging on to the landing gear of a Boeing
747.

Nor would I want to fly a couple of hundred people across an ocean in a hang
glider.

The languages have fundamentally different philosophies and programming
models. It's like comparing Apples and PCs.
 
L

Lew

NC said:
Both PHP and Java work well with Oracle; when it comes to MySQL,
however, Java (at least in its Tomcat implementation) tends to have
performance issues. One widely publicized example is Friendster; the
performance problems in its Linux/Tomcat/MySQL stack were so pervasive
that the whole application had to be rewritten in PHP.

Could you give some specific citations how Java has "performance issues" with
MySQL, and why it would differ from Java's performance with Postgres or Oracle?

The only thing that could affect performance between Java and a database would
be the JDBC driver. (Application code issues we will take as equivalently
dangerous be it Java or PHP.) MySQL provides their own JDBC driver.
 
J

Jerry Stuckle

Lew said:
Could you give some specific citations how Java has "performance issues"
with MySQL, and why it would differ from Java's performance with
Postgres or Oracle?

The only thing that could affect performance between Java and a database
would be the JDBC driver. (Application code issues we will take as
equivalently dangerous be it Java or PHP.) MySQL provides their own
JDBC driver.

Yes, but MySQL (and many other databases) access through the jdbc
drivers is much slower than in PHP. The JDBC driver is often byte code
and needs to be interpreted. OTOH, the PHP driver is compiled C, and
uses the C calls to the database, which are generally faster.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
(e-mail address removed)
==================
 
S

Sanders Kaufman

If we think of programming as flying, then we can think of PHP as a hang
glider and Java EE as a commercial jet airliner.

Of course - if you think of programming as programming, then there's almost
NO difference.

It's like asking - which is *better* - Enlish or Spanish?
It all depends on with whom you're trying to communicate.

Sure - there's some folks who will write mainfestos in preference of one or
the other, but their advocacy won't help you get the job done.
 
S

Sanders Kaufman

Lew said:
Could you give some specific citations how Java has "performance issues"
with MySQL, and why it would differ from Java's performance with Postgres
or Oracle?

I had an issue with the load-time for the java runtime.
I did a site that only got a few hits per month, but on ONE day, it would
get like a thousand.
When people weren't hitting it all the time, they'd experience as much as 30
seconds delay while the runtime (or whatever) booted up (or whatever).
It was a teeny, tiny, simple servlet - like 10 lines of code.
But if nobody hit it in a while, the first hit would be slllloooowwww.
 
L

Lew

Jerry said:
Yes, but MySQL (and many other databases) access through the jdbc
drivers is much slower than in PHP. The JDBC driver is often byte code
and needs to be interpreted. OTOH, the PHP driver is compiled C, and
uses the C calls to the database, which are generally faster.

First of all, bytecode interpretation is a fraction of the overhead of talking
to a database.

Secondly, all production-grade JVMs optimize the heck out of bytecode to a
degree at least comparable to C code.

Do you have citations for the differences in Java MySQL speed and PHP MySQL speed?

Do you have citations for the reasons for any differences?

I am still interested - do you have citations for performance differences
between the Java / MySQL combination and other Java / RDBMS combinations like
Postgres or Oracle?

I hear the conclusions that have been stated:

- Java / Tomcat to MySQL is slower than other Java / RDBMS combinations.
- Java / Oracle works better than Java / Tomcat / MySQL.
- There were severe performance problems (unspecified) with Linux / Tomcat /
MySQL.
- These problems necessitated a switch to PHP (implying no other solution
would have worked?).
- Java / Tomcat to MySQL is slower than PHP / Apache / MySQL.
- This latter is due to bytecode interpretation being slower than C binary
execution.
- C calls to MySQL are generally faster than JDBC calls to MySQL.

One at least is incorrect. I am interested in the evidence for the others.
 
R

Roedy Green

I'm wondering if I can get a reasonably civil (without starting any
huge wars) opinion on how server-side PHP compares to server-side
Java.

PHP is for small projects, maybe at most a forum.. J2EE is for giant
ones. You need to know a lot less to get your first PHP database
project working.

It is better, which is better a water ski boat or an oil tanker. It
depends what you want to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top