423,319 Members | 2,562 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,319 IT Pros & Developers. It's quick & easy.

PHP compared to Java/J2EE

P: n/a
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'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.

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.

Let me know what you think. Thanks.

Frank

Nov 14 '07 #1
Share this Question
Share on Google+
66 Replies


P: n/a
On Nov 14, 2:35 pm, flarosa <fr...@franklarosa.comwrote:
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'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.

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.

Let me know what you think. Thanks.

Frank
Frank,
I asked myself the same question some time ago. most of the answer i
found it at:

http://www.tbray.org/ongoing/When/20...ing-Frameworks
hope it helps

Nov 14 '07 #2

P: n/a
flarosa wrote :
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'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.

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.
I have done work in both

PHP
- scripting language. The source code gets read and interpreted every
time a page hit occurs, unless you are using a precompiler, but then
the host server must have a special Apache extension to run it.
- becuase of the above it is expensive to use a lot of constants, so
you end up with a lot of magic numbers
- sort of OO. It has classes, but the implementation is not complete.
It was bolted on after the fact, so you can mix OO with procedural.
- one of the big features is the ability to "include" (or "requires") a
file. That way you build up a web page from many smaller files.
However, any variable which an included file might use from the parent
file, must be created by the parent file. So you may include a file
which requires a variable, only to have it crash becasue that variable
is not present. Makes debugging difficult.
- by design, presentation code is mixed with business logic
- great for small projects

Java
- compiled language. The compiler produces byte-code. The server reads
the byte code and uses the Java Runtime Environment (JRE) to run it.
- All constants are resolved by the compiler, so using many constants
makes the code more readable.
- The JRE will inspect the code execution path and will optimize it on
the fly. So the longer your code runs, the faster it runs.
- Is OO by design
- great for large projects.

So for small simple projects I use PHP. For anything serious I use
Java.

$0.02

--
Wojtek :-)
Nov 14 '07 #3

P: n/a
flarosa wrote:
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'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.

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.

Let me know what you think. Thanks.

Frank

Frank,

PHP is more popular because it's supported by all the web servers. When
PHP first came out, for instance, Apache and IIS didn't support Java
well on the server side (don't know what it's like now). Plus is is
fast and has a smaller memory footprint than Java, which made it better
for shared hosting companies. The result is that a lot of hosting
companies offered PHP really cheap - but Java support was comparatively
lacking and more expensive.

PHP is getting more object oriented. It still has a ways to go - Java
is much better in that respect. But PHP is getting there, a little at a
time.

Now when you're talking larger applications, I agree Java is a better
language, especially when you're talking GUIs. There is a GUI available
for PHP, but it is sadly lacking in functionality compared to Java. And
Java's event model makes some things much easier than in PHP (which
doesn't have an equivalent).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Nov 14 '07 #4

P: n/a
..oO(Wojtek)
>PHP
- scripting language. The source code gets read and interpreted every
time a page hit occurs, unless you are using a precompiler, but then
the host server must have a special Apache extension to run it.
There are also several PECL extension for PHP to cache the compiled
bytecode (PHP code is compiled first and then interpreted by the ZE).
One of these caches (APC) will most likely be part of PHP 6.
>- becuase of the above it is expensive to use a lot of constants, so
you end up with a lot of magic numbers
Huh? I use hundreds of global and class constants. This is definitely
not a performance hit, there are "better" ways to waste CPU time.
>- by design, presentation code is mixed with business logic
Such mixing is possible in other languages as well. And it's always the
developer who decides if he wants to make use of it or not. Of course
you can also properly separate business from presentation logic.
>- great for small projects
Also great for bigger projects. Of course like in all languages you have
to know what you're doing and know the tools you're using.

Micha
Nov 14 '07 #5

P: n/a
On Nov 14, 12:56 pm, Jerry Stuckle <jstuck...@attglobal.netwrote:
flarosa wrote:
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'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.
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.
Let me know what you think. Thanks.
Frank

Frank,

PHP is more popular because it's supported by all the web servers. When
PHP first came out, for instance, Apache and IIS didn't support Java
well on the server side (don't know what it's like now). Plus is is
fast and has a smaller memory footprint than Java, which made it better
for shared hosting companies. The result is that a lot of hosting
companies offered PHP really cheap - but Java support was comparatively
lacking and more expensive.

PHP is getting more object oriented. It still has a ways to go - Java
is much better in that respect. But PHP is getting there, a little at a
time.

Now when you're talking larger applications, I agree Java is a better
language, especially when you're talking GUIs. There is a GUI available
for PHP, but it is sadly lacking in functionality compared to Java. And
Java's event model makes some things much easier than in PHP (which
doesn't have an equivalent).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attglobal.net
==================
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?

I am starting work on a project and I was going to do it with PHP,
MySQL, and some AJAX stuff. I considered doing it in Java but my
timetable is pretty short and front end GUI stuff in Java is a
nightmare to me (not good at it, not bashing Java). So with my short
time frame, I figured that a web based application would be the best
way where I can quickly build the interface. My application is not
huge, probably 50-75 hours for me to do.

THanks.

Nov 14 '07 #6

P: n/a
Steve wrote :
your point of expense is moot. not to mention silly, even if what you'd
claimed were true. last time i checked, apache was still free.
Expensive in terms of processor time, not currency.

--
Wojtek :-)
Nov 14 '07 #7

P: n/a

"Wojtek" <no*****@a.comwrote in message
news:mn***********************@a.com...
Steve wrote :
>your point of expense is moot. not to mention silly, even if what you'd
claimed were true. last time i checked, apache was still free.

Expensive in terms of processor time, not currency.
yeah, i got that after i reviewed the post. :)

even still, when talking web dev, php has a supremely smaller footprint than
java coule ever hope to attain. what php does provide, it makes sure it
doesn't sacrifice speed. and, as i think i saw someone else post, you can
get php to a semi-compiled state just as java does.
Nov 14 '07 #8

P: n/a
Lew
Steve wrote:
not a fully compiled language. just like msil that is executed by the .net
framework, java [sic] need jre [sic]. not much of a greater advantage there.
Actually, Java JVMs are quite effective at runtime code optimizations.

"Wojtek" <no*****@a.comwrote in message
>The server reads the byte code and uses the Java Runtime Environment (JRE)
to run it.
...
>- The JRE will inspect the code execution path and will optimize it on the
fly.
Steve wrote:
NO DIFFERENT THAN [sic] PHP. you need to quantify and qualify 'optimize'.
Actually, it's quite different, for most JVMs. JVMs perform inlining, loop
unrolling, enregistering, escape analysis, common-code refactoring,
just-in-time adaptive compilation and various forms of run-time analysis that
static-compilation tools are hard-pressed to achieve. While it's certainly
possible to do these things with PHP, most interpreters don't.

The various optimizations in the JVM achieve at least a ten-fold increase over
strictly interpreted bytecode, according to articles I've read. I saw that
simply switching a major enterprise server at a job site from "-client" to
"-server" doubled its throughput.

If I may be so bold, resorting to /ad hominem/ remarks in your exposition
redounded to its detriment.

--
Lew
Nov 14 '07 #9

P: n/a
Steve wrote :
php and java only get ONE pass at doing an optimization.
Nope. Modern Java implementations use adaptive optimization during
runtime. With traditional compiled languages, the compiler does it
once.

http://en.wikipedia.org/wiki/Java_pe...e_optimization

--
Wojtek :-)
Nov 14 '07 #10

P: n/a
Lew
KDawg44 wrote:
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, JSPs and servlets. java.sun.com has tutorials on the topic, and you
should search their site for information on "Model 2" architecture, a
Model-View-Controller pattern for web apps.
I am starting work on a project and I was going to do it with PHP,
MySQL, and some AJAX stuff. I considered doing it in Java but my
timetable is pretty short and front end GUI stuff in Java is a
nightmare to me (not good at it, not bashing Java). So with my short
time frame, I figured that a web based application would be the best
way where I can quickly build the interface. My application is not
huge, probably 50-75 hours for me to do.
GUI in JSP is just GUI in HTML. If you can make PHP, you can make JSP.

