SitePoint Sponsor

User Tag List

Page 1 of 8 12345 ... LastLast
Results 1 to 25 of 190
  1. #1
    SitePoint Evangelist ikeo's Avatar
    Join Date
    Oct 2004
    Location
    Austin Texas
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Could someone tell me why Java is faster than PHP

    I've been doing a lot of reading because of Harry Fuecks Pro PHP Rant
    In my reading, I tripped up on something.
    George Schnossnagle says here that he believes Java is faster than PHP.

    Notice how PHP being naturally slower than Java (something I believe to be true) comes in last?
    I always believed so too because (don't laugh)
    1. Java is used in Enterprise systems so it must be fast
    2. I thought because Java is compiled .... it would be faster.

    Well after doing a little research over at wikipedia
    I found this.

    This is achieved by most Java compilers by compiling the Java language code "halfway" to bytecode (specifically Java bytecode) —simplified machine instructions specific to the Java platform. The code is then run on a virtual machine (VM), a program written in native code on the host hardware that interprets and executes generic Java bytecode.
    Apparently compiled Java bytecode is interpreted too (just like PHP) so what makes Java faster than PHP?

    Is it the compiler or JVM runtime incorporated into J2EE (am I throwing around words I do not understand?)

    I really would like to know the answer to this.

  2. #2
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Two things. JavaVM's are developed by sun, who have brainpower (and shiny goldpieces) enough to make blindingly fast interpreters. And they have spend a long time doing it.
    Second, PHP compiles to bytecode on each request. This takes time. Further, since java bytecode is compiled in advance, the compiler can afford to optimize the bytecode.

    Additionally, PHP lives on a pper-request basis, where java servlets are kept in memory between requests.

  3. #3
    SitePoint Addict
    Join Date
    May 2005
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Prove that Java is "faster" than PHP in the general sense. "I think PHP is faster because of x" or "I think java is faster because of Y" doesn't work. Make two applications that run similiar logic and test them by sending several hundred simultaneous requests at each. Come back and report the results.

    In my experience, Java is slower than PHP for the stuff that you should be using PHP for as long as you're using an opcode cache. Even without the opcode cache, PHP frequently beat out most of the Java stuff anyway.

    And, no, simple "create x thousand variables and echo the output" type of scripts don't work. Why? Because that blatently ignores real world usage scenerios, namely the fact that a whole hell of a lot of the code that you use in PHP is actually mapped directly to C function calls, which is almost guaranteed to be faster than the java equivilents. Try doing something useful and then come back and say that Java is "faster" than PHP.

    There are also scalability issues to consider. It's a hell of a lot easier to build scalable PHP apps than it is scalable java apps.

  4. #4
    l º 0 º l silver trophybronze trophy lo0ol's Avatar
    Join Date
    Aug 2002
    Location
    Palo Alto
    Posts
    5,329
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Uh-oh. Something smells like burning.
    .
    Zach Holman
    good-tutorialsblogtwitterlast.fm

  5. #5
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Etnu
    There are also scalability issues to consider. It's a hell of a lot easier to build scalable PHP apps than it is scalable java apps.
    ?

  6. #6
    SitePoint Member
    Join Date
    May 2003
    Location
    Laval
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Java is probably faster but you also have to look at the amount of resource it uses to be faster, ie: RAM.

    In my experience, Java runs faster but uses more memory. However it provides stateful execution through servlets. Use the right tool for the right job.

  7. #7
    SitePoint Guru
    Join Date
    Nov 2002
    Posts
    841
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The Java VM is more advanced than the PHP VM. Read about fast garbage collection and Just In Time Compilation.

    One thing, though. All that JIT compilation, zillions of classes to load and shared state caches to warm up show up when you are loading a java desktop app -- Slow. This doesn't matter so much on a server, where you are running the same code over and over all the time and you never shut down the JVM.

  8. #8
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Pittsburgh, Los Angeles
    Posts
    706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Apparently compiled Java bytecode is interpreted too (just like PHP) so what makes Java faster than PHP?
    Java isn't "interpreted" in the same sense that php is, java's VM is much more sophisticated than what PHP offers. Java hasn't been an "interpreted language" for a long time (I forgot which version changed its status though). Anyhow java as things like a Hot spot compiler, which will compile "hot stops" of the program to machine code.
    Theoretically its possible that this can make much better optimizations than when you say compile C to native code, as it has much more information about the system its running on.

    In my experience, Java runs faster but uses more memory. However it provides stateful execution through servlets. Use the right tool for the right job.
    Whats your basis for this claim? In a web environment java based applications work
    MUCH differently than php apps do. That is to say with servlets you can save things between requests...if you do this of course you'll use more memory. But you are using more meory because you are doing something different. Where as with php all memory allocated during a request is taken back. PHP's interpreter does not use less memory that a VM for java.
    PHP frequently beat out most of the Java stuff anyway
    If PHP is performing better than your java stuff then you dont' know how to write java.
    Java as a language runs...much faster than php does. Furthemore in a web environment you can make optimizations that you cannot make in php, where as any optimization you do with php is either a standard feature with servlets/jsp or can easily be done.
    It's a hell of a lot easier to build scalable PHP apps than it is scalable java apps.
    Maybe in an alternate universe? But certainly not this one.

  9. #9
    SitePoint Evangelist ikeo's Avatar
    Join Date
    Oct 2004
    Location
    Austin Texas
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken
    Second, PHP compiles to bytecode on each request.
    I didn't know there was any compilation going on with PHP at all. I checked that out and found this
    That is really good to know.


    I read this article and a couple of others ... here's a quote.
    Faster is a non-starter, because Java is not so much faster than PHP that it makes much of a difference.
    What it seems like to me, is that Java isn't that much faster than PHP (if it is indeed faster).


    PHP's interpreter does not use less memory that a VM for java.
    I can't speak on this, because all my knowledge about this is theory (I programmed in Java a long time ago). However, it seems that Java loads a lot of stuff into main memory to run as quickly as it does and PHP doesn't use as much memory. Whether this is significant enough is probably dependent on your server right?


    It's a hell of a lot easier to build scalable PHP apps than it is scalable java apps.
    Maybe in an alternate universe? But certainly not this one
    I'm reading "Moving to ASP.NET Web Development with VB.NET" by Harris and Mac Donald. I don't code in VB.NET, but there was a big chapter on scaling Web applications that caught my eye. What they say in the book is borne out by George's ideas in my first post. The design and architecture of the web app affect scalability a WHOLE lot more than the individual language. Yes? No? maybe?

  10. #10
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ikeo
    I didn't know there was any compilation going on with PHP at all ... That is really good to know.
    Yes. An opcode-cache can boost performance quite a bit. I'll recommend you look at PECL::APC.

    Quote Originally Posted by ikeo
    What it seems like to me, is that Java isn't that much faster than PHP (if it is indeed faster).
    I think it depends a lot on the type of application, you're writing. If you are rendering 3d graphics, java probably beats the *** out of PHP. Webapps on the other hand, aren't cpu-heavy - it's a lot of i/o, and switching between i/o and cpu bursts. Theese things are more dependent on the OS than the interpreter, so the result are probably much the same for both.

    Quote Originally Posted by ikeo
    However, it seems that Java loads a lot of stuff into main memory to run as quickly as it does and PHP doesn't use as much memory. Whether this is significant enough is probably dependent on your server right?
    I'm guessing here, but I would suppose that the same VM can stay alive for ever, like a deamon. It's comparable to apache having to start up before PHP can be served.

    Quote Originally Posted by ikeo
    The design and architecture of the web app affect scalability a WHOLE lot more than the individual language. Yes? No? maybe?
    That's my view too. And java comes with a thorugh and very clever framework fo classes, which makes it much easier to write large scale apps. Java's framework may be a killer for beginners, but it's really valuable when you need to write bigger stuff. PHP on the other hand, is easily accesible, but doesn't help you much after a certain point.

  11. #11
    SitePoint Evangelist ikeo's Avatar
    Join Date
    Oct 2004
    Location
    Austin Texas
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it depends a lot on the type of application, you're writing. If you are rendering 3d graphics, java probably beats the *** out of PHP. Webapps on the other hand, aren't cpu-heavy - it's a lot of i/o, and switching between i/o and cpu bursts. Theese things are more dependent on the OS than the interpreter, so the result are probably much the same for both.
    He He ... I wonder who would actually write a 3D graphics app in PHP? :P
    I get your point though.

    That's my view too. And java comes with a thorugh and very clever framework fo classes, which makes it much easier to write large scale apps. Java's framework may be a killer for beginners, but it's really valuable when you need to write bigger stuff. PHP on the other hand, is easily accesible, but doesn't help you much after a certain point.
    Okay, so I'm not crazy and all this reading is making me a little bit knowledgeable. I agree with you about PHP though. I wrote this website from scratch in PHP. Don't be deceived by the 2 or 3 pages it has, the CMS behind it is almost 3 or 4 times as big. It started out fine, but now it has become really tedious to use PHP to code it, and I don't even think using OOP would really help. I'm actually thinking about rewriting the whole thing in .NET.

  12. #12
    SitePoint Evangelist ikeo's Avatar
    Join Date
    Oct 2004
    Location
    Austin Texas
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Selkirk
    The Java VM is more advanced than the PHP VM
    Semantic question here but ....
    Is it really called the PHP Virtual Machine or is it the PHP runtime?
    Would those be one and the same thing?

  13. #13
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Pittsburgh, Los Angeles
    Posts
    706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    However, it seems that Java loads a lot of stuff into main memory to run as quickly as it does and PHP doesn't use as much memory. Whether this is significant enough is probably dependent on your server right?
    It may be the case that java VMs use more "base" memory than the PHP interpreter I haven't really bothered to look as in either case its not very big. I was referring to the amount of memory your application will use. But this is a little hard to compare...but I have tested roughly how much memory is used by PHP objects vs Java objects and java does much better. Also even the PHP people note that Java is better at object allocation/collection and warn against pretending (namely PHP5) as if it is java.
    Webapps on the other hand, aren't cpu-heavy - it's a lot of i/o, and switching between i/o and cpu bursts. Theese things are more dependent on the OS than the interpreter, so the result are probably much the same for both.
    With java web technologies you can greatly reduce this load, by using in memory caches. You can't really do the same in PHP, although you can use things like memcached to do some of them. So this is only true when you app can't take advantage of any sort of caching logic.
    The design and architecture of the web app affect scalability a WHOLE lot more than the individual language. Yes? No? maybe?
    Sure, but the language and the technologies built on it effect how you design the application. With java (and .NET) there are standard web frameworks that have proven to be scalable, there is no such thing in PHP. Although I think Zend is working on some framework...I'd be really suprised if it did well. Even the lack of good IDEs for PHP effect its scalability. To me at least, PHP is just a templating language trying in the last couple of years to be something else. Its very good to use when you are writing a thin client over some database...but to write any real "business logic" in it seems silly.

  14. #14
    SitePoint Evangelist ikeo's Avatar
    Join Date
    Oct 2004
    Location
    Austin Texas
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Snaily
    But this is a little hard to compare...but I have tested roughly how much memory is used by PHP objects vs Java objects and java does much better.
    This doesn't surprise me. OOP was an after thought in PHP 4 and Zend still haven't gotten it completely right in PHP 5.


    With java web technologies you can greatly reduce this load, by using in memory caches. You can't really do the same in PHP, although you can use things like memcached to do some of them. So this is only true when you app can't take advantage of any sort of caching logic.
    Lets not make this about J2EE vs PHP. Every one knows ... or should know (at least) that J2EE provides a bevy of tools and functionality for enterprise level web application development that PHP can only dream of at this point. (I'm agreeing with you.)


    Sure, but the language and the technologies built on it effect how you design the application. With java (and .NET) there are standard web frameworks that have proven to be scalable, there is no such thing in PHP. Although I think Zend is working on some framework...I'd be really suprised if it did well.
    Ehhhh ... kinda sorta. This one goes back to the fact that PHP wasn't designed to be an application language. I agree with you about the Framework and how it helps make ASP.NET and J2EE easier to scale. However Java (as a language) isn't more scalable than PHP. Java already has a framework that helps it scale. I'd like to see what PHP does with its framework in PHP6 before I make a judgement either way. Make no mistake, PHP can scale, but I think I can concede without controversy that Java and .NET frameworks make it easier to do.

    Even the lack of good IDEs for PHP effect its scalability. To me at least, PHP is just a templating language trying in the last couple of years to be something else. Its very good to use when you are writing a thin client over some database...but to write any real "business logic" in it seems silly.
    I agree up until the bolded part. Frameworks are available in PHP that make it very possible to write business logic in PHP .... WACT for example. And every man's definition of "silly" varies. Also (I hope someone else jumps in on this to offer an alternative viewpoint) but its my belief that PHP IDEs are just as plentiful, if not more common than Java IDEs.

  15. #15
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Pittsburgh, Los Angeles
    Posts
    706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also (I hope someone else jumps in on this to offer an alternative viewpoint) but its my belief that PHP IDEs are just as plentiful, if not more common than Java IDEs.
    They are just as plentiful, but there are no where near in quality. I have used the ones that are suppose to be the best (Zend Studio, eclipse with php plugin etc) and can say I'd almost go "old school" and use emacs. I think PHP being "dymanically typed" has something to do with it...but in many cases more can be done. Where as products for java like Intellij are a pleasure to use. Although I will say I found Zend Studio's debugger to be decent
    However Java (as a language) isn't more scalable than PHP
    Actually, I think this is wrong. The two main issues that come to mind are that PHP lacks namespaces and that PHP is dymanically typed. The first I think most would agree with. With the second you can add comments to variables, methods etc to give hints about what they are suppose to be...but this is a bit hacky and usually developers get lazy with documentation. Also I'm aware of PHP5's "type hinting" in methods, but this only solves a few of the problems.

  16. #16
    SitePoint Evangelist ikeo's Avatar
    Join Date
    Oct 2004
    Location
    Austin Texas
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Snaily
    They are just as plentiful, but there are no where near in quality. I have used the ones that are suppose to be the best (Zend Studio, eclipse with php plugin etc) and can say I'd almost go "old school" and use emacs. I think PHP being "dymanically typed" has something to do with it...but in many cases more can be done. Where as products for java like Intellij are a pleasure to use. Although I will say I found Zend Studio's debugger to be decent
    Debatable ... there's Komodo, PHPEdit, PHPDesigner (My new favorite), TSW Webcoder 2006 and tons more. I don't know much about Java IDEs so I can't speak to that. I do like Netbeans though.


    Actually, I think this is wrong. The two main issues that come to mind are that PHP lacks namespaces and that PHP is dymanically typed. The first I think most would agree with. With the second you can add comments to variables, methods etc to give hints about what they are suppose to be...but this is a bit hacky and usually developers get lazy with documentation. Also I'm aware of PHP5's "type hinting" in methods, but this only solves a few of the problems.
    I saw a post that made pointed out similar problems with PHP scalability
    Pretty brutal, but good points nonetheless. I really can't argue on this since my experience with scaling is pretty limited, so I have to concede on those points as well.

  17. #17
    SitePoint Wizard Ren's Avatar
    Join Date
    Aug 2003
    Location
    UK
    Posts
    1,060
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Faster when doing what?

    If doing number crunching Java's JIT VM is surely going to give it the advantage.
    Grabbing data from external resources, and presenting a web page, I'd doubt there is much difference in similarly architectured applications.

  18. #18
    SitePoint Guru
    Join Date
    Nov 2002
    Posts
    841
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  19. #19
    SitePoint Addict
    Join Date
    May 2005
    Posts
    255
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by kyberfabrikken
    ?
    Java's startup cost means that you'll usually leave the process around and serve requests through that single process (the typical "application server" model). PHP's startup cost is extremely low, and the standard setup is to simply toss more instances of apache at the problem. As traffic increases, add more servers. It's pretty much infinitely scalable.

    Quote Originally Posted by Selkirk
    The Java VM is more advanced than the PHP VM. Read about fast garbage collection and Just In Time Compilation.

    One thing, though. All that JIT compilation, zillions of classes to load and shared state caches to warm up show up when you are loading a java desktop app -- Slow. This doesn't matter so much on a server, where you are running the same code over and over all the time and you never shut down the JVM.
    Fast garbage collection is meaningless when you simply toss away the entire app context at the end of the request (the way that you build PHP apps). PHP's garbage collection is actually pretty terrible, but it doesn't matter because you just toss it all out at the end of the request.

    JIT compilation does not make a web app faster. It can (theoretically) help improve the speed of a desktop app or server process. In practice, it usually performs worse than statically compiled apps (e.g. C). Web apps startup and tear down every request in the PHP model, so it doesn't matter.

    PHP's interpreter does not use less memory that a VM for java.
    In most instances it does. A typical command-line PHP app uses about 4 MB of RAM. An apache thread running the PHP interpreter will usually eat 6-12MB.

    Java as a language runs...much faster than php does.
    Prove it.

    Maybe in an alternate universe? But certainly not this one.
    How to scale PHP:

    Install app on more servers.

    I work with PHP code every day that deals with hundreds of requests per second. The scalability problems are always on the database end, not on the application end. If you want the app to handle a heavier load, you simply add more hardware 99% of the time. You can't just throw more hardware at a java app to solve the scalability problem. No, PHP isn't made out of magic and butterflies, but this is one area that scripting languages really shine.

    The idea that PHP's type hinting in some way makes apps *harder* or that it's a *problem* is just laughable. Dynamically typed languages have many advantages that statically typed ones do not. Data type indicates absolutely nothing about a variable. Use sensible variable names and document your code or it'll be hard to use. Forcing something as archaic as static typing on web development slows development cycles painfully.

    No, PHP is never going to be good as a daemon process. That's just cold hard truth. PHP excels as a web app language and as a general-purpose scripting language. It can replace perl for everything and everything else for web apps, but it'll never replace C when it comes to high performance daemon processes. Nobody's ever going to write a web server in PHP.

    EVERY language is "compiled". The difference is with regards to what it's compiled to.

    Java is compiled to java byte code which the JRE maps to machine instructions to perform tasks.

    PHP is compiled to PHP byte code which the PHP runtime maps to machine instructions to perform tasks.

    C code is compiled to machine instructions to perform tasks.

    C# code is compiled to CLI bytecode which the .net (or mono, or whatever) runtime (CLR) maps to machine instructions to perform tasks.

    What affects speed is when that compilation occurs. In PHP, compilation is done at run time (unless you're using an opcode cache). In other languages, it's done at build time.

    You can't really do the same in PHP, although you can use things like memcached to do some of them.

  20. #20
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Etnu
    Nobody's ever going to write a web server in PHP.
    Incidentally ... http://nanoweb.si.kz/

  21. #21
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know anough about the low-level stuff to really argue for or against php vs. java, and I think it's subordinate anyway. I'm quite sure that both can be scaled in regards to performance.
    More importantly, it's my belief that the software framework which the two platforms present to the programmer make a difference. PHP's framework is easily accessible, but the consequences are often unmaintainable apps when they grow in size. I know that you can easily make spaghetti code in java, but it's easier to avoid it.

  22. #22
    SitePoint Evangelist ikeo's Avatar
    Join Date
    Oct 2004
    Location
    Austin Texas
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree with you mostly but I want to gain a better understanding of some of your points.

    PHP's garbage collection is actually pretty terrible, but it doesn't matter because you just toss it all out at the end of the request.
    Can you prove this.


    JIT compilation does not make a web app faster. It can (theoretically) help improve the speed of a desktop app or server process. In practice, it usually performs worse than statically compiled apps (e.g. C). Web apps startup and tear down every request in the PHP model, so it doesn't matter.
    I've done some reading on this, and from what I understand JIT would help Java perform better than PHP because PHP is interpreted (after being compiled to Zend opcode).

    The idea that PHP's type hinting in some way makes apps *harder* or that it's a *problem* is just laughable. Dynamically typed languages have many advantages that statically typed ones do not. Data type indicates absolutely nothing about a variable. Use sensible variable names and document your code or it'll be hard to use. Forcing something as archaic as static typing on web development slows development cycles painfully.
    read this and let me know what you think

  23. #23
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    > I know that you can easily make spaghetti code in java, but it's easier to avoid it.

    Well, I wouldn't go as far as to say that, in regards that it's easier to avoid in Java. At the heart of it, it's basically down to the individual developer(s) how they develop, but looking deeper into what you say, maybe it's the practice of separation that's more foundamentally ingrained into the development community?

    I have the adverse impression that it's that foundamental practice of separation that is lacking some what with the PHP community...

  24. #24
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    > Web apps startup and tear down every request in the PHP model, so it doesn't matter.

    I would agree with that, and that Just In Time is pointless when you consider the environment of which PHP works under. As for Garbage Collection, that may well be a concern not so much based on the size of the application as such, but more so as the number of users using that application, increases.

    I'm not sure myself how PHPs Garbage Collection works, or even if it works at all

  25. #25
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Pittsburgh, Los Angeles
    Posts
    706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In most instances it does. A typical command-line PHP app uses about 4 MB of RAM. An apache thread running the PHP interpreter will usually eat 6-12MB.
    You can easily run a small command-line app with less than 4MB of RAM in java. Java doesn't use a lot of memory...it does take awhile to start up. But if you have any evidence that PHP uses less memory than Java reference it.
    JIT compilation does not make a web app faster. It can (theoretically) help improve the speed of a desktop app or server process.
    What the hell are you even talking about? In java any code that becomes "hot" will be compiled to native code. Whether that code is running a web application or desktop app simply doesn't matter.
    Prove it.
    google.com - Anybody that denies that Java as a language is faster than PHP is a mindless fan-boy of PHP. ...hell try writing any NON-TRIVIAL algorithm in PHP and Java and see which which does better. PHP can solve some of its performance problems by outsourcing its work to C via an extension though. PHP is just not in the same class as Java, compare it to Perl, Python etc.
    Dynamically typed languages have many advantages that statically typed ones do not. Data type indicates absolutely nothing about a variable.
    Sure they have advantages...one of the advantages NOT being scalability. And...hmm..call me crazy but I'd imagine that a variables Data type would indicate something namely its data-type =).
    Use sensible variable names and document your code or it'll be hard to use. Forcing something as archaic as static typing on web development slows development cycles painfully.
    Adding typing information to variable names makes things really ugly. Furthermore if you have to add typing information to the variable names and/or document how does this imply less work? You do the same work the difference is languages with static typing can use this information at compile time. Furthmore good IDEs in Java do all the typing work for you. Have you actually worked on a proejct with more than 50 files to manage?
    I work with PHP code every day that deals with hundreds of requests per second. The scalability problems are always on the database end, not on the application end. If you want the app to handle a heavier load, you simply add more hardware 99% of the time. You can't just throw more hardware at a java app to solve the scalability problem.
    Have you actually worked with java web applications AT ALL? Please tell me why you can't "add more hardware" to java applications? EVEN if you wrote an application that is not distributable you can easily cluster tomcat (or any other servlet container) using sticky sessions. This is almost trivial to set up. Need more power? Add another tomcat instance. If your application was written to be distributable then its...a no-brainer...and ahem if you are working on the sort of app that can't run on just one server....you'd do that. But more importantly....the part of scalability that is being talked about in this post is that of the code. PHP's code is not scalable. Large web applications have thousands and thousands of source files being worked on by many people....there is no sensible way to manage this with PHP.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •