Re: Why JSP is better than PHP >>

From: Date: Mon, 13 Nov 2000 18:54:33 +0000
Subject: Re: Why JSP is better than PHP >>
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-25007@lists.php.net to get a copy of this message
Erick Papadakis wrote: > 1. Anything you can do with PHP, you can do with JSP; > the reverse is not true Maybe true, but one should prove that. At the end, it depends on coder's proficiency > 2. JSP is much more powerful, since it has access to > all the Java libraries. PHP only has access to PHP > libraries PHP has access to all the php libraries :). The word 'only' only means that (maybe) there are more Java libraries, then php's. Well, did someone used java.awt.* or java.Swing.* bunch in their JSP pages? :) There are a lot of good php code around for free that you can use in your applications. And there are a lot of extensions written for php in C, which is more fast than their Java counterparts. > 3. JSP is Object-Oriented, so leads to cleaner code > that's easier to debug, maintain, and improve. (PHP > also allows objects, but the object model is more > primitive, and most scripted pages ignore PHP objects > and just use normal variables.) It's a question of preference. There are a lot of good programmers around wasting their time discussing what is better - OO code or plain procedural programming. But nobody forbids you to write good clean maintainable code, which is easy to debug and improve using either OO or procedural practice. I guess the OO side of PHP to improve shortly, cause i see many things that development team took from java for the last few months :) > 4. The equivalent syntax in JSP is just as simple to > learn, so you can get up and running just as quickly > -- that is, there's no extra startup cost in using > Java, at least not a significant one JSP is nothing more (and nothing less) then java subset. All the difference is that JSP allow to insert some language tags into html. I doubt that you can learn java good enough as fast as you could learn php good enough. Learning to place language tags within html page in descent way won't make you a good java programmer - java is much more complex then php, and it takes years to learn it well. By the way, the syntax is not the main thing in learning the language - all the major languages consist of if, then, else, for, while, unified operators, variable, function and class declarations. Nothing more :) All the rest are functions made by other people. > 5. Java programmers (as opposed to 15-year-old hackers > or HTML monkeys) appreciate the importance of a clean > language with complex OO data structures and strong > typing Good programmers (as opposed to monkeys) appreciate the importance of good practice and good coding standards. In any language. > 6. With JSP, if the code inside a page gets too big, > or if you want to use it elsewhere, you can cut it > out, make it into a Java class, and invoke it from > anywhere in your application (even not from a page). > With PHP, you're stuck inside the HTML box. That's not true. Good practice in development of big projects in php is to split you code and use it if needed. And, of course, not to place ANY of the php code in html boxes :). Use templates instead. > 7. JSP's concept of state management and persistence > is more explicit and powerful than PHP's. With JSP, > you can specify whether a variable persists for the > page, the request, the session, or the application (or > if it's just local to the function). The JSP engine > automatically does the right thing with cookies so you > have access to the variable on later requests. With > PHP, you just have "global" and "not global", you > don't have automatic session management, and have to > do your state thing manually with cookies or hidden > variables. What the hell do you mean under "automatic session management" in a stateless HTTP protocol? How can you pass a session entity other then using a cookie, post, get or path info? Did java learn mind reading? I doubt. JSP and PHP (and others similar ) engines are doing session management in similar ways. They use cookies, hidden fields and so on. Call it automatically if you like. PHPLIB also do it automatically while it is not the core part of php. JSP is also an add-on library for java. As for persistence decisions, You should always determine how the things should be persistent by yourself. If you want the variable live in session, you must definitely say this in your program. No engine will decide it automatically for you. If it will, it's bad. As of variable and methods visibility, the one thing php lacks - it knows nothing about private and public. Not a big problem for a good programmer. For the list of "persistencies" above, only one thing php currently lacks - that is an application persistence. For my point of view, it's only a marketing term. Application level is nothing more then storage for variables persistent while the server is running, and methods to fetch and change its values. Place those variables in a database or a plain file, and you'll get an application level in php. I guess it is possible to store that data in a memory also, while have not tried yet. -- Best regards, Max A. Derkachev mailto:kot@books.ru Symbol-Plus Publishing Ltd. phone: +7 (812) 265-0054, 265-1228, phone/fax: 567-8775 http://www.Books.Ru -- All Books of Russia

« previous php.general (#25007) next »