If you use Java Server Faces (JSF), things get more sophisticated, but the
approach is still markup oriented.

--
Lew
Nov 14 '07 #11

P: n/a
Lew
"Wojtek" <no*****@a.comwrote in message
>So the longer your code runs, the faster it runs.
Steve wrote:
that is UTTERLY FALSE! there is a thing called an optimal limit. java will
hit a primary, ultimate, optimzed execution plan at some point. however, it
evaluates what 'optimal' is EVERY SINGLE TIME that code portion is going to
be executed.
You are mistaken. JVMs do not use a static optimization plan. It changes how
it runs different code paths depending on the runtime profile. It will
decompile code back to bytecode, for example, if it falls into relative
disuse, and JIT another part that is currently undergoing heavy use.

It can also dynamically examine things like method arguments to determine if
it's safe to lift instance variables into registers or not.

Go back and review how JVMs actually work. Sun has a number of white papers
on java.sun.com that explain the sorts of things they can do. IBM
DeveloperWorks has a series of articles by Brian Goetz that explained these
matters back in about 2003 / 2004.

--
Lew
Nov 14 '07 #12

P: n/a

"Wojtek" <no*****@a.comwrote in message
news:mn***********************@a.com...
Steve wrote :
>php and java only get ONE pass at doing an optimization.

Nope. Modern Java implementations use adaptive optimization during
runtime. With traditional compiled languages, the compiler does it once.

http://en.wikipedia.org/wiki/Java_pe...e_optimization
what i'm saying is that this is not a continual process, like a gui, or
running process on a system. in the context of the web, java doesn't get to
capitalize on more than a few adaptations given the
run-produce-output-and-done nature of a web hit. make sense?
Nov 14 '07 #13

P: n/a
Wojtek wrote:
Steve wrote :
>your point of expense is moot. not to mention silly, even if what
you'd claimed were true. last time i checked, apache was still free.

Expensive in terms of processor time, not currency.
No more so than Java, and in many cases, less.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Nov 14 '07 #14

P: n/a
Steve wrote :
what i'm saying is that this is not a continual process
Yes it is.

--
Wojtek :-)
Nov 14 '07 #15

P: n/a
Michael Fesser wrote :
I use hundreds of global and class constants.
Hundreds is not a lot.

--
Wojtek :-)
Nov 14 '07 #16

P: n/a
flarosa <fr***@franklarosa.comwrites:
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've yet to see a cross-posted language comparison that remained civil.
This may be the exception, but I doubt it will be.
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.

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.

Let me know what you think. Thanks.
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--

--
WV News, Blogging, and Discussion: http://wv-www.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
Nov 14 '07 #17

P: n/a
..oO(Sherman Pendley)
>flarosa <fr***@franklarosa.comwrites:
>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'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
Nov 14 '07 #18

P: n/a
flarosa wrote:
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
Nov 14 '07 #19

P: n/a
..oO(Wojtek)
>Michael Fesser wrote :
>I use hundreds of global and class constants.

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
Nov 14 '07 #20

P: n/a
Sherman Pendley wrote:
flarosa <fr***@franklarosa.comwrites:
>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've yet to see a cross-posted language comparison that remained civil.
This may be the exception, but I doubt it will be.
>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.

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.

Let me know what you think. Thanks.

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.
js*******@attglobal.net
==================

Nov 15 '07 #21

P: n/a
Lew
Jerry Stuckle wrote:
Back in the 60's and early 70's, structured programming was a novelty! :-)
It still is.

--
Lew
Nov 15 '07 #22

P: n/a
Lew wrote:
Jerry Stuckle wrote:
>Back in the 60's and early 70's, structured programming was a novelty!
:-)

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.
js*******@attglobal.net
==================

Nov 15 '07 #23

P: n/a

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:5r******************************@comcast.com. ..
Lew wrote:
>Jerry Stuckle wrote:
>>Back in the 60's and early 70's, structured programming was a novelty!
:-)

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.
i think lew was making a joke there.
Nov 15 '07 #24

