Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Java or PHP/SQL

Options
2»

Comments

  • Registered Users Posts: 2,021 ✭✭✭ChRoMe


    The main difference I see between PHP and Java is it's type system, particularly that Java is static. There are of course others, but this would be the biggest hurdle I'd imagine.

    When you think about it, static/strong typing isn't really a better representation of the metal than dynamic/weak typing.

    It is because its forcing you to think about the type of data you are storing in memory. Its a far way from C, but its definitely closer.


  • Registered Users Posts: 1,311 ✭✭✭Procasinator


    ChRoMe wrote: »
    It is because its forcing you to think about the type of data you are storing in memory. Its a far way from C, but its definitely closer.

    But closer to the metal, that is not generally the case.

    For instance assembly, which is usually the closest most people will get to the metal. It is generally untyped. You can do whatever you want in code, and you'll find out later in run-time if you've done it wrong. It's true you are forced to think about the type of data you are storing in memory, but not by the compiler, but by non-functioning code, undefined behaviour or maybe even segfaults.

    Type-safe languages attempt to prevent this kind of errors from happening, but that is not to say they are closer to the metal.


  • Registered Users Posts: 2,021 ✭✭✭ChRoMe


    But closer to the metal, that is not generally the case.

    For instance assembly, which is usually the closest most people will get to the metal. It is generally untyped. You can do whatever you want in code, and you'll find out later in run-time if you've done it wrong. It's true you are forced to think about the type of data you are storing in memory, but not by the compiler, but by non-functioning code, undefined behaviour or maybe even segfaults.

    Type-safe languages attempt to prevent this kind of errors from happening, but that is not to say they are closer to the metal.

    True its a general characteristic rather than a rule. Generally I think it is the case, but of course there are specific instances where it doesn't hold true. Personally I prefer a compiler choking on something rather than having to hunt down weird run time behaviour


  • Registered Users Posts: 1,311 ✭✭✭Procasinator


    I suppose thinking about types is a more low-level task, and some languages (such as PHP) allow you to think less about them. In Java you can't re-use variables on unrelated types nor avail of as much implicit type conversions as PHP. But I don't think that is much of a roadblock to moving from say PHP to Java as being made out to be.

    I'd argue a PHP and Java programmer would struggle moving to C anyhow, and the Java programmers advantage wouldn't be that significant (assuming an equal level of experience).


  • Registered Users Posts: 2,021 ✭✭✭ChRoMe


    I suppose thinking about types is a more low-level task, and some languages (such as PHP) allow you to think less about them. In Java you can't re-use variables on unrelated types nor avail of as much implicit type conversions as PHP. But I don't think that is much of a roadblock to moving from say PHP to Java as being made out to be.

    I'd argue a PHP and Java programmer would struggle moving to C anyhow, and the Java programmers advantage wouldn't be that significant (assuming an equal level of experience).

    Its one of the biggest differences,but how many problems it causes for someone starting out is dependent on the student.


  • Advertisement
  • Registered Users Posts: 19,019 ✭✭✭✭murphaph


    I'm currently doing the HTML/CSS/JS for a Java project and my team lead offered to show me some Java which I'm gonna take him up on. I looked at Java a while back so know the basics but not in a web app sense (that stuff strikes me as very different to PHP, using Tomcat etc. I mean) and the way the framework (stripes) is coded is really different to the way PHP can be directly embedded in HTML and the PHP engine on the web server will interpret it and spit out the proper HTML-all that seems really quite different in Java.

    Anyway, while he was showing me he mentioned that Java 6 does indeed allow a sort of "weak typing". He said it's now possible to declare an "integer" object and not initialise it and then to assign that object to an integer primitive, that is potentially assign null to a primitive, which could lead to a null pointer exception. Sure enough the IDE he uses highlights the "danger" (if you hover over the assignment!) but the language does allow it and I guess some IDEs wouldn't even highlight that and it would only be discovered at runtime.

    He said he's not sure if it's a good thing or a bad thing that it's now possible to do this.


  • Registered Users Posts: 2,021 ✭✭✭ChRoMe


    murphaph wrote: »
    I'm currently doing the HTML/CSS/JS for a Java project and my team lead offered to show me some Java which I'm gonna take him up on. I looked at Java a while back so know the basics but not in a web app sense (that stuff strikes me as very different to PHP, using Tomcat etc. I mean) and the way the framework (stripes) is coded is really different to the way PHP can be directly embedded in HTML and the PHP engine on the web server will interpret it and spit out the proper HTML-all that seems really quite different in Java.

    Anyway, while he was showing me he mentioned that Java 6 does indeed allow a sort of "weak typing". He said it's now possible to declare an "integer" object and not initialise it and then to assign that object to an integer primitive, that is potentially assign null to a primitive, which could lead to a null pointer exception. Sure enough the IDE he uses highlights the "danger" (if you hover over the assignment!) but the language does allow it and I guess some IDEs wouldn't even highlight that and it would only be discovered at runtime.

    He said he's not sure if it's a good thing or a bad thing that it's now possible to do this.

    That is a feature that has been around since Java 5. Its called autoboxing, personally I wouldn't consider it weak typing. Its a good thing, cleans a lot of crap out of code.


  • Registered Users Posts: 116 ✭✭aficionado


    Advice has been great here, Some of it over my head so think I'll go for the more accessible option!
    Signed up for the php course so hope it goes well and I dont get bad habits!
    Thanks for your help


Advertisement