java vs php
Moderator: General Moderators
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
java vs php
ok im learning more about classes and objects by learning java but do the same rules apply like private and static and everything? i have not really used php as very OO but have just used classes to group functions and then make things a little more organized for myself but if this java stuff applies then things might make a lot more sence to me.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Alot more so in PHP5 yes.
Java is pure OO so it's not the same but a lot of the concepts still apply.
In PHP5 you can use overloaded methods, declare interfaces, assign properties/methods as private, public or protected, create abstract classes etc.
Don't forget PHP isn't natively an object oriented language so it's far from perfect.
Java is pure OO so it's not the same but a lot of the concepts still apply.
In PHP5 you can use overloaded methods, declare interfaces, assign properties/methods as private, public or protected, create abstract classes etc.
Don't forget PHP isn't natively an object oriented language so it's far from perfect.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Ohhh noo... you're wrong my friend. PHP is capable of creating Command line applications too. It can even use ncurses and stuff. It does more than you may think. I regularly write command line apps for linux using PHP.Jenk wrote:They have different abilities
Java creates standalone apps, as well as applets/weblets/serverlets. Where as we should all know, PHP is limited to Webservers, or more specifically, HTTP Requests
I believe it won't be long before we can start compiling it into machine code too
Java tends to be more memory intensive and have a steeper learning curve as well. The initial is all fine and dandy but it ramps up sharply as you get into building actual "useful" applications. I've found PHP to be FAR simpler to integrate as well, Java having more compatability issues than you can shake a tree full of monkeys at.
Definitely, which is one of the reasons I've migrated from Java to PHP. PHP gets the job done fast. It may not always be totally OO, but if you separate display from business logic, you're fine.Moocat wrote:Java tends to be more memory intensive and have a steeper learning curve as well. The initial is all fine and dandy but it ramps up sharply as you get into building actual "useful" applications. I've found PHP to be FAR simpler to integrate as well, Java having more compatability issues than you can shake a tree full of monkeys at.
Moreover, it's possible to create standalon GUI apps (using php-gtk)d11wtq wrote: Ohhh noo... you're wrong my friend. PHP is capable of creating Command line applications too. It can even use ncurses and stuff. It does more than you may think. I regularly write command line apps for linux using PHP.
It's possible to compile php into byte-code and encapsulate it into executable file (using bcompiler). It isn't "machine code" exactly, but it's as close as compiled java applications are.I believe it won't be long before we can start compiling it into machine code too
You might want to precise which php version against wich java version you want to compare.shiznatix wrote: ok im learning more about classes and objects by learning java but do the same rules apply like private and static and everything?
Basically, the basic OOP concepts in PHP5 and Java5 are very alike.
If you're learning about classes and objects (=instances of classes), i would advise not to focus on language specific/syntax details. Instead focus on inheritance and composition. Just as you've learned to recognize repeating stuff and to put it in a functions you should now learn to recognize stuff that shares the same behaviour. Once you can do this, you can take it a step further and try to recognize patterns. Patterns are even more abstract, they are about the behaviour between objects.