P: n/a
Steve wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:5r******************************@comcast.com. ..
>Lew wrote:
>>Jerry Stuckle wrote:
Back in the 60's and early 70's, structured programming was a novelty!
:-)
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.

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.
js*******@attglobal.net
==================

Nov 15 '07 #25

P: n/a

"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Wb******************************@comcast.com. ..
Steve wrote:
>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:5r******************************@comcast.com ...
>>Lew wrote:
Jerry Stuckle wrote:
Back in the 60's and early 70's, structured programming was a novelty!
:-)
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.

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 :-).
s'all good, momma. hope you had a good time. it's good to get away from the
screen now and again, eh.

cheers
Nov 15 '07 #26

P: n/a
KDawg44 wrote:
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/
Nov 15 '07 #27

P: n/a
flarosa wrote:
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...
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth
Nov 15 '07 #28

P: n/a
NC
On Nov 14, 9:35 am, flarosa <fr...@franklarosa.comwrote:
>
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
Nov 15 '07 #29

P: n/a
Lew
Steve wrote:
"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:Wb******************************@comcast.com. ..
>Steve wrote:
>>"Jerry Stuckle" <js*******@attglobal.netwrote in message
news:5r******************************@comcast.co m...
Lew wrote:
Jerry Stuckle wrote:
>Back in the 60's and early 70's, structured programming was a novelty!
>:-)
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.
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 :-).

s'all good, momma. hope you had a good time. it's good to get away from the
screen now and again, eh.
It was more of a wry commentary than a joke.

--
Lew
Nov 16 '07 #30

P: n/a
Lew
Joshua Cranmer wrote:
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.

--
Lew
Nov 16 '07 #31

P: n/a
Lew
NC wrote:
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.

--
Lew
Nov 16 '07 #32

P: n/a
Lew wrote:
NC wrote:
>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.
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.
js*******@attglobal.net
==================

Nov 16 '07 #33

P: n/a
"Lew" <le*@lewscanon.comwrote in message
news:E4******************************@comcast.com. ..
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.
Nov 16 '07 #34

P: n/a
"Lew" <le*@lewscanon.comwrote in message
news:g4******************************@comcast.com. ..
NC wrote:
>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?
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.
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.

--
Lew

Nov 16 '07 #35

P: n/a
Lew
Jerry Stuckle wrote:
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.

--
Lew
Nov 16 '07 #36

P: n/a
On Wed, 14 Nov 2007 09:35:35 -0800, flarosa <fr***@franklarosa.com>
wrote, quoted or indirectly quoted someone who said :
>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.

--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Nov 16 '07 #37

P: n/a
"Roedy Green" <se*********@mindprod.com.invalidwrote in message
news:g5********************************@4ax.com...
PHP is for small projects, maybe at most a forum.. J2EE is for giant
ones.
And yet - PHP is *constantly* used for large, successful projects - while
Java sites are pretty much limited to pretty pinball games and such.

Nov 16 '07 #38

P: n/a
On Fri, 16 Nov 2007 08:22:25 -0000, Sanders Kaufman <bu***@kaufman.net>
wrote:
"Roedy Green" <se*********@mindprod.com.invalidwrote in message
news:g5********************************@4ax.com...
>PHP is for small projects, maybe at most a forum.. J2EE is for giant
ones.

And yet - PHP is *constantly* used for large, successful projects - while
Java sites are pretty much limited to pretty pinball games and such.
How about Ebay? I think that qualifies as a large, successful project:

http://www.addsimplicity.com/downloa...2006-11-29.pdf

Also, parts of Amazon's platform are Java too (along with C++ and Perl).

Your pinball game is surely a client-side application, is it not? Applets
may be one or the more visible aspects of Java but they are largely
irrelevant. The vast majority of commercial Java development is
server-side (i.e. web applications).

Dan.

--
Daniel Dyer
http://www.uncommons.org
Nov 16 '07 #39

P: n/a
Roedy Green wrote:
On Wed, 14 Nov 2007 09:35:35 -0800, flarosa <fr***@franklarosa.com>
wrote, quoted or indirectly quoted someone who said :
>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.
I don't think that's fair. PHP can be and is used for a lot of large
projects. And Java can be and is used for a lot of small projects.

