I have been developing websites using PHP for the past one year, and it has serve me quite well(fast to learn, powerful, etc) except for the occasional frustration from troubleshooting PHPLIB.

With all the marketing 'hype' by Sun, i'm beginning to get interested in Servlet/JSP as another tool for web development. Can someone who has used both languages comment on their differences, e.g. is there anything Servlet/JSP could do which PHP couldn't? or vice versa? TIA.

Moreover, as i'm currently looking for another job(in singapore), PHP still does not seem to be popular in start-ups or web shops, compared to ASP/VB, Perl or Servlet/JSP instead. I guess in order to make myself more marketable, i have to pick up some of the other languages(although none can beat the simplicity of PHP syntax).

regards,
jonathan

    Java is a better choice for projects that lend themselves to Object Oriented code, if you want the code in your web app. But, if you use a database with a procedural language like Oracle or Postgresql, you can put a large chunk of your logic right into the database, which, really, is where the ruleset and such belong anyway.

    As middle-ware type of software, PHP gives you the ability to interact with dozens of different dbase backends at once, all with their native interface, or a couple of fairly fast odbc drivers.

    As a development environment, Java is probably a bit more mature, but not as fast as PHP in any test I've done.

    The real question is can you develop scalable business apps in PHP and / or java servlets, and the answer is yes, they are both quite capable of doing that.

      Just found this article on the problems of JSP at http://www.servlets.com/soapbox/problems-jsp.html

      It seems that the author recommends 'template engines' such as WebMacro or Enhydra XMLC to replace JSP. (Kind of similar to FastTemplate or PHPLIB Templates for PHP) I think the only difference now is what advantage Servlets or EJB(Beans) has as compared to PHP.

      regards,
      jonathan

        7 months later

        Yes, the subject remain open... and that's because I still think that JSP is a lot more faster than PHP...
        Isn't that true ?

          Not in any benchmarks I've looked at. Generally speaking JSP's selling point over PHP isn't absolute performance but code reusability, OOP, and layering.

          PHP is about as fast as it gets really without compiling C and using fastCGI. Even then it can be a close race.

            10 months later

            Yeah!! is true, php is faster than JSP technology. But ask yourself??? How many times you reinvention the wheel using php. Too much!! And that's because php don't offer good Object Oriented Aproach. Although the JSP is no faster, it's more faster when you have the thinks in your head and you can produce thats more faster than PHP because you have the tools. You can't compare the millions of class and libraries that Java have with the fewer utilities of PHP. In conclusion, PHP is faster than JSP but JSP is more elegant in it's code and more expandable.

              Hi!

              I agree with all other guys who chipped into the discussion - Java is more powerful and more mature as an object-oriented platform, but the speed is not so great which arises from the fact that objects generally tend to allocate more memory and so they take more time during startup and shutdown. But OOP is more right - try to write a decent application in straight C++ that opens a window with a few buttons and textboxes on it. Then try the same with MFC - Microsoft Foundation Classes. The amount of code will be much smaller in the second case. However, in the first case you will be dealing with a lightning-fast application and in the second the whole 1-Megabyte MFC Dynamic Link Library will have to be loaded every time this small window opens. Again, in the first case if you don't use any wizards it will take you anywhere from a few hours to a day to write and debug it (if you're not reusing code, that is), and in the second - a few minutes maybe.
              The same applies to VB - VB Runtime takes a bit over 1 megabyte; Delphi - Visual Component Library is quite heavy too, although Delphi compiler may compile only parts of it into the code if I remember well.

              Java is about the same - there's Java Virtual Machine behind the scenes. It gets loaded during server initialization, but it still takes time to start up your scripts which is generally longer than PHP script startup time.

              What JSP offers which PHP doesn't? JSP has a great OOP toolset. One of the things you'd miss in PHP if you were a Java programmer is an ability to extend more than one object interface or extend and implement interfaces at the same time. This is very handy sometimes. If you make a reusable library, you can make and extend objects, and then, somewhere down the road, implement this library's interface - so you won't have to backtrack and make the first object in this hierarchy extend the library in question. For instance:

              class MyLib {}
              class MyClass {}
              class MyClass2 extends MyClass {}
              class MyClass3 extends MyClass2 implements MyLib {}

              In the case of PHP, you will really break down the nice OOP approach if you make MyClass extend MyLib, which you don't want because you might want MyClass to extend different libraries in different cases.

              If you are considering a second language, you should really explore your options. There's a lot of stuff going on with XML and different libraries to make XML a standalone solution. You can also explore C# which is a new Microsoft thingie (as much as we all hate Microsoft, they do right things most of the time :-) ).

              All of this is about to change because super computers are not far away and even with Pentium 600 it doesn't matter that much if you are dealing with a VB application or a C++ application. You have a small delay during initialization and probably a little bit slower response time, but it's okay. Our brain doesn't work at such speeds anyway. You have to think how much time either approach takes in order to write and debug a solution. OOP is a winning approach, and I hope the new PEAR and other technologies PHP is after will make it more appealing to developers everywhere.

              Best regards,
              Stas

                3 months later

                I thought that Stanislav gave a really fair and balanced view of the whole thing.

                  Write a Reply...