Results 1 to 12 of 12
  1. #1
    capser is offline Member
    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0

    Default Help to chose java or PHP

    Hello Guy's

    I know you have seen this question or somewhat of it many of times.
    But I really need your help to decided.

    I'm new to programming and stick in the middle of java and php.

    Everything I have found relating to such questions which is best to learn, the same answer arises.

    "Depends what you want to do... each has it's strength and weakness and it all comes down to what you want to do with the language, as one will be better then the other"

    or something on those lines.

    My questions is without starting a vs war, is what do they do better then each other. or even what do they do the other doesn't.

    I want to create websites, and possible app's to support those sites. I know java would be suited for the later, but some say java is only used for large web applications. so why can't it be suited for small projects?

    Anyway I hope you guy's understand what I'm trying to ask.

    Regards

  2. #2
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    PHP is used to dynamically generate content, generally in HTML, for a webpage output. For dynamic, on-the-fly-type web applications, PHP won't cut it. JavaScript (not Java) would be used for some small-scale apps, like a mini calculator or something. But Java should be used for any dynamic app that would be embedded in the website.

    The two languages have severely different usages, so that question that keeps arising is a darn good one; it depends almost entirely on what you're doing in order to figure out what you want. If I were you (which I'm not, and I'm not sure the scope of your project), I'd use PHP (with HTML and CSS) for generating the website, and Java for running any web applications within. Though alternately, you could use AJAX (PHP handled by async JavaScript) to run a web application on a large scale.

  3. #3
    capser is offline Member
    Join Date
    Jun 2011
    Posts
    2
    Rep Power
    0

    Default

    Quote Originally Posted by Zack View Post
    PHP is used to dynamically generate content, generally in HTML, for a webpage output. For dynamic, on-the-fly-type web applications, PHP won't cut it. JavaScript (not Java) would be used for some small-scale apps, like a mini calculator or something. But Java should be used for any dynamic app that would be embedded in the website.

    The two languages have severely different usages, so that question that keeps arising is a darn good one; it depends almost entirely on what you're doing in order to figure out what you want. If I were you (which I'm not, and I'm not sure the scope of your project), I'd use PHP (with HTML and CSS) for generating the website, and Java for running any web applications within. Though alternately, you could use AJAX (PHP handled by async JavaScript) to run a web application on a large scale.
    Thank you for your reply, but it still leaves me in the dark. Without knowing what I can do, or the strength of a language I still can't decided to which I should learn.

    Can you mix the two together as you stated
    "I'd use PHP (with HTML and CSS) for generating the website, and Java for running any web applications within"

  4. #4
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    Give us a detailed idea of what you want to do. What type of website are you trying to make? I would suggest PHP first because almost all websites use PHP now, and then Java afterwards. That's just a basic view point, you'll be able to get a lot more basic functionality out of PHP in the short run.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  5. #5
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    My biggest reason for saying you should learn java first is because php can teach you some bad habits. For example, in php you can do this
    Java Code:
    $x = "hello";
    $y = 10;
    $z = $x + $y;
    The language is very weakly typed. If you learn php first you will be able to create a site quicker(probably), but you will (probably) have a harder time learning strongly typed languages like java later on.

  6. #6
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    @Sunde, Sure there are some weaknesses like that, but it really depends on the individual. Honestly the best path is decided by what he's trying to accomplish in the website. If he's not planning on making anything super advanced that would require more than PHP then there really isn't a reason for him to start with Java. However if he plans to move into a really large development scheme with a lot of advanced functions then it might be in his best interest to skip over PHP and move straight into Java.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  7. #7
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Yes, exactly the point I meant to make. If he only ever plans on learning one language and doing just specific things such as web development, he may want to go with php. I just wanted to include some thing about php that could throw him off a little if he ever transitions to java or other strongly typed languages.

    @op: I suggest you take a look at both, perhaps get an introductory text for each language and casually read through them to see which fits your needs better, and which will help you attain your goal more quickly.

  8. #8
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    If you want more advice from us, I suggest giving us a broad overview of what you're trying to accomplish.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  9. #9
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    Quote Originally Posted by sunde887 View Post
    My biggest reason for saying you should learn java first is because php can teach you some bad habits. For example, in php you can do this
    Java Code:
    $x = "hello";
    $y = 10;
    $z = $x + $y;
    The language is very weakly typed. If you learn php first you will be able to create a site quicker(probably), but you will (probably) have a harder time learning strongly typed languages like java later on.
    While I agree that PHP is "weakly"-typed (though I'd use the term flexibly, instead), this is not actually possible. Strings are concatenated using . while numbers are done with a + sign. And in fact, you can do this in Java also:
    Java Code:
    String x = "hello";
    int y = 10;
    String z = x + y; // Yes, this is defined as a string, but it still combines two variable types, something not possible in a strictly-typed language like C++.
    Quote Originally Posted by capser View Post
    Thank you for your reply, but it still leaves me in the dark. Without knowing what I can do, or the strength of a language I still can't decided to which I should learn.

    Can you mix the two together as you stated
    "I'd use PHP (with HTML and CSS) for generating the website, and Java for running any web applications within"
    Yes. PHP is used for something entirely different than Java; Java does not generate contents of webpages, it runs inside its own application (from a JAR file on a computer) or applet (embedded in a website), independent of the content around it. PHP is used to generate the backend, the content that is visible to you.

    Much more information on notable differences is available around the web.
    Last edited by Zack; 06-27-2011 at 12:51 AM.

  10. #10
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    @zack, I'm aware php string concatenation is done with a period, I meant + as in addition. Adding a string and a number will return a number. Add
    Java Code:
    echo $z;

  11. #11
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    Quote Originally Posted by sunde887 View Post
    @zack, I'm aware php string concatenation is done with a period, I meant + as in addition. Adding a string and a number will return a number. Add
    Java Code:
    echo $z;
    Oh, okay. I missed your point.

  12. #12
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    Normally when designing a website you have a team. If you are the only one doing this then you might want to start with HTML/CSS/PHP so you can actually develop a website, and then learn Java so you can make applets for your website. You can essentially put all of the web development codes together on the same webpage.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

Similar Threads

  1. Replies: 3
    Last Post: 01-10-2011, 02:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •