Jump to content


Photo

Java vs PHP for web applications


  • Please log in to reply
32 replies to this topic

#1 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 16 January 2008 - 10:13 PM

This is a discussion about using Java or PHP for web applications. To start, here are some pro's and con's of both

Java
+ Good structure and documentation. Standardized class and method usage.
+ Perfectly OO
+ Strongly typed
+ No include problems, just have the classes in the classpath
+ Easy to use frameworks like Spring
+ Database libraries like Hibernate
- Big overhead for quick or small applications
- Virtually no shared hosters available

PHP
+ Easy for quick/small sites
+ Lots of hosters
+ Easier for beginners (?)
- Part OO, part procedural. OO part is not quite good.
- less libraries available
- hard to structure applications, need to include a lot of files. requires a lot of discipline
- function usage not consequent
- weakly typed, can introduce bugs and security errors
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#2 Phil

Phil

    Force Majeure

  • Network Leaders
  • 7,976 posts
  • Location:Switzerland
  • Projects:Revora, C&C:Online
  •  Thought Police
  • Division:Revora
  • Job:Network Leader
  • Donated
  • Association

Posted 16 January 2008 - 10:45 PM

I can't say I have ever developed a web application in Java, but I guess that PHP makes more sense unless you have a huge application in the background. Basically, if you don't need an entire software layer that works over the internet, PHP is the way to go.

revorapresident.jpg
My Political Compass

Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.


#3 Blodo

Blodo

    The one who disagrees

  • Project Team
  • 3,002 posts
  • Location:Eastern Europe
  • Projects:siteMeister, Mental Omega
  •  The wise guy

Posted 19 January 2008 - 07:17 PM

- Part OO, part procedural. OO part is not quite good.

Is it a bad thing that it also supports procedural? You don't need to get into the whole OOP madness to write a short script when you need it. Other than advanced OOP stuff like observers or the useful stuff like namespaces I don't really see PHP needing much more really.

- less libraries available

They are quality though. I'd complain more about the limited extension possibility for PHP on shared hosts (adding libraries is impossible without owning the server) that basically make coding for any library that is not included with PHP as well as enabled by default pointless.

- hard to structure applications, need to include a lot of files. requires a lot of discipline

How is that? It just needs you to establish your own convention rather than running around with one that the language imposes. One might argue that it's better that way for beginners and advanced coders alike.

- function usage not consequent

What do you mean by this?

- weakly typed, can introduce bugs and security errors

I agree that it could use strict type casting as an option (throw an error when a variable specifically assigned as an int is overwritten by a string) but that's about all. PHP5 classes are more strict when coded properly, and thus easier to debug - but PHP still parses the basic structures that worked in PHP4 for that beginning level.

ARGUMENT FROM CREATION, a.k.a. ARGUMENT FROM PERSONAL INCREDULITY (I)
(1) If evolution is false, then creationism is true, and therefore God exists.
(2) Evolution can't be true, since I lack the mental capacity to understand it; moreover, to accept its truth would cause me to be uncomfortable.
(3) Therefore, God exists.


#4 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 20 January 2008 - 01:40 AM

Is it a bad thing that it also supports procedural? You don't need to get into the whole OOP madness to write a short script when you need it. Other than advanced OOP stuff like observers or the useful stuff like namespaces I don't really see PHP needing much more really.

supporting procedural is not bad, but mixing it with OO is smelly IMO

They are quality though. I'd complain more about the limited extension possibility for PHP on shared hosts (adding libraries is impossible without owning the server) that basically make coding for any library that is not included with PHP as well as enabled by default pointless.

i actually meant libraries coded in php, not the thing you use to extend the php runtime (like gd)

How is that? It just needs you to establish your own convention rather than running around with one that the language imposes. One might argue that it's better that way for beginners and advanced coders alike.

unless you have a good system (which beginners dont have), you can really mess up the includes in php.

What do you mean by this?

that function names are not consequent, and their usage differs a lot. for example, in one function you put the source first, then the destination. in another, it's the other way round.

i also have two new cons to add:
- no exceptions
- every class and function is reloaded for every page that is executed. a java application server loads the apps and keeps it running
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#5 Jeeves

Jeeves

    I write the interwebz

  • Members
  • 4,156 posts
  •  Friendly neighborhood standards Nazi

