• Advertisement
Sign in to follow this  

[web] Which one is more efficient? JSP or PHP

This topic is 4234 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I will start coding a web based game in a few days. I am not sure with which one should I code it? But I am more tended to JSP. I want your comments on this please.

Share this post


Link to post
Share on other sites
Advertisement
The one that will be the most efficient is the one your the most familar with. Your productivity will be much higher in the long run going with the one you know best. However, you may miss an exciting oppurtunity to learning something new and challenging!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster

http://shootout.alioth.debian.org/debian/benchmark.php?test=all&lang=java&lang2=php

In these tests PHP seems to be more efficient with memory, but Java is mostly faster.

I've never used JSP so I dont know how sutable it is. PHP is very easy to learn/use, but I would just use whatever you are more familliar with.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Sorry, the forum messed up the link...

http://shootout.alioth.debian.org/debian/benchmark.php?test=all&lang=java&lang2=php

Share this post


Link to post
Share on other sites
Don't worry about which one is more efficient. Worry about which language you are more proficient in.

Also, the first thing to affect efficiency is going to be how you design your database and how you access it. Yes, the language/framework powering your application will affect speed, but usually far less than the code you write yourself.

Share this post


Link to post
Share on other sites
The more efficient one is, as others have noted, the one which you are more proficient in, because you will be able to build the application more quickly (which is more important than runtime performance).

I'm sure Java will outperform PHP in every task at runtime, but you really don't care!

Mark

PS: Please don't use JSP, it really sucks. It is an abuse of the Java VM :)

Share this post


Link to post
Share on other sites
I am good on both languages. But the main performance problem is with the database queries. In java I made a design plan about database queries. I will form a class file for each database table in which there will be methods get_field and set_field for each field and a method update_record to set all fields to new positions. By this way I am thinking of minimizing the database query number to minimum. Is this a good idea?

Share this post


Link to post
Share on other sites
For best performance you will want a layer that gives you direct SQL access to the database, and performance will then be dependent on your database, database structure, and SQL quality, rather than the web language. Both languages should be able to offer this.

Share this post


Link to post
Share on other sites
Quote:
Original post by mfk_1868
By this way I am thinking of minimizing the database query number to minimum. Is this a good idea?

Yep, that's pretty much rule #1 in database queries. Don't use two queries if you can manage with one. Crossing the boundary from your external application to the database is expensive, so use as few queries as possible.

Share this post


Link to post
Share on other sites
Quote:
Original post by Spoonbender
Quote:
Original post by mfk_1868
By this way I am thinking of minimizing the database query number to minimum. Is this a good idea?

Yep, that's pretty much rule #1 in database queries. Don't use two queries if you can manage with one. Crossing the boundary from your external application to the database is expensive, so use as few queries as possible.


Not necessarily. In some cases, especially when using GROUP BY, 2 queries will be stupidly faster than one (think 10 minutes vs less than 1 second) I learned this the hard way :/ The number of queries doesn't matter as much as the quality of them.

Share this post


Link to post
Share on other sites
Out of curiousity.... can you give an example of where 2 queries out preforms the GROUP BY clause?

Share this post


Link to post
Share on other sites
performance of your server side scripting language is almost entirely irrelivant. who cares if you take 200ms or 250ms to run your code when each database query can take full seconds to complete. the only thing that you really care about optimizing is the number of database queries you make per page load.

-me

Share this post


Link to post
Share on other sites
Quote:
Original post by Cygnus_X
Out of curiousity.... can you give an example of where 2 queries out preforms the GROUP BY clause?
In the forum I was developing, I was pulling thread information, number of unique views, and number of unique replies all in the same query. This involved about 12 tables, most of which were only required for the thread information (which of course would be the same for each corresponding view and reply). Splitting the query into 3 (one to pull thread info, one for the number of views, and one for the number of replys) sped things up a great deal (as I said, from around 10 minutes to under one second). In most cases I have encountered, the overhead of sending multiple queries is way less than that of a more complex query involving GROUP BY.

The point is that, when striving for efficiency, there isn't one black-and-white rule. It's like indexes - just because they can make some queries faster doesn't mean you should create one for every single field.

Share this post


Link to post
Share on other sites
Quote:
Original post by mfk_1868
do you know a way that we can measure the time of a query?


Get the microtime before the query. Get it afterwards. Calculate the difference. If you use a database abstraction layer of some sorts then it's quite easy to build a profiler into it.

Share this post


Link to post
Share on other sites
that can be shorter in group by statements which are very complex but I dont think it can be in basic sql statements.

The worst performance statements are join statements in sql. But in general minimizing query number brings performance.

PS: I dont mean joining all tables and getting all data in one query. I mean if you get some data from a table do it in one step instead of a lot.

Share this post


Link to post
Share on other sites
I fully believe that there is no reason to ever use PHP. It's a toy language that grew far past its original scope and is now a horrid, horrid piece of tripe.

JSP and the whole Java EE thing are not my favorite either, but at least it's a semi-properly structured language.

Give me ASP.NET with C#.

Share this post


Link to post
Share on other sites
Quote:
Original post by capn_midnight
Give me ASP.NET with C#.


No thanks. I prefer not to use MS servers. Perhaps you should give Python a try. I've never used it for webdev before but it's supposed to be quite good.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sander
Quote:
Original post by capn_midnight
Give me ASP.NET with C#.


No thanks. I prefer not to use MS servers. Perhaps you should give Python a try. I've never used it for webdev before but it's supposed to be quite good.


actually, I've been playing around with Ruby lately (hehe, ever since watching
">this). It's a strange little language, if not a wee bit flaky here and there. I'm primarily interested in the Camping web app framework, I'm interested to see just how featureful it is, considering how "small" (sans dependencies) it is.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sander
Quote:
Original post by capn_midnight
Give me ASP.NET with C#.


No thanks. I prefer not to use MS servers. Perhaps you should give Python a try. I've never used it for webdev before but it's supposed to be quite good.


To be fair, I don't think he was implying you had to use it.

Cheers
Chris

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement