The great Java vs PHP debate [jsp falls by the wayside]
mike
Status: Contributor
Joined: 08 Oct 2004
Posts: 71
Reply Quote
<this thread was split from this scaleable inman thread>

yea, the &amp; makes sense, i guess i always had it in my head that it would screw the link up, i should have just tried it.

as for his not validating, i think he's more making a statement. some people are way too caught up in the whole validating thing and would rather have a shitty page that validates than working on making a good one validate.

i'm planning on teaching myself java for a large site I'm on the staff of that is planning on switching over from php to jsp. right now my scripting skill are pretty week, and i don't use flash much. i'm pretty sure if i get the time and do some research it's not that difficult to get the flash file size cut down. where there is a will there's a way
Back to top
erikZ
Status: Contributor
Joined: 30 May 2004
Posts: 148
Reply Quote
<<< teaching myself java for a large site I'm on the staff of that is planning on switching over from php to jsp.

That's a really bad idea, who thought of that? Not the teaching yourself a programming language, that's a good idea, but switching from php to jsp. PHP is incredibly robust, it's almost always bad programming that leads to perceived inefficiencies, and jsp, oh, very sad. If your staff were serious about upgrading, I could see a switch to Perl or maybe compiled C++ type modules, but jsp? that's like switching from a Toyoto Camry/Lexus to a Daewoo or Hyundai.

Also, jsp isn't java, it's just a scripting language, like asp or php. You might be thinking of javabeans or whatever, but why anyone in their right mind would even contemplate that switch for a second, man, I'm glad I'm not involved, that's like going from stable linux/unix servers to windows servers, very sad.

Re your other comments on HTML, I can't agree. HTML 4.01 strict is only a tiny step away from XHTML, especially if you leave out the target attribute.

The only thing you need to do to switch a 100% text/html type 4.01 file to XHTML is basically 3 simple search and replaces. First, <br> changed to <br />, second, two regular expression search and replaces, or one if you want, I'm not very good at regular expressions but this is the rough idea:

<img(.)+> for <img$1 />, same for meta and link, and that's it, an XHTML document. There is actually a script that does the opposite, returns the correct html type, xhtml 1 or html 4 by doing this type of search and replace live right before the document is delivered.

The day you can do this switch is so far away it's not even worth considering currently [IE 5-6 = 90-95% market share. Even if IE Longhorn supports XHTML mimetype, which is not a given, it will take about 6 years, or maybe 8, until you can actually really use XHTML on a practical level. If you haven't tried putting out real XHTML I'd suggest you try it, your enthusiasm will drop quickly.]

You'd be surprised how strict HTML 4 is in strict mode, it was actually easier for me to learn XHTML 1 than strict HTML 4. And if you use only genuine HTML characters in the 4.01, you're ready to do for the switch anytime you want.
Back to top
mike
Status: Contributor
Joined: 08 Oct 2004
Posts: 71
Reply Quote
comparing switching php to jsp to switching from a lexus to a daewoo is downright absurd. your perceptions of jsp are very outdated. programmed properly it can outperform both mod_perl and mod_php. we've been running on php for about 3-4 years now. we've just outgrown it. that and pretty the site needs to be rebuilt the correct way without a bunch of messy hacks. The current team is all pretty tied up with school and other ventures that make them money. so this being more of a fun project kinda presents a problem. i should have been more specific to have said j2ee rather than java, anyhow we have someone who's volunteered to start on that. a bunch of us are comp sci majors who have to learn it anyway. the site is planned to grow into an extremely large application so we also feel that it'll give us more room to grow. anyway, i'm not the project manager or anything, and they do more of the programming than me. they layed out there reasons to me and they all seemed very valid. so thus i'm just optimistic and looking forward to learnign something new.

btw the problem with the html/xhtml is when u have other people editting documents. especially when the people editting them really shouldn't be doing so. u see they can add shitty code with html and i might not catch it with a validator. xhtml will point it right out for me.
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 3895
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
I'm an open source fan, I got that way by working with proprietary solutions. I trained on ASP, I was the top asp student in my classes. The second I went to PHP, I went, oh, great, all the stuff I hated isn't here, and everything that I wanted is.

You're probably right about what you say about jsp being improved, I hope it is, all I can say is that when I hit a slow dynamic website, all I have to do is look up at the url, and it's 9 times out of ten running jsp [the worst in general by far] or asp. But this is probably a comment on jsp and asp programmers, the real hackers tend to either use real programming languages, C, C++, Java, or hardcore scripting languages like Python or Perl, hackers don't like proprietary stuff in general, it turns them off.

It's also a question of if your server is running Apache 1.3 or 2.0, 2.0 is much faster, supports multithreading, other stuff, also if it runs certain php things like zend optimization, can't remember the rest.

PHP runs some of the biggest web sites in the world, it's not an issue with PHP, it's the programming that's the problem, but sometimes it's hard for people to face this problem.

