Which is better JSP or PHP?

Posted by Shashank Krishna Sunday, April 19, 2009


Which is better, JSP or PHP? that's a religious questions, depends on whether you believe in god or not? but who is god anyway?

The question itself isn't a very good one. It should be which is better J2EE or PHP because it's not really possible to look at JSP in isolation. There is no doubt that PHP is the better langauge for building web apps. PHP is the shortest path between the problem and the solution. J2EE will take you through a more scenic path. It might possibly be argued that the road built with J2EE technology will be more durable and can carry vehicles with bigger loads, but that is another religious question.

If you are a java programmer you will say PHP code looks really messy when you embed it into HTML and PHP programmers will come back and say JSP looks a lot worse, which is true. The retort generally given is that you can make use of varius tag libs such as struts or jstl to make the code neater. Some people will also make vague references to the MVC pattern.

If these advocates of tag libraries look at the servlet source code generated from their JSP they will surely bring up their dinner. Hand coded JSP when made into a servlet might make you lose your appetite but your dinner will hopefully stay in.

Not so with PHP, once you have written a few hundred thousand lines of code with PHP you can make scripts that look distinctily sexy.


Spread Firefox Affiliate Button | edit post .


  1. excellent post

  2. There's nothing 'vague' about MVC, and with that sort of reference, you're lack of knowledge is showing. It also shows in your last sentence. ANY algorithm can look sexy when the programmer know what they're doing and has some mastery over the language they're using.

    As for HTML with embedded PHP, vs a JSP with embedded JSTL/EL, anyone who doesn't see or know the difference needs more practice, and not just in one language, but in general. Practice with and knowledge of multiple languages comes with a better knowledge of software science, engineering, architecture, algorithm design, etc, and tends to be the result of the same, too. JSTL/EL IS cleaner than PHP, due in no small part to the fact that it provides a solution for keeping programmatic code out of the front end. As such, it's just plain easier to read and the edit HTML surrounding it.

    For a basic site, PHP will work fine. You can even go MVC and object oriented with PHP, or use something like the Yii Framework. PHP is definitely one of the best for rapid development, it just happens to be one of the worst for any sort of best practice.

    Generally, this sort of point of view depends largely (but not entirely) on whether you're a programmer, or someone who came into programming from purely front-end development or design, and don't have hard engineering experience. Probably, PHP gets a much worse reputation than it deserves, because of that (as does javascript, even though javascript is, by and large, front end). Most PHP I've seen written by others looks like a spaghetti nightmare (as does Perl). The same CAN be said for JSP and Java, but generally isn't, if it's being done where Java is normally used (in enterprise areas where any sort of heavy lifting is necessary). Generally, I've seen less spaghetti in web development server side code written in any language other than PHP. It CAN be well-written, but generally isn't.

    I realize this is an old post, and as such, hope you've learned something since then. I'm not religious about any programming or scripting language, nor am I prejudiced against any. It's just that the post exists, long after you've written it, and I don't think any young, eager noob who might come across it during an online search should take it with more than a grain of salt, as that would lead them in the wrong direction.


Post a Comment

Are You Planning on Quitting Facebook? Why?



About Me

My Photo
Shashank Krishna
Bangalore, up, India
nothin much to say.........doin B.tech in IIIT allahabad loves bloggingn hacking.... :) and loooves blogging
View my complete profile