Why Java blows PHP out of the water!



  • Posted in a thread for someone asking what language(s) to learn if he wants to make a website...these are quotes from the same person in the same thread:


    "Java... isn't really as hard as PHP."

    "Since php is [only] designed to make calls to a database, that's what you get free...You pretty much just write your queries out on a mostly static php page..."
    vs.
    "With java, you aren't really calling a static page that gets preprocessed and then sent to you, but rather you're actually calling a program that will create and spit out html code, live."

    "PHP is good when the dimensions of a table change in one dimension (ie, it gets longer). But if the table is expanding in two dimensions, PHP is out of it's league."

    "PHP would probably have to be hard coded with the maximum size of the table. But a java/jsp application can generate the table live, to ANY size, with just a for loop."

    "I have a batchelor's in computer sciences, am a websphere administrator AND developer, and run a multinode application server for one of the largest securities firms in the country.

    Yes. I have experience."

    "Database calls are slow (at least compared to array cell calls). In a java implementation, you can get all your information in one query, and read from the array to output. In php, so far as I'm aware, you'd need to make a new query in each cell.

    Hence why java is better.

    To demonstrate it in very, very poor psudocode:

    For php implementation:

    for 0 to n
    for 0 to m
    write output from database query
    end for
    end for

    For java implementation:

    resultset = execute query
    while resultset.next
    for 0 to resultset size
    write from resultset
    end for
    end while"



  • That is so stupid, I now want to commit a murder-homicide.

    Thats right. a MURDER homicide.



  • yes, I've wanted to kill some php advocates more than once myself.



  • "Database calls are slow (at least compared to array cell calls). In a java implementation, you can get all your information in one query, and read from the array to output. In php, so far as I'm aware, you'd need to make a new query in each cell."

    A PHP resultset can only have one single row? 

    As for the PHP vs Java pseudocode, in PHP you can do this:

    $result = mysql_query($query);
    while($row = mysql_fetch_row($result))
       foreach($row as $field)
         do_whatever($field);

    I bet Java can do the same, I'm not sure about the foreach thingy in Java 1.5 though; so you might be stuck with the silly indices. So I don't see how PHP would suck any more than Java. [flame bait]At least I don't see five try/catch blocks in there.[/flame bait]

    It's nice when people bash PHP, when really the only problems are
    - quirky syntax and function names
    - lots of noob programmers who don't know the first thing about designing a web site



  • Let the boring truth blow you away.  Learn both, use either when mandated by:

    1) Contractual or in-house development conventions.
    2) Whichever makes the most sense for a given project objective.  Aften learning both Java and php, you'll know.

    (Don't ask which is a better to learn.  If you're set on only learning one programming language, you're not going to learn much from the one you choose.)


  • @cwolves said:


    Database calls are slow (at least compared to array cell calls).


    Well, obviously he is referring to the Storray Engine [tm] here.



  • @jwenting said:

    yes, I've wanted to kill some php advocates more than once myself.



  • I hate this forum software...



  • @jwenting said:

    yes, I've wanted to kill some php advocates more than once myself.

    is that:
       I've wanted (to kill some php advocates) more than once myself
    or:
       I've wanted to (kill some php advocates more than once) myself
    ?

    As much as you may want to, you can only kill someone once.





  • @John Smallberries said:

    @jwenting said:
    yes, I've wanted to kill some php advocates more than once myself.

    is that:
       I've wanted (to kill some php advocates) more than once myself
    or:
       I've wanted to (kill some php advocates more than once) myself
    ?

    As much as you may want to, you can only kill someone once.

    I'll settle for either ;)
    And there have been some reports of this guy about 2000 years ago who rose from the dead.[H]

    And that's without taking into account all the zombies out there (who might in part be php advocates...) [;)]



  • @cwolves said:

    "Database calls are slow (at least compared to array cell calls). In a java implementation, you can get all your information in one query, and read from the array to output. In php, so far as I'm aware, you'd need to make a new query in each cell."


    Wow, it's creepy that someone would think that the language used affects the database backend in any way.

    I'm not going to quote the other parts of the post, but I think they other notions presented are hilarious.



  • The only heavy java site that I use frequently visit is where I'm taking some online classes and that sits is SLLLOOOW.  You log in and then it divides the page up into three frames and each one says, "Loading Class Info, Please Wait" and slowly, one by one, they load up.  Other times, like if you click a message in a conference, it shows you the message but the menu bar at the bottom that is supposed to say, "Reply to this Message" still hasn't loaded yet.

    Say what you want about PHP (I'm certainly no fan) but its one big advantage is that you can throw a lot of server hardware at a problem and do all your processing in a milisecond and just shoot some html out to the client and it all looks super fast.  It's sad, but processing a whole page on the server and sendng the HTML for that whole page out to the client is still faster than sending three Java programs (one per frame) and letting them run on the client.

    Eh, like someone above me said, how about if we learn both and then use the tool that best fits the job.



  • @tofu said:

    The only heavy java site that I use frequently visit is where I'm taking some online classes and that sits is SLLLOOOW.  You log in and then it divides the page up into three frames and each one says, "Loading Class Info, Please Wait" and slowly, one by one, they load up.  Other times, like if you click a message in a conference, it shows you the message but the menu bar at the bottom that is supposed to say, "Reply to this Message" still hasn't loaded yet.

    Say what you want about PHP (I'm certainly no fan) but its one big advantage is that you can throw a lot of server hardware at a problem and do all your processing in a milisecond and just shoot some html out to the client and it all looks super fast.  It's sad, but processing a whole page on the server and sendng the HTML for that whole page out to the client is still faster than sending three Java programs (one per frame) and letting them run on the client.

    Eh, like someone above me said, how about if we learn both and then use the tool that best fits the job.


    Looks like you compare apples to oranges. The app you describe seems to use Java applets.
    But you should rather look at server-side java, like servlets, JSP, Struts, JSF etc.. Serverside Java can be very performant if done right.



  • @tofu said:

    The only heavy java site that I use frequently visit is where I'm taking some online classes and that sits is SLLLOOOW.Nobod
    ...

    It's sad, but processing a whole page on the server and sendng the HTML for that whole page out to the client is still faster than sending three Java programs (one per frame) and letting them run on the client.


    Nobody was talking about client-side Java as far as I know. Server-side Java and PHP do the same thing: generate HTML[0] and send it to the client. Performance is often limited by the database backend, so it doesn't really matter if Java is a few times faster than PHP for most applications.

    I can think of a long list of objections to both Java and PHP, but some of the things people worry about are just silly.

    [0]They can both generate other kinds of output, like images.


Log in to reply