For an enlightening analysis, read this.

:: Quote ::
Services such as Amazon, Yahoo, Google, and Slashdot have known about scripting languages for years and used them effectively in production. Yahoo even adopted PHP as its language of choice for development. Don't believe the hype in the white papers that says that PHP isn't for real applications or doesn't scale.


The comments are especially entertaining, as you can see, another my thing is the best thing and your's sucks type thing, that's why all this needs to be taken with grains of salt, but this is talking about java, not jsp, like comparing php to c++, it's not a real comparison of course.

But since I'm not working on your site, it makes no difference to me. However, anytime someone moves from a really solid open source model to a proprietary model, it's generally almost certain that a mistake is being made, with the exception of entreprise level database systems, but all the scripting languages can interact with those fine.

Once a site gets to a certain point, I believe there is often a switch made to compiled cgi modules, usually done in C++ or C, that's what google runs on, though they started on PHP or Perl if I remember right, could be wrong. But I've read some pretty serious reviews of this question, php versus real Java especially, and the java people couldn't really prove any point that I could see, and that's java, not jsp. What makes the real difference, and this is what almost every real pro I've read on the subject says, is how the database queries are written, how the tables are linked, created, etc, that's generally the real bottleneck, and where the biggest mistakes happen. That's not related to what scripting language is used though, it's a sql thing.

Webmasterworld runs on PERL I think, and it gets a lot of traffic, but it also has very good programming running it.

Anyway, it's an interesting area, definitely worth looking into. One of the real things that made me take note, and remember, we're talking in these comparisons about Java, not jsp, was that a primary thing not discussed was programming and development time, Java ran far behind on that one.

If it were me, I'd be looking for some really good perl hackers.

Anyway, it doesn't really matter which system you learn on, programming is what you learn, not programming languages, ideally anyway - the one exception is if you waste your time on MS type stuff, that's a total dead end in terms of programming skills, it's too proprietary, as long as there is a reasonably close relationship to C it's fine, I suspect jsp has this too, since java does, .net and asp, those are the worst, total waste of time.

Re XHTML, try it, see how it works for you, that's what I did, I saw a lot of debate, implemented 2 full xhtml supporting sites, this one, in xhtml 1.0 strict [except the forums, those are 4.01 transitional, phpbb html is just too nasty to get fixed, though I did finally get it to validate, took a long time], mimetype served correctly only to validators and opera, when I get around to it. And www.phoenixwebtech.com , xhtml 1.1, the real thing, served to all compliant browsers as such, try it yourself, it's the only way to learn, the code and the links are in the xhtml thread. After doing this I stopped all commercial xhtml work, and switched to 4.01 transitional or strict, depending on the client.
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
Funny thread, drifted a bit off topic but that's ok.

Here's a pretty major discussion of PHP -> JSP, more appropriate for this case:
:: Quote ::
The website doesn't look much different, but hopefully we can now stop being a byword for unacceptably poky site performance.
[note here: poor performance using jsp, as noted, and I'd also second the observation that jsp pages tend to be the most poorly performing pages I see on dynamic sites]troutgirl blog - friendster moves to php from jsp

See especially post number 6 in that thread, by PHP's author, Rasmus Lerdorf [weird numbering system, post author and number occurs after the post]:
:: Quote ::
Scalability is gained by using a shared-nothing architecture where you can scale horizontally infinitely. A typical Java application will make use of the fact that it is running under a JVM in which you can store session and state data very easily and you can effectively write a web application very much the same way you would write a desktop application. This is very convenient, but it doesn't scale. To scale this you then have to add other mechanisms to do intra-JVM message passing which adds another level of complexity and performance issues. There are of course ways to avoid this, but the typical first Java implementation of something will fall into this trap....

Add to this the very simple way to link in native-C or C++ code to PHP and you can do all your heavy lifting in a strongly typed compiled-to-native-bytecode language while leaving just the lighter frontend templating work to userspace PHP scripting. That gives you the best of both worlds. The absolute fastest performance because nothing is going to beat decent C code and the frontend flexibility to quickly modify the user experience and launch new features through PHP's very easy-to-learn and friendly frontend language.


Post 14 repeats what I've seen over and over [obviously it's possible to find well implemented solutions, but the difficulty in finding those suggests that it's probably harder to do with JSP than PHP:
:: Quote ::
Those of you asking why they switched from JSP have obviously never used Friendster, or any other JSP programmed site. They are almost always slow. I can't stand them. On the other hand, I've never been on a well-programmed PHP or Perl site that was unacceptably slow.


Post 24 hits the nail on the head:
:: Quote ::
One of the downsides of JSP is that it does need experienced programmers that know what they are doing. JSP is no different from Java (desktop) in this regard. I've only used 1 or 2 desktop java apps that were fast, but I've used dozens that were slow and buggy. Most PHP sites will run pretty fast even with some shoddy programming, but JSP sites won't, from what I have seen.


This goes with pretty much everything I've read on this, take equal programming skills and you'll get a better result with PHP, because php is very easy to work with.

Post 50 cuts through the BS, this is what I've seen too:
:: Quote ::
Google uses Python, actually. But yeah, you'll be as hard-pressed to find a Java-based Web site that doesn't suck as you would be to find a Java-based GUI application that doesn't suck. They're like ghosts - some people believe they exist, some people don't, and I've never seen one. :-)


