"don't compare PHP to JSP" why???

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

"don't compare PHP to JSP" why???

Post by pedrotuga »

My knowledge in everything that is java-related is zero.
I talked to a friend of mine that just graduated in computer science. He said that java was the base stone of all the course program.
that quote came a bit after.

Ok, so what's there on JSP that makes PHP not comparable to it?
He told me about servlets, isnt it possible to reach the same performance level in anyway using php?
This might be a big stupidity of mine but where is the big difference betwin both?

Like... are the only advanteges of using php the fact of running everywhere or being easy to learn and well documented?

I know these are php boards, but i heard so many ppl saying quotes like the one above without properly explain them... so i want to listen to the other side.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Servlets are fairly heavily compiled by the Java system, so unless you use a really good bytecode compiler for your PHP, you can't really come close there. However, finding a host that offers Java isnt' as easy or cheap as finding a host supporting PHP.

Java has access to a few things that PHP doesn't handle so well. It's mostly in external interactions and functionality, but PHP has some things Java doesn't have either.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

JSP runs extremely slowly on my system.

Java is a much more strictly typed OO language and packages up really nicely. The namespace also remains nice an clean due to the way it deals with packages (of which there are many many packages to use). PEAR is probably the closest thing PHP has to Java's standard packages.

Java compiles .java files into bytecode class files. This means you can distribute closed source packages as .jar files with Java or you can choose to distribute the .java source files. PHP is simply interpreted at runtime which does have a certain amount of overhead... that said, Java still requires the use of a JVM (Virtual Machine) so you get overhead there too.

The HUGE thing with Java is that (like PHP) it's a cross platform language but (unlike PHP) it's all ready set up to build standalone client side applications with a GUI & skin which looks and feels like the operating system it's running on by using libs such as AWT, Swing and JAXX. It's not *just* a language for the web. People have written 3rd party libs/tools for doing similar things with PHP but they are much less mature. There is more of a steep learning curve to get into Java however and getting a JSP application or servlet up and running on a web server takes a lot more configuration than a PHP application which usually is just a case of extracting the tarball and running it.

PHP probably has about the same amount of community suppport as Java.

From my standpoint I can see myself using a healthy mix of both in the future. I personally am quite enjoying learning Java right now.

If you develop with PHP5 and OOP then Java/PHP really aren't overly dis-similar apart from a few syntactical differences.
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post by pedrotuga »

d11wtq.... i am just curious about web based development here.

Now, all this skepticism of mine is basicaly because you find thousands of php aplications out there, millions of pages run php. For example... pretty much all the web comunities run some message board system writen in php. Wikipedia uses mediawiki, the software development pages use trac, there is already dozens of ajax classes and frameworks, pear has two or three diferent modules for each goal,etc etc... i wonder... why da heck doesnt JSP take its place? Maybe is just me that haven't discover a whole new world of java.

Anyway... that might be because of PHP being able to run everywhere.

Fyed, can you give me a few examples of those things that php doesnt handle so well? and a few of the opsite as well....
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

pedrotuga wrote:d11wtq.... i am just curious about web based development here.
Java is nowhere near as "friendly" for web development IMO. Even making and testing a small change to the code requires a little work at the server to get it going. I'm not being biased here; I like Java :)
pedrotuga wrote:Now, all this skepticism of mine is basicaly because you find thousands of php aplications out there, millions of pages run php. For example... pretty much all the web comunities run some message board system writen in php. Wikipedia uses mediawiki, the software development pages use trac, there is already dozens of ajax classes and frameworks, pear has two or three diferent modules for each goal,etc etc... i wonder... why da heck doesnt JSP take its place? Maybe is just me that haven't discover a whole new world of java.
I'm not sure where you've determined the language thos apps were written in from? Trac uses Python, MediaWiki is written in PHP though yes. You'll find a good proportion of web based applications written in many languages; the popular ones being PHP, Java, Python and Perl.
pedrotuga wrote:Anyway... that might be because of PHP being able to run everywhere.
So can Java, and Java doesn't just run on web servers... it's actually designed to do full skinned GUI apps too.
pedrotuga wrote:Fyed, can you give me a few examples of those things that php doesnt handle so well? and a few of the opsite as well....
PHP has no real native means Closed source distribution. There are tools out there to compile to Bytecode but you need to pay for software to run it.

PHP cannot do much without a web browser or a terminal. Java has libraries like Swing/AWT.

Java supports multi-threading.... this is a total no-go in PHP.

Most people have Java (JRE) installed on their computers so you can write Applets which work directly with servlets and you can even distribute software for end-users which can be carried around on a CD or USB stick.

PHP makes writing applications rapidly a lot quicker, it doesn't need to be compiled, and it's much less strictly typed. I have to say; I'm sat here trying to think of things PHP has capability to do which you can't do in Java and I'm struggling which is a little depressing.
_ca_
Forum Newbie
Posts: 12
Joined: Wed Oct 25, 2006 4:38 pm

Post by _ca_ »

pedrotuga wrote:i wonder... why da heck doesnt JSP take its place?
There are such places. Just look at Alfresco. Java can be used on an Application Server which is running continously. For some (e.g heavy load operations) things, this is better.

PHP is - imho - very pragmatic. Get fast an easy solution for your problem. With PHP 5 you can even build scaleable and maintainable applications ;)

Some really cool PHP Projects:
Bambalam PHP 2 EXE Compiler/Embedder
Winbinder (using the Win API for GUI Programms and DLLs)

I think both - PHP and Java - can be usefull. It depends on what your main problem is. It's just like mySQL vs postgreSQL. :)

Chris
User avatar
pedrotuga
Forum Contributor
Posts: 249
Joined: Tue Dec 13, 2005 11:08 pm

Post by pedrotuga »

I dunno either why did i had in mind that trac was written in PHP.
Anyway... i think PHP stills the most popular language among web developers.

_ca_, thanks... windbinder got developed really fast since the last time i heard about it.
Post Reply