There is a long list of advantages of some languages from other language but I just list down some of the prominent I found out so far.
This is not a comparison of languages over another language. This is just a little angle to looking one language over the other.
- When declaring Class members, you could use a function to define the member property
- example: public String myText = SomeOtherClass.getMyText();
- which is not allowed in PHP
- PHP has no method overloading (methods with the same name but with different signatures in which the right method to be invoked is determined by the matching supplied parameters and return values)
- example in Java
- public void getData(int Param)
- public void getData(String Param)
- public void getData(int Param1, String Param)
- This could be in a similar way done in PHP by appending the data type into the function
- function getData_int(Param)
- function getData_string(Param)
- function getData_int_string(Param1,Param2=null)
- or something like:
- }
- Namespace in PHP is very odd to see
- in php: \\com\\somecompany\\webui::MainModule
- in java is desirable: com.somecompany.webui.
- when using php in procedural language codes you write is short and readable, but in OOP php(5.0+), theres a need to explicitly use $this-> to every method/property call of members in the class, which hinders readability of code, where as in java, you are not required to write "this" as long as there is no conflict to a method local variable.
function getData(param){
type = getType(param); if(type==int){ ... }else if(type == String){
...
}
No comments:
Post a Comment