I've never seen a good java based app, and I've never seen a good jsp site, no matter what the high paid jsp guys claim. I've seen lots of high traffic php sites, mozillazine for example, php is not an issue.

Post 51
:: Quote ::
Finally, I'm still waiting on a Java site that is comparable in size to go-gaia.com


Anyway, it's a good thread. One thing you'll notice is that despite continuos claims that jsp is superior, there is not a single valid example given of a fast performing jsp site, but there is observation after observation that the users have never personally seen a good performing high traffic jsp site. I haven't either, I'm sure they exist, I just haven't seen one. Note that friendster had 2 JSP authors working on their JSP. I'm going to go far out on a limb here and take the extreme guess that those guys are a lot better than the guys you are working with. And they couldn't get a successful solution working in JSP.

An interesting blog entry:
:: Quote ::
Yahoo, Internet.com, now Friendster. I'm not surprised - in my previous work at a web agency, about two thirds of our business came from companies moving to Open Source, away from ASP and Java. About 30% was from one company alone - a major European auto manufacturer who were thoroughly disappointed with their JSP solution.
an interesting blog entry[last entry currently]
Back to top
mike
Status: Contributor
Joined: 08 Oct 2004
Posts: 71
Reply Quote
well it comes down to the only person with the time and willingness to rewrite stuff from scratch does jsp, so we're all gonna learn. there's a big team of us so we should get the code down pretty well. we run our own dedicated servers so we can make them do what we want. therefore that type of stuff is never a problem
Back to top
jeffd
Status: Assistant
Joined: 04 Oct 2003
Posts: 594
Reply Quote
All the sites under discussion run huge dedicated servers, obviously.

One of the real problems is that when somebody knows one language, they want to work in it.

That troutgirl thing attracted some major attention, you'll notice if you read the blog comments all the way, almost all the arguments against php were wrong, or based on not using the zend optimizing engine, or based on having to use Apache 1.3, which doesn't support the radically improved high volume capacity of Apache 2.

The key point is very obvious, it may be possible to create a good jsp solution, but it a: requires much more programming skill, a serious amount, and b: nobody can show a high traffic jsp website that doesn't suck, I've seen that too, time after time, sluggish page loads, look in url, jsp running site, it's like clockwork.

Post 59 hits a really key point: server load is based on a bunch of components, but serving images is huge, any type of data file is going to massively slow down a big site:
:: Quote ::
I think phpBB is an excellent example on how anyone can have a moderately well written PHP script without some design pattern/OO framework and yet get great scalability just by doing some MySQL tweaks and serving images from another web server.


If only one person has jsp skills, and you 'all have to learn', you are making a huge mistake. End of story. That one person should learn PHP properly, and then you'd have a long term maintainable project.

You don't learn advanced programming skills like this in a month, not in 6 months, it takes several years to even start getting decent. PHP cuts a big amount off that, but it's still very difficult. Supporting one person who might be gone in 6 months or a year is not a good idea, you will always be able to find PHP hackers who will be happy to join a serious project, the same does not apply to jsp, it just doesn't attract that kind of programmer.

Code maintainability involves a bunch of different elements, but one of the biggest ones is having access to a development community that is as big as possible so you can continue to grow and evolve painlessly, and that is attracting the right kind of people. There's a reason all the major open source projects like phpbb etc run on php and not .asp or .jsp.

It's the same reason Linux and the other open source apps are growing at an incredibly fast rate, the very best programmers are attracted by the community, by the respect, by the openness of these projects. See the 'what makes a good hacker' thread in the programming forum to get a sense of what makes a good hacker tick. Proprietary closed source solutions turn off these types, for very good reason.

What's especially interesting in that thread is that the Java people seem incapable of keeping hold that the original discussion was comparing JSP, not J2EE/Java to PHP. And even with that constant misstatement, it turns out that except for super heavy industrial strength apps, with huge development budgets and a lot of time, PHP is extremely competitive with J2EE. So PHP ends up being compared to J2EE, but nobody bothers reading the first Lerdorf post where he suggests PHP with heavy C backend programming modules for the very best mix. Sad really, to see people so immersed in their little worlds that they can't even read text and understand it. Oh well.

So if your site was going to run across different servers in different parts of the country, it might be better to go J2EE. But in no case did anybody there really suggest jsp was a good solution. That's why it was ignored after a while in the discussion.

Further reading sitepoint blog
Back to top
Display posts from previous:   

All times are GMT - 8 Hours