Posted 20 January 2008 - 02:30 AM

PHP is easy enough for me to learn enough to know I suck at it. Therefore I like :)
I just wrote a site for a client, which contains several little php scripts. Nothing big, but you don't need any major programming to make a dynamic site with some powerful features. I think the best example of this is just the simple <? include(); ?>. With no programming ability I was finding it easy to manage and keep data up to date across a range of pages. And I don't know if you can do similar with java, or wouldn't have to because its all running in the app, but I think every beginner here should go out and learn a few basic php functions, because you don't need to be a programmer or doing anything complex for them to be really, really useful.

World Domination Status: 2.7%


#6 Blodo

Blodo

    The one who disagrees

  • Project Team
  • 3,002 posts
  • Location:Eastern Europe
  • Projects:siteMeister, Mental Omega
  •  The wise guy

Posted 20 January 2008 - 11:42 AM

supporting procedural is not bad, but mixing it with OO is smelly IMO

That's not really a bad thing the way I see it though, just yet another school of coding. It's simply using objects to support procedural code, so there is no need for half a million classes in a built up application. How clean the code will be in the end depends fully on the coder.

i actually meant libraries coded in php, not the thing you use to extend the php runtime (like gd)

Well in that case you should know the site http://phpclasses.org and see that this really isn't a problem. There is enough libraries for anyone there, and quality too.

unless you have a good system (which beginners dont have), you can really mess up the includes in php.

That really depends. In the end beginners just seem to shove everything in one directory regardless and while that might seem like a big mess of files it is less tedious for the beginner to learn that way, and over time he will realise that there are better ways of segregating files.

that function names are not consequent, and their usage differs a lot. for example, in one function you put the source first, then the destination. in another, it's the other way round.

Yeah, this has been haunting PHP since version 3..

no exceptions

Dead wrong. http://uk3.php.net/exceptions

every class and function is reloaded for every page that is executed. a java application server loads the apps and keeps it running

While reloading everything is a native behaviour of PHP, I believe opcode caches and bcompiler more than make up for this, also taking into account the general slowness of Java. The only problem here is that both need serverside configuration, which is not possible on shared hosts. Shared hosts also rarely go out of their way to actually enable different PHP features, simply installing it instead and just using it straight out of the box.

ARGUMENT FROM CREATION, a.k.a. ARGUMENT FROM PERSONAL INCREDULITY (I)
(1) If evolution is false, then creationism is true, and therefore God exists.
(2) Evolution can't be true, since I lack the mental capacity to understand it; moreover, to accept its truth would cause me to be uncomfortable.
(3) Therefore, God exists.


#7 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 20 January 2008 - 12:43 PM

also taking into account the general slowness of Java

now there you are wrong. jave being slow is a prejudice from it's beginnings, but these days it's almost as fast (and sometimes faster, yes it's true) than native apps.

Dead wrong. http://uk3.php.net/exceptions

ok so it does support exceptions now, i didn't know that, and it's good. still, the standard functions that have been around before 5 don't use them (AFAIK).

Anyway, I partly agree with you and Jeeves in that PHP is easier for beginners. Personally I find Java to be better when you're getting into bigger applications (web applications vs dynamic web sites).
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#8 Beowulf

Beowulf

    Shipgirl

  • Advisors
  • 7,219 posts
  •  Azur Lane Fangirl

Posted 30 June 2009 - 10:15 PM

I know I'm bumping a year and a half old topic but I found it somewhat interesting. I'll go so far as to say Java is rather slowish but it's not so slow that there's a noticeable difference. Then again, what do I know? I write web apps in .NET. ;)

And I've also found that PHP, classic ASP as well, are more efficient since they communicate directly with the HTML instead of using an intermediary. Maybe that's just me though...

NZ.org | BBPCG
Discord: The Astronomer#1314
Steam


#9 Jeeves

Jeeves

    I write the interwebz

  • Members
  • 4,156 posts
  •  Friendly neighborhood standards Nazi

Posted 05 July 2009 - 02:12 PM

I'll go so far as to say Java is rather slowish but it's not so slow that there's a noticeable difference

