PHP vs. JSP

Its silly to say that any language is more “enterprise ready” when you are comparing java, php and even asp.

What is “enterprise ready”? I could do roughly similar things in java, php and asp. You can say that jsp is more scalable, or that php has a lower learning curve, sure. But, from what I have seen, “enterprise ready” is really code for “whatever my company bought”. That is all it comes down to. There is no built-in PHP limitation that says “oh! You have too many lines of code on this server! I’m going to stop working because I’m not made for this!” and there is no JSP limitation that says “Screw you, I don’t want to only work with one programmer! Give me a team!”

If you consider the pure merits of a language, you will realize that there is fundamentally no difference. Just because there are PHP programmers who aren’t very good and then run off and write really bad code that isn’t extensible doesn’t neccessarily mean that PHP is a bad language. And the same could be said of JSP!

(This is mostly directed at MJohansson)

However, it’s not possible to say that one is “better”. It basically depends a lot on the size and complexity of your application.

JSP and Java are meant for larger applications. While Java is an agile language, it’s not as agile as PHP for small applications. With PHP, wou can code small things very fast without an IDE (Integrated Develpment Environment - a software used to develop software). Coding Java without an IDE is, in comparison, a pain.

PHP is unbeatable for small scale applications, because it’s so incredibly cheap, in both time and money, to get started with. Add to that that the learning curve is very small, and you instantly have the #1 language for one-man websites.

However, once you start going more advanced and bigger, PHPs agility instead becomes it’s own worst enemy, and you have to do a lot of extra coding to get the infrastructure needed that JSP and .NET already has in place from the beginning. PHP is also very problematic in the sense that it completely lacks a standard approach to development, which causes loss of time when you are dealing with many developers.

I could write an utterly horrible platform in JSP, and .NET. To say that PHP is problematic because it lacks a “standard” approach to development is a bit strange. I could pretty much write a massive JSP page that completely ignored OO. By the same token, I can write PHP code very quickly and get a solution out, yes. But by the same token, I can also get simple java serverlets out at a similarly rapid rate.

Code is code. An if statement in Java is practically the same amount of typing as PHP or .Net. The same if statement does the exact same thing, and has the exact same issues of scale (“Oh no! I used more than 100 lines of code! I must use .NET or JSP now!”). Scalable is nothing more than a buzzword for most situations.

PS: Sorry about that. I will go off on long rants everytime I see people say “my language is better!” Languages are roughly all the same, I have never said to myself “this application is too small/big for the language I’m using. I should rewrite it”. At the level we are looking at (web development), the only difference is what you are most familiar with, or what you have access to, not any intrinsic difference in a language. That is the main issue, not whether Language A can handle sites of 200 pages or more, or whether Language B only works if the site has less than 30 pages.

I have to say I agree with Mattias on this one.

About what? It almost seems to me as if he flopped sides. First saying PHP wasn’t well suited for large applications, then that it could do it… (there is a distinction, but I still believe it is false. Good planning, proper design, and competent programmers decide the ability for a project to scale, not the language the application is based on.)

What’s wrong with that statement? It isn’t as well suited as languages like Java or C# but it can be done, just a whole lot more work. I’m a big believer in PHP but I also know it’s limitations, and currently it’s biggest limitation is it’s lack of a decent framework. With a proper framework, a decent developer would be in a position to set out to do in Microsoft, but until then, every programmer is forced to either start from scratch or use an “all-over-the-place” framework such as PEAR which doesn’t even come as part of the language, but a plug-in which needs to be put on the server seperately.

I agree with several points that Mattias makes as well , I do not agree however with the general spin of the post.

Most of all , while Mattias impicity touches on the language vs framework issue it is not stated which only bothers me as it is the most important point to consider in such a comparison.

Then peeps read the post , see the logical points noted and parrot the ‘for large apps you should use JAVA’ argument as gospel.

I dont see that as helping objectivity , I could not care a kippers what language/framework people use to code in , whatever works for them , but when someone is starting out and looking for advice one would hope that the more respected members of the community try not to spin too much cos it makes people dizzy and they can lose their way.

…that and you probably worked out by now that I have a hard time keeping my thought to myself :wink:

But that’s what you’re here for :wink: To fight tooth and nail for PHP :wink:

Microsoft is already outdone several times over by several technologies when it comes to web-related development ( in usage terms ).

With the current trend to the blurring lines between browser & client based apps .NET seems well poised to take advantage , especially considering MS desktop dominance , I dont see how JAVA can compete with this in the future.

Fameworks are great for those who like working within a framework and the comfort & many advantages that that brings, it also introduces inflexibility.

However , we must assume that a dominant PHP framework will arise at some point . Now if PHP already compete’s at the top-end , one can only assume that the future will be even rosier.

The major difference then is that you will still have the rapid development capabilities of PHP , still have the flexibility to code as you wish yet still have PHP’s raw power and of course the open-source model which has helped push PHP to its current position.

DJ, if someone had told you 2 years ago that PHP would have the following and market share that it currently has today … you would have said … ? (no rude words please ;))

