java vs php

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

java vs php

Post by shiznatix »

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.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

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.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

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 :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

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 :)
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.

I believe it won't be long before we can start compiling it into machine code too ;)
User avatar
Moocat
Forum Contributor
Posts: 143
Joined: Wed Oct 12, 2005 9:28 am
Location: USA

Post by Moocat »

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.
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

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.
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.
User avatar
Moocat
Forum Contributor
Posts: 143
Joined: Wed Oct 12, 2005 9:28 am
Location: USA

Post by Moocat »

Java isn't totally useless though, it has it's part in large applications, but unless it's something that's REALLY big, like an airport control center, that's going to take a few years to develop, I find PHP to be far easier, faster and more efficient, even in the long run (if coded properly).
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

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.
Moreover, it's possible to create standalon GUI apps (using php-gtk)
I believe it won't be long before we can start compiling it into machine code too ;)
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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

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?
You might want to precise which php version against wich java version you want to compare.
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.
Post Reply