But what you're saying is that Java isn't good for a forum or smaller
project. And that is definitely not true.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Nov 16 '07 #40

P: n/a
Roedy Green wrote:
On Wed, 14 Nov 2007 09:35:35 -0800, flarosa <fr***@franklarosa.com>
wrote, quoted or indirectly quoted someone who said :
>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.
PHP for fora at most?
You must be joking/trolling.

I have written big stable mission critical applications running in
serious companies, with only PHP/Postgresql. They still run and perform
greatly up to today.
I am sure a lot of the folks in here did the same.

If you think PHP can only handle a forum, that says a lot about your
understanding of PHP, not PHP itself....
It is a totally untrue observation.

I have done a lot of work in both languages, and I deliver about 2-5
times faster in PHP than in J2EE.
But maybe that says something about MY understanding of J2EE.
;-)

Bottomline is that PHP is a lot easier to learn than Java, so a lot of
bad programmers program in PHP, since they don't get Java.
That is not PHP's fault, but leads to an army of avarage/bad programs in
PHP, and also give PHP a silly name to a certain extend.

It is totally 100% possible to program right in PHP AND make complex big
industry strength applications.

Why on earth do you claim a forum is the best PHP can do?

Regards,
Erwin Moller
Nov 16 '07 #41

P: n/a
NC
On Nov 15, 6:18 pm, Lew <l...@lewscanon.comwrote:
NC wrote:
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,
Not exactly a very technical explanation, but here's an insider's
take:

...on Friday we launched a platform rearchitecture based on
loose-coupling, web standards, and a move from JSP (via
Tomcat) to PHP. The website doesn't look much different, but
hopefully we can now stop being a byword for unacceptably
poky site performance.

http://troutgirl.wordpress.com/2004/...ster-goes-php/

who, by the way, was fired for writing it:

http://www.news.com/Friendster-fires...3-5331835.html
and why it would differ from Java's performance with
Postgres or Oracle?
I would make the same guess you did: there's something wrong with
MySQL JDBC driver...

Cheers,
NC
Nov 16 '07 #42

P: n/a
Erwin Moller wrote:
I have written big stable mission critical applications running in
serious companies, with only PHP/Postgresql. They still run and perform
greatly up to today.
Just curious: You mean Apache/PHP/Postgresql, right? Because I've
never heard of anyone writing just PHP by itself.

How large were these mission critical apps? For example, how many lines
of code, and how many files? I'm just trying to get some objective
metrics here.
Nov 16 '07 #43

P: n/a
On Fri, 16 Nov 2007 20:57:11 +0100, Mark Space <ma*******@sbc.global.net>
wrote:
Erwin Moller wrote:
>I have written big stable mission critical applications running in
serious companies, with only PHP/Postgresql. They still run and perform
greatly up to today.

Just curious: You mean Apache/PHP/Postgresql, right? Because I've
never heard of anyone writing just PHP by itself.
Well, it could be done. Not really a standard though, and hardly advisable.
--
Rik Wasmus
Nov 16 '07 #44

P: n/a
NC
On Nov 15, 10:05 pm, Lew <l...@lewscanon.comwrote:
>
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?).
Performance problems with Linux / Tomcat / MySQL are very specific;
whatever the reasons, the response time of a Tomcat / MySQL setup
increases with the number of simultaneous connections much faster than
that of a PHP / MySQL setup.

Could there be solutions other than switching to PHP? Of course!
Here are a few possibilities:

1. Switching from JSP to Python.
2. Switching from MySQL to Oracle.
3. Switching from Tomcat to a commercial application
server.
4. Switching from Tomcat to JBOSS.
5. Investigating the root cause of the problem and fixing
it (which could possibly mean developing a new JDBC
driver for MySQL).

Options 2 and 3 entail significant license costs. Options 3 and 4 may
not solve the problem (if the problem is indeed in the JDBC driver,
changing the application server may not help). Option 5 has an
indefinite timeframe and highly uncertain cost, plus it requires
technical knowledge that the organization experiencing the problem may
not possess. What's left? Abandoning JSP altogether for something
that is known to work better with your chosen OS and DBMS...

Cheers,
NC
Nov 16 '07 #45

P: n/a
Jerry Stuckle wrote:
>
Just experience. No hard facts.
No facts at all with all that experience? I'm a little doubtful, to
tell the truth.

How many systems/server? How were they configured? All did the web
server and db run on the same system? If not what type of channel did
they communicate over? Other systems involved?

How many queries, how big were the tables, how many rows were returned?
How many joins were involved?
An experienced engineer should be able to list some facts....
Nov 16 '07 #46

P: n/a
Mark Space wrote:
Jerry Stuckle wrote:
>>
Just experience. No hard facts.

No facts at all with all that experience? I'm a little doubtful, to
tell the truth.
No hard measurements I can lay my hands on. But about 18 years of C++
experience and 10 years Java.
How many systems/server? How were they configured? All did the web
server and db run on the same system? If not what type of channel did
they communicate over? Other systems involved?
Typically all on one system, although some were on remote systems. Comm
links were the same in both cases, so that's immaterial.
How many queries, how big were the tables, how many rows were returned?
How many joins were involved?
Biggest would have been around 200 tables, regularly joining around
15-20 tables. A hundreds of gigabytes of data. Largest table probably
had 10M rows. But again, not germane to the conversation because the
database and request were identical in both cases. This was using DB2.
>
An experienced engineer should be able to list some facts....
Sure, if I went back through stuff. But I've been a consultant for 17
years now. I've worked on numerous projects during that time. And I
don't keep detailed notes when I'm done with a project. Those go to the
customer.

But I do remember one project where some big manager said it had to be
Java. They spent about a year on the project - around 25 programmers in
all. The resulting applications were so slow as to be basically
unusable. Users complained from day 1. Nothing the did could get
acceptable performance.

They ended up rewriting it in Visual C++. Now I am not a fan of MFC,
but the result was a significant decrease in response time for the user.
Enough that it was now acceptable. Note that nothing else changed -
databases, etc. were still the same.

The manager didn't actually get fired, I don't think but he wasn't with
the company for much longer.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Nov 16 '07 #47

P: n/a
"Daniel Dyer" <"You don't need it"wrote in message
news:op***************@cgl0656.chaucer.co.uk...
On Fri, 16 Nov 2007 08:22:25 -0000, Sanders Kaufman <bu***@kaufman.net>
Your pinball game is surely a client-side application, is it not? Applets
may be one or the more visible aspects of Java but they are largely
irrelevant. The vast majority of commercial Java development is
server-side (i.e. web applications).
Actually, no.
I was thinking of a game I used to play on (i think) iWon.com - back when
Java first came out, pre-php.
It had both a client and server component in Java.
I thought it was pretty cool because it was the first game I found where web
users could compete with each other.
Not exactly a massive-multiplayer thing, but it was a start.
Nov 16 '07 #48

P: n/a
Jerry Stuckle wrote:
database and request were identical in both cases. This was using DB2.
And yet, I was asking about your problems with JDBC with Linux and
MySQL......
Nov 16 '07 #49

P: n/a
NC wrote:
...on Friday we launched a platform rearchitecture based on
loose-coupling, web standards, and a move from JSP (via
Tomcat) to PHP. The website doesn't look much different, but
hopefully we can now stop being a byword for unacceptably
poky site performance.

http://troutgirl.wordpress.com/2004/...ster-goes-php/
" This is a funny result. I am my self a PHP enthusiast, but in the
journal “ACM SIGMETRICS Performance Evaluation Review, Volume 31 Issue
3″ there was an article called “A performance comparison of dynamic Web
technologies” where Perl, Java server technolgy (also tomcat) and Perl
was benchmarked in a labratory environment. It was concluded that
Serverside Java outpreformed PHP and Perl by a factor 8. "

Nov 16 '07 #50

66 Replies

This discussion thread is closed

Replies have been disabled for this discussion.