PHP vs java: need help deciding which to use

TheDude05

Limp Gawd
Joined
Jan 27, 2005
Messages
393
Pretty soon I'm going to start writing a web app for a friend of ours business. Its for basic customer management, invoices, etc. Basically a simple CRM designed specifically for their operation. I need help deciding what to write it in.

I've never done any web applications in Java, let alone know much about J2EE apps in general but i've kind of been wanting to learn. However, I'm fairly fluent in PHP and written a couple websites in it already. If I wrote my app in PHP I would use Symfony or CakePHP for the framwork. If I went the Java route I guess i'd use Struts (unless you recommend something else) I'm wanting to use JasperReports in my app as well. I'd also like to implement a little AJAX stuff. So heres my thoughts on both

Java:

pros:
- Learn about enterprise java
- native support for jasper reports

cons:
- must learn everything new including all the http classes and server stuff (ie, tomcat, jboss, etc)



PHP:

pros
- Already know and love php, can write something fairly quick
- Already know how to set up webserver for php support
- only have to learn whatever framework im working in

cons:
- My knowledge is still only in php, learning java as well could help me when I get out of school
- Must figure out a way to use jasper reports



So does anyone have any suggestions? Time isn't much of an issue as I just mentioned I could write something like that, not that I would. Basically I never commited to it so I can take as long as I want. The only reason I was thinking the Java route is because I'd kind of like to learn about it, but it seems like a lot of things to learn (jsp, j2ee, etc). I'm torn. :(
 
If you are doing a project for someone you need to go with something you know. Not knowing java it will be quite unwieldy for you compared to PHP. If you can do the project you want to do in PHP then don't think twice about it. To learn java you should try writing programs for yourself. Java was the first language I have learned and I have chosen to use PHP for the small sized web applications I have been working on recently.
 
Ruby on Rails is your salvation. ;) Spend time solving the problem and not writing glue.
 
PHP is server side, Java is client side...unless your website is dead as a doorknob, aren't you going to need both??
 
Stuh505 said:
PHP is server side, Java is client side...unless your website is dead as a doorknob, aren't you going to need both??
JavaScript is client side. Java applets are client side. regular java can be used for server side stuff with java server pages and whatnot
 
tim_m said:
JavaScript is client side. Java applets are client side. regular java can be used for server side stuff with java server pages and whatnot

They are called servlets, the server's resources are used to run your client's program .... better not have a memory leak the garbage collector does not find. Remember how easy it was to segfault a C prog?

Anywho ..... go with PHP. Why?:
java requires the runtime environment
java always takes a minute to load assuming youd be using applets
you don't know the vulnerabilities of java code on initial coding stages (learn it on the side and maybe slowly build stuff with it if needed)
you have that jasper conflict
PHP can do the job and you know how to use it.

I LOVE java, but in this case I'd use PHP. I like java simply for its architectural build, cross-platform capability(which PHP also has seeing its SSI), class structure w/ inheritance, ease of use, etc ..... I just wouldn't vote on it for this project. Refer to my last statement in the previous paragraph.

Hope it helps bias your opinion :)
 
MadJuggla9 said:
Anywho ..... go with PHP. Why?:
java requires the runtime environment
java always takes a minute to load assuming youd be using applets
you don't know the vulnerabilities of java code on initial coding stages (learn it on the side and maybe slowly build stuff with it if needed)
you have that jasper conflict
PHP can do the job and you know how to use it.

True Java requires a runtime enviroment, but since he's using Struts it's no more of a problem then using PHP. They'll both require some setting up of the server, and PHP may be easier to setup then struts, but neither are too difficult to setup. Since everything will be on the server it shouldn't make a difference once the server is started, no applets involved.
 
penguin said:
For the user's sake, use PHP. It's way less headache inducing.
Hate to disagree here, but Java or PHP makes absolutely no difference to the user. However, it'll make one hell of a difference to the programmer.

Excuse the broad generalisations, but if you decide to go down the Struts route, you'll end up jumping through XML hoops galore to get the most simple functionality out of the door. If you use PHP, you're likely to do a lot of home-grown code do do basic stuff (eg database persistence).

I'd second the recommendation for Ruby on Rails - if you're open to the idea of learning something new, go for it. RoR is built on the same MVC (Model-View-Controller) concepts as Struts, but it has a built-in persistence engine which will save you hours of coding and frustration, along with a whole load of helpers and plugins which will reduce the amount of time you spend writing noddy code to an absolute minimum. Sure, there are problems with it, but odds are that J2EE (or any other Java-based framework) are waaaaaay overkill for your needs. Please bear in mind that there's a sea-change going on in the Java world right now, away from the insane (and unnecessary) complexity which is J2EE. Plump for RoR (you can learn it and build an application with it in the same time you'd take to just learn a small part of J2EE). You'll thank DHH in the end :)
 
If you're writing SQL you're wasting time.
If you're writing XML you're wasting time.
If you're writing glue code you're wasting time.

Applications take code to complete and wasting time doing the above will make your application's development slower.

With Ruby on Rails (ActiveRecord)'s magic I have written a total of one SQL statement.

