Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > PHP compared to Java/J2EE

Reply
Thread Tools

PHP compared to Java/J2EE

 
 
flarosa
Guest
Posts: n/a
 
      11-14-2007
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

 
Reply With Quote
 
 
 
 
igrosny@gmail.com
Guest
Posts: n/a
 
      11-14-2007
On Nov 14, 2:35 pm, flarosa <(E-Mail Removed)> 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,
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

 
Reply With Quote
 
 
 
 
Wojtek
Guest
Posts: n/a
 
      11-14-2007
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


 
Reply With Quote
 
Jerry Stuckle
Guest
Posts: n/a
 
      11-14-2007
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.
http://www.velocityreviews.com/forums/(E-Mail Removed)
==================

 
Reply With Quote
 
Michael Fesser
Guest
Posts: n/a
 
      11-14-2007
..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
 
Reply With Quote
 
KDawg44
Guest
Posts: n/a
 
      11-14-2007
On Nov 14, 12:56 pm, Jerry Stuckle <(E-Mail Removed)> wrote:
> 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.
> (E-Mail Removed)
> ==================


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.

 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      11-14-2007

"Wojtek" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.


not true at all! php can run all by itself or as a module to most *any* web
server (if that is how you intend it to be executed).

> - becuase of the above it is expensive to use a lot of constants, so you
> end up with a lot of magic numbers


'because of the above' being FALSE, 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.

as for 'magic numbers'? well hell, that's completely unrelated to the point
you were trying to make. second, *people* create magic numbers...not
programming languages. you may need to explain yourself a bit more here.

> - sort of OO. It has classes, but the implementation is not complete.


in what way?

> It was bolted on after the fact, so you can mix OO with procedural.


in *ANY* language, you can mix OO and proc code. as for being bolted on
after the fact, again that's a completely FALSE statement. aspects of OO
have been in php since at least php 3.0 and remained largely unchanged until
php 5. the major provisions of what is prized about OO were *all* there at
that time...that was back in early 1998 fwir!

> - 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.


ok...but again you assume php just does web pages. you do that with perl
too? or ruby? or java?

> 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.


well, that's a stupid argument. that goes to developer architecture,
implementation, and lack of error checking to prevent 'crashing'. it has
little to do with being a php weakness.

> - by design, presentation code is mixed with business logic


ONLY BY THE DESIGNER !!!

> - great for small projects


AND FOR THE MULTI-BILLION DOLLAR projects for the fortune 100 companies for
whom i've developed php applications. lots of data, lots of users, lots of
hits, lots of bad consequences if php (or my implementation of it) fails.

> Java
> - compiled language. The compiler produces byte-code.


not a fully compiled language. just like msil that is executed by the .net
framework, java need jre. not much of a greater advantage there.

> The server reads the byte code and uses the Java Runtime Environment (JRE)
> to run it.


see above.

> - All constants are resolved by the compiler, so using many constants
> makes the code more readable.


NO DIFFERENT THAN PHP.

> - The JRE will inspect the code execution path and will optimize it on the
> fly.


NO DIFFERENT THAN PHP. you need to quantify and qualify 'optimize'.

> So the longer your code runs, the faster it runs.


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.

as far as web development goes, php and java only get ONE pass at doing an
optimization. i think your point here is coming up a little short.

> - Is OO by design


nothing *IS OO*...java was written with OO support in mind from its onset.
though php put it in its tertiary release, it was done in short order. the
only argument to be made here is what of OO is supported by either AND of
the things NOT supported YET by php, which are NEEDED to get the job done.

> - great for large projects.


just like php. moot point.

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


yeah, i think you're charging to much. i'd rate your overview about...one
peso, if that.


 
Reply With Quote
 
Wojtek
Guest
Posts: n/a
 
      11-14-2007
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


 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      11-14-2007

"Wojtek" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.


 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      11-14-2007
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" <(E-Mail Removed)> wrote 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Training Institute In Delhi, Live Projects on PHP. Short TermPHP Courses, PHP Scripts, PHP Training with Live Projects. Rajive Narain Java 0 09-18-2009 10:47 AM
Learn how to edit php pages with free php editor torque63 HTML 0 01-01-2009 03:45 AM
RE: php and python: how to unpickle using PHP? Ted Zeng Python 0 10-13-2006 12:11 AM
php and python: how to unpickle using PHP? Ted Zeng Python 4 10-03-2006 03:07 PM
Slow compared to php Ike Java 7 08-11-2004 07:33 PM



Advertisments