If PHP were standing still (as is JAVA) then fair enough , we however know it is not far from it, nor is .NET of course , .NET’s main (and crucial) advantage from a broader perspective is that it has the desktop and potentially therefore an even wider framework than is currently possible with other technologies.

:wink:@DJ … perhaps I should get a life innit :smiley:

Um, Java (and more specifically JSP) is most definitely NOT standing still. One need only look at Java Server Faces, Struts, etc. to see that there’s a lot of activity still going on behind the curtains :).

What is PHP? I haven’t been in this game very long :wink:

I agree with that, for larger applications, frameworks are fantastic and while I agree that it can introduce inflexibility, people are more than free to extend said framework


class SuperString extends System::String // for example

but PHP’s rapid development capabilities is what makes it so popular and easy to learn. Imagine writing this script in C#


<?php
$db = mysql_connect('localhost', 'root');
mysql_select_db('test');

$sql = "select * from table where id = 4";
die( print_r(mysql_fetch_array(mysql_query($sql)), 1) );
?>

This is pretty neat, but with PHP5/GTK2, how does PHP lack in this area? For people saying “I need a framework”, what is PHP-GTK? I’ve never actually used it but you can certainly speak for the fact that with the more stable GTK2 on it’s way, PHP could outshine .NET with it’s cross-platform compatability and maybe even Java with it’s speed. Stick PHP’s bcompiler extension into this and why can’t we have an executable file just that same as any C/C++ app that doesn’t require the CLI binary and php4s.dll?

I had some more but I got sidetracked and now I can’t remember :stuck_out_tongue: Oh well…

wholly moley!

Java is a programming language. Purely and simply. Been around since 94/95… Can do most anything, and is. Has huge momentum, still free.

PHP is based on a programming language. At best is a:

HTML preprocessor? what language does the processing?
App server. Ok, based upon which language?
Scripting language. For a scriting language to be useful, need, client and server! Which language do client/user use?

There are problems with both, but comparing PHP to java is:

apples and oranges, or is that limes

That may all be true(not sure really).

But this was the question:

"Which serverside-language is better PHP or JSP? "

The question wasn’t: "what is the best all around programming language, Java or PHP?
I’m sure even the most faithful PHP nuts would say Java if that was the question.

–ed

Really? I don’t particularly like Java. My experience with it is that it almost seems to encourage excessive OO. Writing excessively abstract classes that then call other classes’ methods to call classes’s methods that in turn print something out. :wink:

But see, it doesn’t matter, it comes down to the way the programmer programs, not the language. And there is no such thing as the “best” “all around” programming language. That statement is hard to answer because best is not well defined, nor is all around. What makes a language good? Fast development cycle? Fast execution speed? Well implemented OO features? What do you mean by all around? Languages are tools in a toolbox, sometimes its best to put your favorite wrench down and just hammer the nail in. (At this point, someone needs to talk about cars so we can get a good mix of the programming analogies…)

Well I think Java is applicable to a much wider range of problems, whereas PHP is mainly for dealing with the web problem. PHP isn’t really a true general purpose language like C++ and Java, nor is it meant to be. It may be one day, but it’s not there yet. It’s still essentially what it’s name says it is – a hypertext preprocessor. Now the CLI executable with PHP4 and the upcoming PHP5 may change that a bit, but I still wouldn’t go writing a 3d game engine with it, or using it to develop missile guidance software or something like that.

–ed

(This is mostly directed at MJohansson)

I could write an utterly horrible platform in JSP, and .NET. To say that PHP is problematic because it lacks a “standard” approach to development is a bit strange. I could pretty much write a massive JSP page that completely ignored OO. By the same token, I can write PHP code very quickly and get a solution out, yes. But by the same token, I can also get simple java serverlets out at a similarly rapid rate.

You direct this argument against my statement that it’s problematic that PHP lacks a standard approach to web development. I don’t think your argument refutes that statement in any way.

That PHP lacks a decent default framework for development is a huge problem, in mine and manys opinion. Let me show you. .NET, for instance, has a very well defined and good framework in placed called Web Forms, for developing web applications. You don’t have to use it, but pretty much everyone does, since it’s standard, and it’s really good.

This results in the advantage that if I, mid-project, realize that I cannot meet the deadline, and need to bring in another programmer, that person can almost jump right in, since he is already so familiar with the Web Forms framework. Now, PHP completely lacks a standard approach to this, which means that you are forced to to pick between several third-party solutions, and probably write quite a bit of code yourself. This approach has advantages and disadvantages, but one of the main gripes me and other people has with it is that it’s (1) bad from a support perspective, i.e. many third-party vendors = bad, and (2) any programmers brought in at a later point must (most likely) spend a lot of time learning the frameworks you are using.

Maybe I’m off-topic and I have to admit that I’m a C programmer, C++ in the last few days, due to the type of apps I have to develop so I never used Java, .NET and I used PHP only few times.

That said,
one comment in a Java blog surprised me:
``…when he uses Java, he finds himself thinking mostly about the technology itself. And when he uses Microsoft tools, he finds himself thinking mostly about the problem he is trying to solve…‘’
Maybe hearing an opinion from you geeks that used them boths would be appreciated.

Against PHP I could say:

a)
Actually PHP5 is not in production stage…
If this year you had to develop a lot of classes you had to develop them by using 4.x syntax.
When PHP5 will be production ready what will you do ?
Recode your old classes ?
Okay they will work but your application will be composed by a mixage ``language syntax’'…where is the project consistency ?

a.1)
In my opinion PHP changed syntax too many times.
If I remember correctly only 4.2/.1 intoduced classes, but maybe I could be wrong.

This is to say AFAIK, as I said, AFAIK , with C# the language didn’t change too much…okay maybe small changes, with PHP it changed a lot…one thing it to add libraries another is to create new or change language features…

As I said my knowledge is very limited in this field so do not hesitate to enlight me… :wink:

Thanks,
:slight_smile: Andrea

Johannson, I see what you are saying now. I thought you were referring to a unified development methodology and not the core classes the language shipped with.

Incidentally, the fact that frameworks aren’t “part of the language” never really struck me as a particularly good argument. Just as you should consider host availability, and the number of people who are willing to answer your questions, the platform is an integral part of any language. With .net and java, you have a very feature-rich library to build upon, which does not exist in PHP. This deviates from comparing the languages on its intrinsic merits, but I think that it is a major thing to consider. When you are working with a language, you will most likely be using the classes and framework that comes with it, and PHP does not have quite the same feel to it as JSP or .NET. You do find yourself reinventing the wheel more than you may like.

The funny thing is we’re all just arguing, and have absolutely no idea what the original poster wanted. Have we given him enough information? Did he throw up his hands in disgust and hide in a corner?

Darkwulf - couldn’t agree more with your last post. Excellent points. I think PEAR seems to be moving towards becoming the official class library. I have not used it personally, but I’ve heard lots of complaints about it.

The funny thing is we’re all just arguing, and have absolutely no idea what the original poster wanted. Have we given him enough information? Did he throw up his hands in disgust and hide in a corner?

That’s okay. I like arguing in itself. :wink:

thanks for bringing that up ! , for the future no I do not think it will lack in this area far from it, and whilst .NET will have the advantage of better win32 integration , PHP-GTK will have the X-platform advantage (not to be ignored!(with linux finally gnawing its way onto the desktop of many a government department))

I did not mention PHP-GTK as until Zend2/GTK2 is stable its possibilities are speculation … (lost the link but someone just ported GtkMozembed to PHP-GTK mmmmmm :wink: ) & as Andrea pointed out PHP5 is not yet production … non the less it will happen and be backwards compatible to boot with perhaps the odd extra warning/notice or so.

As you mention with the bcompiler && the embed sapi compiled executables are already realistic , & other possible deployment solutions are in the pipeline, its not a case of can’t , there has just been no real need to date. Zend2 is where and when things change.

The oject model is being extended not changed , internally it is a rewrite but mostly transparent to a martian who was not told the object model has changed.

Limited object type syntax came with PHP3 & with many refinements since then , backwards compatibility is always a valid issue but most of us will be only too happy to rewrite code to suit the added functionality of the new improved object model , & when you see how happily .NET has been accepted by ASP houses despite a much larger change in philosophy I do not think it will be an issue for PHP heads , many of us cant wait to dump old code for the new simpleXML functionality , better dereferencing etc, I am not a great lover of OOP and get lost looking at some of the posts here (mostly because they try to emulate JAVA) but you have little choice when dealing with true GUI apps as in PHP-GTK etc.

coo_t2 the PHP binary has been used for many things aside from HTML munging for a long time , not that I would be sticking it in a warhead either :wink:

common ground :smiley:

Really you have to ask the question why i want to learn. PHP is a server side environment where ZEND is the language and all of its libraries and ZEND make up PHP. Just like JAVA is the language used in JSP.

There are many arguments for and against each of the technologies. I would ask my self am i learning this for pleasure,career, etc

From economic point of view, i believe PHP is better. Hosting is cheaper, licensing is free, ability to hire a PHP developer is much cheaper than JAVA. You can find teenagers that can program PHP more than java!

From a programmer psychologic point of view, php is much easier on the brain to pick for the first time than java. I’ve been coding for many years now and still have to think when programming in java while in PHP it just comes natural. I tell everyone that PHP is the language to learn because in brings in familiarities from other languages such bash,PERL,c/C++ etc. I feel PHP developers are more versatile than JSP as they are exposed to many different train of thoughts. And for the amount of code thats out there, they can pick their own style that they feel comfortable in. It is by example where a developer learns and adapts and becomes an expert. Since PHP has so many examples of apps, (check out sf.net) you can learn more about technology and see it practise. what better way to learn and learn quickly.

I am a big fan for PHP as it takes the KISS (Keep It Simple Stupid) approach which is fundamental statement used in the unix world. Think about it, unix has been around since the 60’s and still is!

my 2 cents