Given the following code (Which solves a problem and isn't glue!):

Code:
src = 'Isikesu'
op = +
sopts = { 'minsec' => 0.5 }
agents = []
stations = Pathfind.systems_n_jumps_away(System.find(:first, :conditions => [ 'name = ?', src ] ),5,sopts).each do |psys|
  psys.stations.each do |station|
    station.agents.find(:all, :include => [:agentdivision, { :corporation => :faction } ], :conditions =>[ 

"factions.name = ? AND agents.level > ? AND agentdivisions.name IN (?)", 'Caldari State', 2, 

['Storage','Marketing'] ]).each do |agent| agents << agent end
  end
end

I write no lines of SQL. It's all in easy-to-understand Ruby. The station.agents.find line does three LEFT OUTER JOINs and comparisons. All I wrote was Ruby, no SQL.

Granted, the SQL statement is fugly:

Code:
SELECT agents."id" AS t0_r0, agents."name" AS t0_r1, agents."agentdivision_id" AS t0_r2, agents."quality" AS t0_r3, agents."level" AS t0_r4, agents."corporation_id" AS t0_r5, agents."station_id" AS t0_r6, agents."agenttype_id" AS t0_r7, agentdivisions."id" AS t1_r0, agentdivisions."name" AS t1_r1, corporations."id" AS t2_r0, corporations."name" AS t2_r1, corporations."faction_id" AS t2_r2, corporations."is_playercorp" AS t2_r3, corporations."created_on" AS t2_r4, corporations."updated_on" AS t2_r5, factions."id" AS t3_r0, factions."description" AS t3_r1, factions."name" AS t3_r2 FROM agents LEFT OUTER JOIN agentdivisions ON agentdivisions.id = agents.agentdivision_id LEFT OUTER JOIN corporations ON corporations.id = agents.corporation_id LEFT OUTER JOIN factions ON factions.id = corporations.faction_id WHERE (agents.station_id = 60004309 AND (factions.name = 'Caldari State' AND agents.level > 2 AND agentdivisions.name IN ('Storage','Marketing')))

But no one cares since I didn't have to write it, and should the schema change you don't need to dick around with changing SQL since ActiveRecord will make the query itself.

Save yourself the time and learn RoR.
 
Thanks for all your suggestions. As for your comments on RoR, I would be doing the same with RoR as ill be doing with php. If I go the php route (Which I think I am) I'm going to use Symfony which has database persistance and all the MVC stuff there that RoR has.

Its not that I have anything against Ruby, I just dont want to learn another scripting language when my current scripting language can do everything that the rails framework gives me.


Now heres the new question, since I'm not using Java, whats the best way to incorporate JasperReports reporting into my app? Can I do this with SOAP possibly?
 
TheDude05 said:
Its not that I have anything against Ruby, I just dont want to learn another scripting language when my current scripting language can do everything that the rails framework gives me.
If that's the case, then why bother with Java? It's only semi-compiled, and the performance gains aren't *that* great for most web apps.You'd only end up using Struts and a persistence framework, which by your logic gives you nothing that you don't already have in PHP. In fact, why bother with any different architecture at all?

Because as good as any framework may be, they were not all created equal. The mere fact that you're considering something outside PHP suggests that it's not giving you everything you need. Until you've tried RoR with a real project, don't be so quick to presume that it won't give you anything over your PHP framework.
 
I was only thinking the java route because of jasper reports which ruby wont give me either. Plus i've wrriten stuff in Java before, just not j2ee.
 
J2EE is an outdated, bloated framework, really - it's not worth your time unless you're building a massive system (and even then, not really worth it).
 
:LJ: said:
J2EE is an outdated, bloated framework, really - it's not worth your time unless you're building a massive system (and even then, not really worth it).

Lots of jobs out there working on outdated, bloated systems.
 
If you're writing SQL you're wasting time.
If you're writing XML you're wasting time.

Huh? So I guess anyone who writes PHP instead of using DW is just wasting their time? Understanding what you're doing isn't a waste of time. Creating custom SQL queries to speed up an ineffecient page is not wasting time.


To the OP, if you know PHP and the client will accept a PHP solution then go for it. The server admin will thank you. Not only that, but it will be easier to move the project to other hosting if required and so on.
 
deuce868 said:
To the OP, if you know PHP and the client will accept a PHP solution then go for it. The server admin will thank you. Not only that, but it will be easier to move the project to other hosting if required and so on.

I am the server admin :D
 
deuce868 said:
Huh? So I guess anyone who writes PHP instead of using DW is just wasting their time? Understanding what you're doing isn't a waste of time. Creating custom SQL queries to speed up an ineffecient page is not wasting time.

You misunderstood. In general, yes SQL is a huge waste of time. Especially when we work in the OO world. Who wants to have to do boring crap like transform my object to the peristence world? I just want it persisted! (<3 for ORMs) Only when is it absolutely necessary should you have to dive into making custom queries to make things more performant.
 
We'll just have to disagree on that. It sounds too much like a sys admin saying they know how to setup admin mail server because they can click the required gui buttons for it. When something goes wrong they have no idea how email works and can't fix it.
 
deuce868 said:
We'll just have to disagree on that. It sounds too much like a sys admin saying they know how to setup admin mail server because they can click the required gui buttons for it. When something goes wrong they have no idea how email works and can't fix it.

With Rails (in development mode) I see every query being done. ActiveRecord is fairly mature and used in projects of major importance (Typo blog, Basecamp, etc).

In fact I've written SQL queries faster than it would take to write it in Ruby (It was actually the example earlier in this thread, but without all the foo as t1_r2 crap). That doesn't take away from the powerful nature of an ORM system. The speed at which I can describe a table's relationship (one to one, one to many, and many to many) and have access to the relationships (e.g., blog.comments) is too powerful and useful to pass up.

Anyhow, ORM is a well established data model and there's nothing wrong with taking advantage of it. ;)
 
Ruby on Rails is awsome, if you're going to learn something new from scratch, go with that one. Pick up "Agile web Development with Rails" and don't look back. You'll be very surprised how quickly you can go from knowing nothing about Ruby to having a fully blown system in place that's easy to maintain and develop.
 
Back
Top