Try telling my unis Blackboard that :D
Not only is it unbearably slow but has caused issues in firefox on vista disabling the WDM. And there is no way viewing a web page should ever f*** up your display and OS's window management. EVER.
And attending a uni that receives a lot of M$ sponsorship, I'll admit .NET does have its uses, but I'd still push PHP for general use.

World Domination Status: 2.7%


#10 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 05 July 2009 - 03:54 PM

That's not a problem with Java. Sounds like a client-side problem.
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#11 Beowulf

Beowulf

    Shipgirl

  • Advisors
  • 7,219 posts
  •  Azur Lane Fangirl

Posted 05 July 2009 - 03:54 PM

You'd think that until you use .NET for applications. Overheads aside, .NET is insane for creating feature-rich applications with a lot less hassle.

NZ.org | BBPCG
Discord: The Astronomer#1314
Steam


#12 Romanul

Romanul

    title available

  • Hosted
  • 2,461 posts
  • Location:Romania,Bucharest

Posted 10 July 2009 - 03:52 PM

Flash for the win.

#13 Beowulf

Beowulf

    Shipgirl

  • Advisors
  • 7,219 posts
  •  Azur Lane Fangirl

Posted 10 July 2009 - 10:36 PM

Flash is garbage for everything but games, video players and humorous animated videos.

NZ.org | BBPCG
Discord: The Astronomer#1314
Steam


#14 Romanul

Romanul

    title available

  • Hosted
  • 2,461 posts
  • Location:Romania,Bucharest

Posted 11 July 2009 - 03:37 PM

How come?

#15 Beowulf

Beowulf

    Shipgirl

  • Advisors
  • 7,219 posts
  •  Azur Lane Fangirl

Posted 11 July 2009 - 06:57 PM

It's a mockery of standards since it has none. Flash only websites are generally slow, way too flashy, hard (or impossible) to navigate and an eyesore half the time. Give me a damn HTML page to display content.

Flash is great for specific things but an entire website is not one of them.

Edited by Beowulf, 12 July 2009 - 08:11 AM.

NZ.org | BBPCG
Discord: The Astronomer#1314
Steam


#16 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 11 July 2009 - 07:19 PM

True, Flash websites are bad. For applications (like webmail) it's ok though.
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#17 Phil

Phil

    Force Majeure

  • Network Leaders
  • 7,976 posts
  • Location:Switzerland
  • Projects:Revora, C&C:Online
  •  Thought Police
  • Division:Revora
  • Job:Network Leader
  • Donated
  • Association

Posted 11 July 2009 - 07:42 PM

Webmail? No thanks. Use JavaScript if it has to be very interactive, but for goodness sake keep proper markup.

Flash is garbage for everything but games, video players and humorous animated videos.

QFT

revorapresident.jpg
My Political Compass

Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.


#18 Bart

Bart

  • Network Admins
  • 8,524 posts
  • Location:The Netherlands
  • Division:Revora
  • Job:Network Leader

Posted 11 July 2009 - 07:49 PM

Webmail? No thanks. Use JavaScript if it has to be very interactive, but for goodness sake keep proper markup.

Why? I understand the importance of proper markup better than most, but why in webmail?
I don't think Thunderbird or Outlook are made of proper markup, yet they do fine :p
bartvh | Join me, make your signature small!
Einstein: "We can’t solve problems by using the same kind of thinking we used when we created them."

#19 Beowulf

Beowulf

    Shipgirl

  • Advisors
  • 7,219 posts
  •  Azur Lane Fangirl

Posted 12 July 2009 - 08:12 AM

I don't think Thunderbird or Outlook are made of proper markup, yet they do fine :p

To be technical, they don't consist of any 'mark up' so to speak. :p

NZ.org | BBPCG
Discord: The Astronomer#1314
Steam


#20 Phil

Phil

    Force Majeure

  • Network Leaders
  • 7,976 posts
  • Location:Switzerland
  • Projects:Revora, C&C:Online
  •  Thought Police
  • Division:Revora
  • Job:Network Leader
  • Donated
  • Association

Posted 12 July 2009 - 11:23 AM

I also don't surf Thunderbird or Outlook with my webbrowser, so yeah.

revorapresident.jpg
My Political Compass

Sieben Elefanten hatte Herr Dschin
Und da war dann noch der achte.
Sieben waren wild und der achte war zahm
Und der achte war's, der sie bewachte.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users