Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Java Urban Performance Legends

Posted by CmdrTaco on Sun Oct 09, 2005 08:19 AM
from the still-don't-like-java dept.
An anonymous reader writes "Programmers agonize over whether to allocate on the stack or on the heap. Some people think garbage collection will never be as efficient as direct memory management, and others feel it is easier to clean up a mess in one big batch than to pick up individual pieces of dust throughout the day. This article pokes some holes in the oft-repeated performance myth of slow allocation in JVMs."
This discussion has been archived. No new comments can be posted.
Java Urban Performance Legends | Log In/Create an Account | Top | 846 comments (Spill at 50!) | Index Only | Search Discussion
Display Options Threshold:
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • Nonsense (Score:5, Funny)

    by hedge_death_shootout (681628) <stalin@linuxmai l . o rg> on Sunday October 09 2005, @08:29AM (#13750205)
    These java urban performance legends are rubbish - java is highly performant in a rural or urban setting.
    • Partial Retraction by hedge_death_shootout (Score:1) Sunday October 09 2005, @08:35AM
    • Re:Nonsense by justsomebody (Score:3) Sunday October 09 2005, @11:42AM
    • I hate Java. by JPriest (Score:1) Sunday October 09 2005, @12:16PM
      • Re:I hate Java. by Doctor Memory (Score:2) Thursday October 13 2005, @09:22AM
    • Re:Nonsense by object88 (Score:2) Sunday October 09 2005, @01:03PM
    • Re:Nonsense by MHobbit (Score:2) Sunday October 09 2005, @03:37PM
  • Robomaid (Score:5, Interesting)

    How much time have I spent with Electric Fence and valgrind finding memory leaks in my C programs? In Java, the auto garbage collection is as good as Perl's, without that tricky "unreadable code" problem ;). And I can always tune garbage collection performance by forcing a garbage collect when I know my app's got the time, like outside of a loop or before creating more objects in storage.
    • Re:Robomaid by Some Random Username (Score:3) Sunday October 09 2005, @08:44AM
      • Re:Robomaid (Score:5, Insightful)

        Of course, that's why I program everything in machine language. Memory allocation in hex opcodes worked for me in 1981, it still works in 2005. Programming languages don't leak memory, programmers leak memory.

        In seriousness, look at the bugzillas and changelogs of any programming project. Memory leaks abound. So the reality is that memory de/allocation programming eats quite a lot of productivity, and impedes many otherwise ready releases. Of course we can de/allocate memory properly in C. And we can compute with scientific calculators. When we've got something better, we use it.
        [ Parent ]
        • Re:Robomaid by AArmadillo (Score:3) Sunday October 09 2005, @09:12AM
          • Re:Robomaid by Doc Ruby (Score:3) Sunday October 09 2005, @09:30AM
            • Re:Robomaid by Q2Serpent (Score:3) Sunday October 09 2005, @10:03AM
              • Re:Robomaid (Score:4, Insightful)

                Please forward me the resumes of these programmers, which include "Skills" like "I never write memory leaks". And whose "Certifications" include "Good Programmer", not those other resumes which say "Bad Programmer".

                The fact is that Java programs include more intelligence about programming from the compiler and the JVM. So programmers are more productive than with C. Which means that the same programmer budget can produce more product, or a lower budget can produce the same product. With distributed teams, outsourcing, OSS integration projects, those considerations are crucial to project success. Sure, quality projects also require good design and management. But Java eliminates some quality problems right out of the box. That can't be dismissed merely by saying "hire good programmers, not bad". Because it's a continuum, with a sliding scale of costs that isn't always proportional to productivity.
                [ Parent ]
              • Re:Robomaid by dubl-u (Score:1) Sunday October 09 2005, @12:01PM
              • Re:Robomaid by thoth (Score:2) Sunday October 09 2005, @12:51PM
              • Re:Robomaid (Score:4, Funny)

                by halleluja (715870) on Sunday October 09 2005, @03:18PM (#13752044)
                The fact is that Java programs include more intelligence about programming from the compiler and the JVM.
                It is particularly sad the Visual PnP-generation of today cannot identify the merits of GOTO's and self-modifying code.

                I have never had any memory leaks, just by including the following code snippet:

                /* Distributed under GPL */
                #include <stdlib.h>

                static void* repo = malloc(100000000);

                int main(int argc, char** argv)
                {
                /* do stuff, just increment & cast *repo when I need to utilize free memory. */
                free(repo);
                }
                [ Parent ]
              • Re:Robomaid by Q2Serpent (Score:3) Sunday October 09 2005, @03:51PM
              • Re:Robomaid by shmlco (Score:2) Sunday October 09 2005, @09:15PM
              • Re:Robomaid by Doc Ruby (Score:2) Sunday October 09 2005, @09:30PM
              • Re:Robomaid by Doc Ruby (Score:1) Sunday October 09 2005, @09:47PM
              • Re:Robomaid by Q2Serpent (Score:2) Sunday October 09 2005, @10:52PM
              • Re:Robomaid by Doc Ruby (Score:2) Monday October 10 2005, @07:14AM
              • Re:Robomaid by Doc Ruby (Score:2) Monday October 10 2005, @07:23AM
                • 1 reply beneath your current threshold.
              • Re:Robomaid by Q2Serpent (Score:2) Monday October 10 2005, @02:41PM
              • Re:Robomaid by Agret (Score:1) Thursday October 13 2005, @05:23PM
              • 2 replies beneath your current threshold.
            • Re:Robomaid by pthisis (Score:2) Tuesday October 11 2005, @02:31PM
          • Re:Robomaid (Score:5, Insightful)

            by Mr. Shiny And New (525071) on Sunday October 09 2005, @09:35AM (#13750424)
            (http://home.primus.ca/~mr.shiny/ | Last Journal: Thursday June 28, @11:34AM)
            You're right, Java does have memory leaks, in a sense, but these same problems can arise in any language. You could have a cache implemented in C/C++ that is never properly emptied, so over time it fills up. Or you could have a request log where, due to a bug, requests are not always removed from the log after they are processed. Sure, you might have included code to free the objects in the cache or log when you are done with them, but the programming error is that you forgot to remove the item. This is not a language issue, this is just a programming mistake.

            At least in Java you only need to worry about one problem: removing items from caches, logs, queues, etc when you are done with them; in C++ you have to also worry about de-allocating that object, which requires strict planning since the object must not be referred to anywhere else when you de-allocate it. In general you can't prove that the object isn't still referred-to by someone who had it before it was put into the cache/log/whatever; instead you need to establish rules and write documents to make sure everyone knows what the lifecycle of an object should be.

            As for your company not having a memory bug logged in 3.7 years, that's great, but without knowing what kind of applications you write, or how they're used, it's hard to say if that's significant. Some programs, like, say, grep, or mv or ls or any one-time-use utilities may be rife with memory leaks, but who cares? When the program terminates the memory is freed, and the user will likely not notice the leak. But even if your apps are long-running network services or whatever, I bet the time spent by developers preventing memory leaks is significant, even if that time is completely spread out throughout the development cycle instead of in large, easy-to-spot chunks running Valgrind or some other profiler.
            [ Parent ]
            • Re:Robomaid by Midnight Thunder (Score:2) Sunday October 09 2005, @10:51AM
              • Re:Robomaid by Mr. Shiny And New (Score:2) Sunday October 09 2005, @04:28PM
            • Re:Robomaid by NoOneInParticular (Score:2) Sunday October 09 2005, @02:19PM
              • Re:Robomaid by aled (Score:2) Monday October 10 2005, @03:27PM
              • Re:Robomaid by NoOneInParticular (Score:2) Tuesday October 11 2005, @05:11PM
              • Re:Robomaid by aled (Score:2) Tuesday October 11 2005, @06:05PM
              • Re:Robomaid by NoOneInParticular (Score:2) Wednesday October 12 2005, @03:50PM
              • Re:Robomaid by aled (Score:2) Wednesday October 12 2005, @07:23PM
              • Re:Robomaid by NoOneInParticular (Score:2) Thursday October 13 2005, @01:36PM
            • 2 replies beneath your current threshold.
          • Re:Robomaid by Baki (Score:2) Sunday October 09 2005, @01:33PM
        • Maybe you should look harder. by Some Random Username (Score:2) Sunday October 09 2005, @10:15AM
        • Re:Robomaid by someone1234 (Score:2) Sunday October 09 2005, @10:19AM
          • Re:Robomaid by Doc Ruby (Score:2) Sunday October 09 2005, @10:34AM
            • Re:Robomaid by ezzzD55J (Score:1) Sunday October 09 2005, @11:22AM
              • Re:Robomaid by Doc Ruby (Score:3) Sunday October 09 2005, @11:51AM
              • Re:Robomaid by Doc Ruby (Score:2) Sunday October 09 2005, @09:36PM
              • Re:Robomaid by NoOneInParticular (Score:2) Sunday October 09 2005, @02:25PM
          • Re:Robomaid by Jonner (Score:2) Sunday October 09 2005, @01:59PM
            • Re:Robomaid by PyroGx1133 (Score:1) Sunday October 09 2005, @03:41PM
        • Re:Robomaid by bani (Score:2) Sunday October 09 2005, @06:42PM
          • Re:Robomaid by Jeremi (Score:2) Sunday October 09 2005, @09:01PM
            • Re:Robomaid by bani (Score:2) Monday October 10 2005, @02:02AM
              • Re:Robomaid by Jeremi (Score:2) Monday October 10 2005, @11:47AM
              • Re:Robomaid by bani (Score:2) Monday October 10 2005, @01:36PM
              • Re:Robomaid by Nevyn (Score:2) Tuesday October 11 2005, @09:08AM
              • Re:Robomaid by Jeremi (Score:2) Tuesday October 11 2005, @11:47AM
              • Re:Robomaid by Nevyn (Score:2) Tuesday October 11 2005, @12:26PM
              • Re:Robomaid by pthisis (Score:2) Tuesday October 11 2005, @02:40PM
              • Re:Robomaid by Jeremi (Score:2) Tuesday October 11 2005, @06:57PM
              • 1 reply beneath your current threshold.
          • Re:Robomaid by jsight (Score:2) Sunday October 09 2005, @09:08PM
        • Re:Robomaid by Doc Ruby (Score:2) Sunday October 09 2005, @10:14PM
      • Re:Robomaid by Anonymous Coward (Score:1) Sunday October 09 2005, @09:03AM
      • Re:Robomaid by hedge_death_shootout (Score:1) Sunday October 09 2005, @09:18AM
      • Mod parent Funny! by BerntB (Score:2) Sunday October 09 2005, @09:20AM
      • Re:Robomaid by carlislematthew (Score:1) Sunday October 09 2005, @09:20AM
      • Re:Robomaid by dorkygeek (Score:1) Sunday October 09 2005, @10:58AM
      • Re:Robomaid by tsotha (Score:2) Sunday October 09 2005, @01:28PM
        • Re:Robomaid by pthisis (Score:2) Tuesday October 11 2005, @02:46PM
          • Re:Robomaid by tsotha (Score:2) Tuesday October 11 2005, @05:00PM
            • Re:Robomaid by pthisis (Score:2) Tuesday October 11 2005, @06:32PM
      • Re:Robomaid by Billly Gates (Score:2) Sunday October 09 2005, @02:35PM
        • Re:Robomaid by Some Random Username (Score:2) Sunday October 09 2005, @02:50PM
          • Re:Robomaid by aled (Score:2) Monday October 10 2005, @10:28AM
            • Learn to read. by Some Random Username (Score:2) Monday October 10 2005, @03:20PM
      • Re:Robomaid by Pseudonym (Score:2) Sunday October 09 2005, @09:32PM
      • Re:Robomaid by ebbe11 (Score:2) Monday October 10 2005, @03:18AM
    • Re:Robomaid by Anonymous Coward (Score:2) Sunday October 09 2005, @09:34AM
    • as good as Perl's? by jbellis (Score:2) Sunday October 09 2005, @10:13AM
    • Re:Robomaid by stesch (Score:2) Sunday October 09 2005, @11:24AM
    • Garbage Collection: not just for C by OpenGLFan (Score:2) Sunday October 09 2005, @12:47PM
    • Re:Robomaid by David's Boy Toy (Score:2) Sunday October 09 2005, @12:47PM
      • Re:Robomaid by aled (Score:2) Monday October 10 2005, @10:54AM
    • Re:Robomaid by MenTaLguY (Score:2) Sunday October 09 2005, @02:18PM
      • Re:Robomaid by Doc Ruby (Score:2) Sunday October 09 2005, @09:33PM
    • Re:Robomaid (Score:5, Informative)

      by radtea (464814) on Sunday October 09 2005, @03:10PM (#13752003)
      And I can always tune garbage collection performance by forcing a garbage collect when I know my app's got the time, like outside of a loop or before creating more objects in storage.

      No, you can't. At most you can give the JVM a hint that it would be nice to collect garbage now. The JVM is free to ignore that hint, and many JVMs will do just that.
      [ Parent ]
      • Re:Robomaid by Doc Ruby (Score:2) Sunday October 09 2005, @09:58PM
    • Bwahaha! by cow-orker (Score:1) Monday October 10 2005, @07:19AM
    • C is the problem; Java is not the solution by idlake (Score:2) Thursday October 13 2005, @02:01PM
    • Re:Robomaid by Doc Ruby (Score:2) Sunday October 09 2005, @09:20AM
    • Anonymous Cowards Can't Write by Doc Ruby (Score:2) Sunday October 09 2005, @09:42AM
    • 3 replies beneath your current threshold.
  • by GillBates0 (664202) on Sunday October 09 2005, @08:30AM (#13750214)
    (http://slashdot.org/~GillBates0 | Last Journal: Tuesday July 10, @04:36PM)
    JVM memory allocation isn't "SLOW". It's just pleasantly unhurried.
  • They're good.. now.. (Score:5, Insightful)

    by onion2k (203094) on Sunday October 09 2005, @08:31AM (#13750218)
    (http://www.phpgd.com/)
    JVMs are surprisingly good at figuring out things that we used to assume only the developer could know.

    Yes they are. Now. 10 years ago when Java applets were being embedded in webpages (to show rippling water below a logo :) ) they weren't. The performance of the language has greatly improved while the perception of language has remained the roughly same (at least amoung the general coding community).

    Just goes to show that even if you have a great technical product you'll still need the marketdriods. Unfortunately.
  • BULLONEY!! (Score:3, Insightful)

    by Anonymous Coward on Sunday October 09 2005, @08:31AM (#13750219)
    These articles keep popping up flatly stating that Java's slowness is a myth. But, no matter how many times you say it is a myth and how hard you try to create a new perception, the FACT is that people's real-world experience, no matter how anecdotal, consistently demonstrates that Java is MASSIVELY slow than similar apps in C or C++.

    Java is slower. Don't even get me started on C#.
    • Re:BULLONEY!! (Score:5, Interesting)

      by pla (258480) on Sunday October 09 2005, @08:58AM (#13750308)
      (Last Journal: Monday April 03 2006, @07:23PM)
      Don't even get me started on C#.

      I should hope not! Any form of benchmarking of Microsoft's .Net violates the EULA. And we wouldn't want that!

      So when Microsoft declares their interpreted inverse-polyglotic language as "faster" than compiled pure C, just accept it. Best for everyone that way.


      the FACT is that people's real-world experience, no matter how anecdotal, consistently demonstrates that Java is MASSIVELY slow than similar apps in C or C++.

      Well, the linked article contained a number of what I will graciously call "assumptions" (rather than "outright lies") about allocation patterns in C/C++ that simply don't hold true in most cases.

      For example, the parent mentions the old "stack or heap" question... Which no serious C coder would ask. Use the heap only when something won't fit on the stack. Why? The stack comes for "free" in C. If you need to store something too large, you need the heap. But then, you can allocate it once, and don't even consider freeing it until you finish with it (generational garbage collection? Survival time? Gimme a break - It survives until I tell it to go away!). As for recursion... You can blow the stack that way, but a good programmer will either flatten the recursion, or cap its depth.


      And the article dares to justify its "assuptions" by comparing Java against a language interpreter such as Perl. Not exactly a fair comparison - Yes, Perl counts as "real-world", but in an interpreter, you can't know ahead of time anything about your memory requirements. At best, you can cap them and dump the interpreted program if it gets too greedy. Now, some might point out that Java gets interpreted as well - And I'll readily admit that, for doing so, it does a damn fine job with its garbage collection. But if you want to compare Java to Perl, then do so. Don't try to sneak in a comparison to C with a layer of indirection.


      One last point - The article mentions that you no longer need to use object pooling. SURE you no longer need it - Java does it implicitly at startup. You can avoid all but a single malloc/free pair in C as well, if you just steal half the system's memory in main(). Sometimes that even counts as a good choice - I've used it myself, with the important caveat that I've done so when appropriate. Not always. I don't have malloc() as the second and free() as the second-to-last statements in every program I write. And that most definitely shows in the minimal memory footprints attainable between the two languages... Try writing a Java program that eats less than 32k.
      [ Parent ]
      • Re:BULLONEY!! (Score:4, Informative)

        by LarsWestergren (9033) on Sunday October 09 2005, @09:21AM (#13750382)
        (http://www.ki.se/ | Last Journal: Tuesday August 28, @07:06AM)
        The stack comes for "free" in C. If you need to store something too large, you need the heap. But then, you can allocate it once, and don't even consider freeing it until you finish with it

        Or NOT consider freeing it when you forget about it... as the case may be.

        Try writing a Java program that eats less than 32k.

        No problem at all. [sun.com]
        [ Parent ]
        • Re:BULLONEY!! (Score:5, Insightful)

          by pla (258480) on Sunday October 09 2005, @09:35AM (#13750426)
          (Last Journal: Monday April 03 2006, @07:23PM)
          Or NOT consider freeing it when you forget about it...

          Programming takes some level of skill.

          If you "forget" to increment a pointer, it won't have advanced the next time you use it. If you forget to open a file, assuming your program doesn't crash, anything you write to it goes to the bit bucket.

          If you forget a wife' birthday, you'll have a pissed-off wife.



          "Try writing a Java program that eats less than 32k."
          No problem at all.

          Uh-huh... Now do the same thing without needing a special, stripped-down, nearly featureless JRE. I don't need a special build of GCC to satisfy the condition, why did we shift from apples to oranges to make it possible in the Java world?



          And most of these points end up exatly there - Apples and oranges. Java can do better than a few worst-case scenarios in C. Java can fit in a sane amount of memory with special builds. Java can outperform C by-way-of Perl. All nice claims, but self delusion doesn't make for better programmers.
          [ Parent ]
          • Re:BULLONEY!! (Score:5, Insightful)

            by gaj (1933) on Sunday October 09 2005, @09:42AM (#13750452)
            (http://slashdot.org/ | Last Journal: Wednesday December 10 2003, @02:54PM)
            It's not really apples to oranges to use a smaller profile JRE for creating smaller profile programs. The JRE includes libraries and features such as threading and such. Let's see you build a C program that uses pthreads and one or two major libraries and still have your memory use come in under 32K. Remember, apples to apples, right?
            [ Parent ]
            • Re:BULLONEY!! by scharman (Score:1) Sunday October 09 2005, @10:38PM
          • Re:BULLONEY!! (Score:5, Insightful)

            by earthbound kid (859282) on Sunday October 09 2005, @09:44AM (#13750466)
            (http://deadhobosociety.com/)

            Programming takes some level of skill.

            If you "forget" to increment a pointer, it won't have advanced the next time you use it. If you forget to open a file, assuming your program doesn't crash, anything you write to it goes to the bit bucket.

            If you forget a wife' birthday, you'll have a pissed-off wife.

            I'm not about to forget my girlfriend's birthday, because my computer warns me about it three days ahead of time. Similarly, why should we risk forgetting to deallocate stuff from the heap, when we can have the computer do it itself? Yes, programming takes some skill. But we shouldn't start programming using only our thumbs while dangling over a pit of lava, just to up the skill factor needlessly. If we're going to do something more difficult, we need to get a benefit for it. The benefit of not using a garbage collecting language is that your code will probably be slightly faster than the equivalent code in a GC language. But, is that slight performance increase worth the pain in the ass of doing it the manly way? In most cases, not really. But hey, judge for yourself: find the best language for your particular job and forget the rest.
            [ Parent ]
          • Re:BULLONEY!! by LarsWestergren (Score:2) Sunday October 09 2005, @09:58AM
            • Re:BULLONEY!! by Bloater (Score:2) Sunday October 09 2005, @12:43PM
              • Re:BULLONEY!! by maraist (Score:2) Sunday October 09 2005, @05:22PM
              • Re:BULLONEY!! by Bloater (Score:2) Sunday October 09 2005, @07:35PM
              • Re:BULLONEY!! by maraist (Score:2) Sunday October 09 2005, @08:34PM
              • Re:BULLONEY!! by ultranova (Score:2) Monday October 10 2005, @06:21AM
              • Re:BULLONEY!! by Bloater (Score:2) Monday October 10 2005, @06:50PM
              • Re:BULLONEY!! by Bloater (Score:2) Monday October 10 2005, @07:07PM
          • Re:BULLONEY!! by ninejaguar (Score:2) Sunday October 09 2005, @10:18AM
        • Re:BULLONEY!! by Xyrus (Score:2) Sunday October 09 2005, @12:03PM
          • Re:BULLONEY!! by matfud (Score:2) Sunday October 09 2005, @01:44PM
            • Re:BULLONEY!! by Xyrus (Score:2) Sunday October 09 2005, @04:48PM
              • Re:BULLONEY!! by matfud (Score:1) Sunday October 09 2005, @05:23PM
              • Re:BULLONEY!! by WhiplashII (Score:2) Monday October 10 2005, @12:00AM
              • Re:BULLONEY!! by Xyrus (Score:2) Monday October 10 2005, @07:30AM
              • Re:BULLONEY!! by Xyrus (Score:2) Monday October 10 2005, @07:33AM
              • Re:BULLONEY!! by matfud (Score:1) Monday October 10 2005, @12:24PM
              • Re:BULLONEY!! by Xyrus (Score:2) Monday October 10 2005, @08:16PM
        • Re:BULLONEY!! by Chagrin (Score:2) Sunday October 09 2005, @12:15PM
        • 2 replies beneath your current threshold.
      • Re:BULLONEY!! by sjasja (Score:2) Sunday October 09 2005, @10:41AM
        • Re:BULLONEY!! by aaronl (Score:2) Sunday October 09 2005, @12:33PM
          • Re:BULLONEY!! by maraist (Score:2) Sunday October 09 2005, @06:41PM
            • Re:BULLONEY!! by aaronl (Score:2) Monday October 10 2005, @03:54AM
      • Re:BULLONEY!! by Matt Perry (Score:2) Sunday October 09 2005, @11:38AM
        • Re:BULLONEY!! by ctzan (Score:1) Sunday October 09 2005, @01:44PM
          • Re:BULLONEY!! by maraist (Score:2) Sunday October 09 2005, @07:16PM
      • Re:BULLONEY!! by dubl-u (Score:2) Sunday October 09 2005, @12:17PM
        • Re:BULLONEY!! by HuguesT (Score:2) Monday October 10 2005, @06:22AM
      • Re:BULLONEY!! by adrianmonk (Score:2) Sunday October 09 2005, @07:06PM
      • Re:BULLONEY!! by emilper (Score:1) Monday October 10 2005, @02:40AM
    • Re:BULLONEY!! by msormune (Score:1) Sunday October 09 2005, @09:10AM
    • Really? (Score:5, Informative)

      by Mark_MF-WN (678030) on Sunday October 09 2005, @09:25AM (#13750394)
      Really? Can provide a few REAL world examples? Can you name one? Personally, I'm running Azureus and Netbeans right now, and they're not perceptably different from C++ desktop applications like KDevelop or OpenOffice.
      [ Parent ]
      • Re:Really? by Skye16 (Score:2) Sunday October 09 2005, @10:14AM
      • Re:Really? by Timmmm (Score:1) Sunday October 09 2005, @06:06PM
        • GUI by Mark_MF-WN (Score:2) Monday October 10 2005, @12:24AM
          • 1 reply beneath your current threshold.
      • Re:Really? by bani (Score:2) Sunday October 09 2005, @07:10PM
      • Re:OMG LOL!!! by anthony_dipierro (Score:2) Sunday October 09 2005, @04:24PM
      • 2 replies beneath your current threshold.
    • Truth vs Perception by SmallFurryCreature (Score:3) Sunday October 09 2005, @09:37AM
    • Re:BULLONEY!! by Ray Alloc (Score:1) Sunday October 09 2005, @09:38AM
    • Re:BULLONEY!! by hobo sapiens (Score:1) Sunday October 09 2005, @11:17AM
      • Re:BULLONEY!! by hobo sapiens (Score:1) Sunday October 09 2005, @05:59PM
      • 1 reply beneath your current threshold.
    • Dont take Swing GUI apps as an example by steve_l (Score:2) Sunday October 09 2005, @01:48PM
    • Re:BULLONEY!! by Baki (Score:2) Sunday October 09 2005, @01:50PM
    • Re:BULLONEY!! by 91degrees (Score:1) Sunday October 09 2005, @04:10PM
    • Re:BULLONEY!! (Score:4, Interesting)

      by HeaththeGreat (708430) <hborders@mail.win.org> on Sunday October 09 2005, @08:50AM (#13750279)
      What Java apps are you talking about?

      There aren't many professional-grade Java Desktop apps out there, and those that _are_ out there are generally built for maintainability, not speed (Eclipse, Netbeans). I built a Java web client that blew the pants off its older C++ version. The reason Java apps are generally slower is because the Java culture is about maintainence over performance.
      [ Parent ]
      • Re:BULLONEY!! by m50d (Score:2) Sunday October 09 2005, @09:49AM
        • Re:BULLONEY!! by Baki (Score:2) Sunday October 09 2005, @01:59PM
          • Re:BULLONEY!! by jma05 (Score:2) Sunday October 09 2005, @03:50PM
          • Re:BULLONEY!! by hobuddy (Score:2) Sunday October 09 2005, @06:03PM
          • Re:BULLONEY!! by m50d (Score:2) Monday October 10 2005, @02:46AM
        • Re:BULLONEY!! by LnxAddct (Score:1) Sunday October 09 2005, @02:44PM
      • Re:BULLONEY!! by Q2Serpent (Score:2) Sunday October 09 2005, @10:14AM
        • Re:BULLONEY!! by WhiplashII (Score:2) Sunday October 09 2005, @11:39PM
      • Re:BULLONEY!! by KarmaMB84 (Score:2) Sunday October 09 2005, @10:31AM
      • Re:BULLONEY!! by innot (Score:1) Sunday October 09 2005, @10:56AM
        • Re:BULLONEY!! by gbjbaanb (Score:2) Sunday October 09 2005, @01:58PM
      • Re:BULLONEY!! by wft_rtfa (Score:1) Sunday October 09 2005, @03:46PM
      • 2 replies beneath your current threshold.
    • 2 replies beneath your current threshold.
  • As I see it. (Score:4, Interesting)

    by Z00L00K (682162) on Sunday October 09 2005, @08:33AM (#13750223)
    The memory allocation management routines are normally running when the JVM thinks it's best, but as a programmer it is usually possible to predict the best time when to actually take care of the housekeeping. Even if the memory management cleanup takes the same time in both cases Java has a tendency to issue them in the middle of everything. So if I as a programmer does the garbage collection at the end of a displayed page and Java does it uncontrollable in the middle of the page the latter case is more annoying to the user.
  • by expro (597113) on Sunday October 09 2005, @08:33AM (#13750225)
    How many JVMs can you afford to run on your system for different apps, and how can you make sure they are all the right size, the garbage collectors are in an appropriate mode that can keep up with generated garbage, etc. I can run lots of native apps, which in many cases have no need for a significant heap like Java brings into the picture in far less space than a single JVM. A JVM runs much heavier on the system, and when I run Netbeans, it is continuously on the verge of eating my 1.2 GB powerbook alive, in fact I have to frequently restart Netbeans to get memory back. It has a long way to go in real practical terms even if they have theoretical solutions to some of the problems. I am porting my server software away from Java for the same reasons. This is JDK 1.4, and I am about to try it on 1.5, but I don't think there is that much difference.
  • by PepeGSay (847429) on Sunday October 09 2005, @08:37AM (#13750237)
    This article is actually debunking some people's reasons why Java has poor performance. It does little to debunk my actual real world experience that it *is* slow. I'm glad to see that performance has increased alot, but I remember some all (well 90% or something) Java applications, like the original JBuilder, that made me want to claw my eyeballs out when using them. Those apps and other early apps are where Java's performance issues really took hold in many people's psyche.
  • The problem I have is that (Score:5, Informative)

    by bhurt (1081) on Sunday October 09 2005, @08:40AM (#13750249)
    (http://slashdot.org/)
    the people who keep telling me allocation in Java is slow (much slower than 10 instructions) are generally experienced Java programmers. I use Ocaml, so I'm quite aware of how fast a generational garbage collector can be (btw, on the x86 in Ocaml, allocations are only 5 simple instructions). But from all first hand reports I've heard, Java allocation is still slow. It may be faster than C++, but it's still slow.
  • If I had a dime for everytime I heard that.... by ShyGuy91284 (Score:2) Sunday October 09 2005, @08:48AM
  • Lisp & Smalltalk by GnuVince (Score:2) Sunday October 09 2005, @08:51AM
    • 1 reply beneath your current threshold.
  • First! (Score:5, Funny)

    by Anonymous Coward on Sunday October 09 2005, @08:54AM (#13750290)
    First post here from my Java workstation. Take that!
    • by wheany (460585) <wheany+sd@iki.fi> on Sunday October 09 2005, @12:13PM (#13751135)
      (http://iki.fi/wheany/ | Last Journal: Monday July 03 2006, @01:48PM)
      Oh yeah! Now that you mention it, it really is funny! You see, the article talks about how Java is not as slow as is generally believed, but then the grandparent says that he posted the message using Java! That's not funny as such, but it is when you consider that it's supposedly the first post! And it's funny to think that he might have actually been the first to post the message, but since he was using Java, its slowness caused the message to be actually posted waaay late!

      Too funny!
      [ Parent ]
    • 1 reply beneath your current threshold.
  • The performance red herring (Score:5, Insightful)

    by MarkEst1973 (769601) on Sunday October 09 2005, @09:00AM (#13750313)
    The laws of optimization are:

    1. Make it work.
    2. Make it work well.
    3. Make it work fast

    And #3 is the most interesting... how fast is fast? In an absolute sense, sure, C/C++ will always be faster. But does the end user notice this in a webapp? NO!

    I have a p3 450mhz box running Tomcat/MySql. It serves my local applications fast enough. The server can render the page much more quickly than my browser (on a p4 1.5ghz box) can render it. As a webapp, java on an old machine is plenty fast.

    Java as a desktop GUI is an altogether different story, but I'm not using java on the desktop. This point is moot to me.

    "Fast enough" to not be noticeable. That is the secret of #3. In a webapp, this is easily achieved in java.

  • Interesting, but I doubt it'll work (Score:4, Interesting)

    by vadim_t (324782) on Sunday October 09 2005, @09:01AM (#13750319)
    (http://sheelab.homecreatures.com/)
    The copying collector sounds really fast indeed, but I can immediately see two problems:

    The first one is the need for a huge amount of memory. It would seem that the optimal way of dealing with this is restricting the amount of memory available to the application, otherwise any app can grow to the maximum size allowed by the VM, whether it needs it or not. But this sounds rather crappy to me, now every developer needs to figure out an right limit for the application.

    The second is that performance is going to suck when garbage collection is performed. The slowdown could be a lot larger than a single execution of malloc/free, especially if virtual memory is taken into account. The unused half of the memory will often be quickly moved to swap by the VM, especially when the process grows to sizes in the order of hundreds of MB. Then GC will force bringing all that back to RAM, while possibly swapping the previously used half to disk. Exactly the same situation as what's described with heap allocation, but a whole lot worse.

    It sounds to me that even if malloc is slower, it's a lot less inconvenient in applications like games, where something that is always slow can be taken into account, but where a sudden run of the GC could be really inconvenient.

    But this is not my area of experience, so it's just what came to mind. Can anybody confirm or refute these suspicions?
  • This is Not News (Score:5, Interesting)

    Here is a paper (PostScript) from 1987 on the topic of GC being faster than manual allocation [princeton.edu].

    The author went on to make a very fast GC that set speed records.

    If you are looking for factual arguments, with performance measurements and so on, just look at his work over the last few decades -- you'll see he did a lot of work in these very practical areas.

    When you see how productive guys like him can be, it makes me wish that some people would just stay alive, and keep working, for a few hundred years more, instead of our typical mortal lifespans.
  • expense comes with the paradigm by jherber (Score:1) Sunday October 09 2005, @09:10AM
  • urban performance? by wiggle.e (Score:1) Sunday October 09 2005, @09:13AM
  • Java memory allocation vs. malloc (Score:5, Interesting)

    by iambarry (134796) on Sunday October 09 2005, @09:29AM (#13750402)
    (http://www.testcompany.com/)
    The article's main point is that Java's memory allocation is faster than malloc, and it's garbage collection is better than cumulative free's.

    However, thats not the problem. All memory in a Java program has to be allocated dynamically. Other languages offer static memory alternatives. Static memory use will be more efficient in many cases.

    The my language is faster than yours argument is inherently stupid. There is no "best" language. You need to use the right tool for the right job.

    --Barry

  • java's overhead by Vladimir (Score:1) Sunday October 09 2005, @09:36AM
  • Fire and forget memory management (Score:3, Insightful)

    by defile (1059) on Sunday October 09 2005, @09:39AM (#13750442)
    (http://michael.bacarella.com/ | Last Journal: Friday November 01 2002, @06:19PM)

    I think automatic garbage collection is great, but _my_ problems with Java's memory allocator have little to do with performance. Rather, it sucks so hard at dealing with out-of-memory conditions.

    Why would you ever run out of memory? If you're on a microcomputer, you tend to have an arbitrary limit anyway. The JDK default is 64MB max heap. This is to prevent runaways, but setting the heap size to some arbitrarily high number has really awful performance characteristics -- god help you if you set the number higher than the amount of RAM you have available, or applications that want to share the machine. There's a whole other rant about how stupid automatic garbage collection is on a timeshared environment (like a server), but it's not the point I want to make.

    The point I want to make: since Java is supposed to run everywhere, you really can find environments where you only have 1 or 2MB of heap to play with. Having constrained resources is nothing new to programmers, they've been dealing with it forever. But Java's allocator combined with constrained resources leaves you with very little wiggle room.

    If you've ever developed a Java applicatoin that manages an in-core cache you might have experienced how fucked you are when you get around to the logic of cache expiration. Ideally you can keep cache forever, as long as a) you know it's not stale, and b) you don't need the memory for something better. A is not a problem in Java, but setting up a system to facilitate B is actually really hard. In C/C++ you can wrap malloc() so that if it fails, you can start dumping cache until it succeeds. The solution is elegant, dare I say beautiful.

    In Java this is totally impossible. When you run out of memory the garbage collector is tripped, and if it can't free anything up it generates an OOM exception. You can't realistically catch these exceptions -- they can bubble up from anywhere at any time. The only place you can catch them is at the top of your program loop and the only good it does there is let you say "OUT OF MEMORY" in a user friendly way before exiting the application -- assuming you have the resources left to even say that of course.

    So how does this effect your cache model? Well, you end up having to guess at how much cache to maintain. Guess too high and your application breaks when it's run in a low memory environment. Guess too low and you're not caching enough, the user experience suffers when it has no reason to. The above scenario is just one example.

    Essentially, the problem is one of prioritized memory. Java gives you no usable way of saying memory allocated for purpose X is fine as long as purpose Y is not short. Designers and apologists can make excuses for why Java doesn't support this and maybe provide a good reason, but those reasons hardly qualify Java as a general purpose programming language.

    Goto also.

  • by dzafez (897002) on Sunday October 09 2005, @09:53AM (#13750509)
    (http://www.dzafez.de/)
    I haven't done anything with java in the last 5 years.
    *everybody.screem("w00t!");*

    I can understand the discussion about memory allocation is legitimate.
    *everybody.agree();*

    Now, saying this would not be the case anymore, so hence java is fast now, would be false.
    *everybody.status = iritated;*

    Writing jevecode does make yu handle a lot of errors...
    *everybody.ask("is this not good?");* ...BY HAND!! IT WILL NOT COMPILE ELSEWAY.
    *some.ask("is this not good?");*

    Maybe there is a loss of speed for handling all those errors as well.
    *FirstHalfOfCoders.grab(stone);*

    C coders don't check for every possible error.
    *SecondHalfOfCoders.grab(stone);*

    Maybe, sometimes, it is ok for a programmer, if from that code, there could
    be errors. While on the other side you buy speed with insecurity.
    *FirstHalfOfCoders.throw(stone);*
    *SecondHalfOfCoders.throw(stone);*
    *me.troll();*

    AND BY THE WAY; I LOVE THE "GOTO" STATEMENT!
    *me.run(away);*
  • by JavaNPerl (70318) * on Sunday October 09 2005, @09:57AM (#13750529)
    I have been doing Java programming for several years now and ported many C/C++ applications to Java, mostly server side apps and I'd say roughly 85% of the time the Java apps outperformed the originals, sometimes by an order of magnitude. Now these were more redesigns than straight ports and the performance gains were not because Java was any better from a performance standpoint, but because design is more of a factor in speed than the language used, especially for larger applications. Usually when I find big performance hurdles that are hard for me to overcome, I find I would have same issues in most languages, so finding a better design is usually the solution. If you are writing small - medium apps or mostly GUI apps then I might have reservations about Java, but for larger apps Java is a good choice.
  • garbage collection and Java and efficiency by idlake (Score:2) Sunday October 09 2005, @10:00AM
  • java is slower than C by petermgreen (Score:2) Sunday October 09 2005, @10:13AM
  • Cool code no longer means fast (Score:3, Interesting)

    by jolshefsky (560014) on Sunday October 09 2005, @10:15AM (#13750592)
    (http://jayceland.com/)

    I've never believed that Java's garbage collection is the root cause for its slowness. I do believe that Java's GC is the cause for its random (and more notably, its inconveniently timed) stutters.

    I think the more general Java slowness comes from the obfuscation of efficiency. In C for instance, ugly code correlated with inefficient code. This is no longer the case for object-oriented programming in general, and it is possibly worst correlated in Java.

    The example in the article provides a starting point for what I'm saying. It's based on the algorithm for a point in some Cartesian graphics system:

    public class Point {
    private int x, y;
    public Point(int x, int y) {
    this.x = x; this.y = y;
    }
    public Point(Point p) { this(p.x, p.y); }
    public int getX() { return x; }
    public int getY() { return y; }
    }

    public class Component {
    private Point location;
    public Point getLocation() { return new Point(location); }

    public double getDistanceFrom(Component other) {
    Point otherLocation = other.getLocation();
    int deltaX = otherLocation.getX() - location.getX();
    int deltaY = otherLocation.getY() - location.getY();
    return Math.sqrt(deltaX*deltaX + deltaY*deltaY);
    }
    }

    The Component.getDistanceFrom() algorithm is considered "good OO style." By using bad style, though, you can break the pretty encapsulation -- and make "bad OO style" -- but get a performance gain:

    public double getDistanceFrom(Component other) {
    int deltaX = other.location.getX() - location.getX();
    int deltaY = other.location.getY() - location.getY();
    return Math.sqrt(deltaX*deltaX + deltaY*deltaY);
    }
    }

    Both code blocks require the math (two subtracts, two multiplies, an add, and a square root) but the original block (unoptimized) also requires the allocation of the Point object and the two memory copies to store the (x,y) location.

    This is a trivial example, but my point is that in a complex Java project, readable and elegant code bears no correlation to fast and efficient code. I believe this is why Java is slow.

    • Re:Cool code no longer means fast by AmishSlayer (Score:1) Sunday October 09 2005, @11:08AM
    • Re:Cool code no longer means fast by kingkade (Score:2) Sunday October 09 2005, @11:13AM
    • Re:Cool code no longer means fast by patio11 (Score:3) Sunday October 09 2005, @11:20AM
    • Re:Cool code no longer means fast (Score:5, Insightful)

      by nerdwarrior (154941) <mattNO@SPAMimperiex.net> on Sunday October 09 2005, @12:05PM (#13751094)
      (http://matt.might.net/)
      Except, you're wrong. You're assuming that the compiler is doing *no* optimization. So, how would a compiler treat the first "inefficient" code example? Let's take a look:

      public double getDistanceFrom(Component other) {
      Point otherLocation = other.getLocation();
      int deltaX = otherLocation.x - location.x;
      int deltaY = otherLocation.getY() - location.getY();
      return Math.sqrt(deltaX*deltaX + deltaY*deltaY);
      }

      Look at the implementation of getLocation(). It's a simple non-recursive procedure. In virtually all compilers, a simple procedure like this is going to be inlined, producing:

      public double getDistanceFrom(Component other) {
      Point otherLocation = new Point(other.location) ;
      int deltaX = otherLocation.getX() - location.getX();
      int deltaY = otherLocation.getY() - location.getY();
      return Math.sqrt(deltaX*deltaX + deltaY*deltaY);
      }

      (Note that to the compiler, all variables are effectively public, so this would not be an access violation.)

      Next, the compiler can (easily) prove (by inspection) that Point(Point) is a copying constructor. As a result, it can replace the use of new Point(other.location) with other.location so long as it proves it will not modify otherLocation, and of course, it can prove this quite easily by inspection of getDistanceFrom(). This results in:

      public double getDistanceFrom(Component other) {
      Point otherLocation = other.location ;
      int deltaX = otherLocation.getX() - location.getX();
      int deltaY = otherLocation.getY() - location.getY();
      return Math.sqrt(deltaX*deltaX + deltaY*deltaY);
      }

      Also, note that getX() and getY() are also simple non-recursive leaf procedures, so the compiler would have inlined them at the same time, so you would actually get code equivalent to this:

      public double getDistanceFrom(Component other) {
      Point otherLocation = other.location ;
      int deltaX = otherLocation.x - location.y;
      int deltaY = otherLocation.y - location.y;
      return Math.sqrt(deltaX*deltaX + deltaY*deltaY);
      }

      Which is now faster that your hand-written "optimization." Note in fact, that you "over-optimized" by replacing otherLocation with other.location twice. If a compiler were actually dumb enough to implement it that way, literally, it would have involved an extra (and needless) pointer dereference to get the value of other.location twice, when it already had it sitting in a register. (Fortunally, most any compiler nowadays would have caught your "optimization" and fixed it.)

      In fact, the compiler wouldn't stop here. It might even rearrange the order in which it fetches x and y to avoid cache pollution and misses. Do you consider that each time you fetch a variable? Most programmers don't, and shouldn't. The moral of the story is that most programmers fail to realize how smart compilers have become. Compiler writers design optimizations with "good coding practices" such as this in mind, and the programmer will be rewarded if he or she uses them.
      [ Parent ]
    • Re:Cool code no longer means fast by p3d0 (Score:2) Sunday October 09 2005, @02:44PM
    • Re:Cool code no longer means fast by dubl-u (Score:1) Sunday October 09 2005, @02:57PM
    • Re:Cool code no longer means fast by matfud (Score:1) Sunday October 09 2005, @03:33PM
    • Re:Cool code no longer means fast by zipwow (Score:2) Monday October 10 2005, @05:34PM
  • Programs (Score:5, Insightful)

    by MoogMan (442253) on Sunday October 09 2005, @10:27AM (#13750645)
    Unfortunately, programs such as Azureus, which run piggishly slow on a 1.2GHz laptop do nothing to dispell these 'performance myths'.
    • Re:Programs by Matt Perry (Score:3) Sunday October 09 2005, @11:51AM
      • Re:Programs by Sycraft-fu (Score:2) Sunday October 09 2005, @03:03PM
        • 1 reply beneath your current threshold.
      • Re:Programs by bani (Score:2) Sunday October 09 2005, @07:36PM
      • Re:Programs by Fujisawa Sensei (Score:2) Sunday October 09 2005, @09:05PM
    • Re:Programs by m0rphin3 (Score:1) Sunday October 09 2005, @02:18PM
    • Re:Programs by glesga_kiss (Score:2) Sunday October 09 2005, @02:49PM
    • Re:Programs by matfud (Score:2) Sunday October 09 2005, @03:51PM
      • Re:Programs by matfud (Score:1) Monday October 10 2005, @11:58AM
      • 1 reply beneath your current threshold.
    • 5 replies beneath your current threshold.
  • What a bunch of FUD (Score:3, Interesting)

    by SlayerDave (555409) <elddm1@gmai l . com> on Sunday October 09 2005, @10:29AM (#13750657)
    (http://www.cns.bu.edu/~elddm)
    From TFA:

    The common code path for new Object() in HotSpot 1.4.2 and later is approximately 10 machine instructions (data provided by Sun; see Resources), whereas the best performing malloc implementations in C require on average between 60 and 100 instructions per call (Detlefs, et. al.; see Resources).

    Wow, that's really shocking. Until you actually look at the Detlef paper [cs.ubc.ca] and realize that it was published in 1994, 11 years ago!! Who knows, maybe things have improved a bit in 11 years. The author certainly thinks Java is getting better; maybe it's possible that C/C++ compilers have improved as well.

    • Re:What a bunch of FUD by sjasja (Score:2) Sunday October 09 2005, @12:10PM
    • Re:What a bunch of FUD by dubl-u (Score:1) Sunday October 09 2005, @12:27PM
    • Re:What a bunch of FUD (Score:5, Informative)

      by Sangui5 (12317) on Sunday October 09 2005, @01:32PM (#13751468)
      Additionally, even if it takes more instructions per call, glibc malloc() will return freshly used "hot" memory to you, while the JVM will return the coldest memory to you--the author of the article admits that this is a problem, but it is worse than they say.

      First, you definately have an L1 cache miss. On a P4, that is a 28 cycle penalty. You also likely have an L2 cache miss. Fast DDR2 memory has an access latency of about 76 ns--call it 220 processor clock cycles. If you miss the D-TLB, then add another 57 cycles. Total cost of your "fast" allocator--305 cycles of memory access latency. 305 is somewhat higher than 100.

      Even worse, if you are on a system with a lesser amount of memory, you may miss main memory entirely, causing a page fault. That'll cost you several milliseconds waiting for the disk. That really really hurts, since 8 milliseconds latency from disk is twenty-four million cycles at 3 GHz. 24 million, 24,000,000, 2.4 * 10^6, no matter how you write it, that's a lot of cycles to allocate memory.

      All of a sudden, 100 instructions to hit hot memory seems cheap.
      [ Parent ]
    • Re:What a bunch of FUD by matfud (Score:1) Sunday October 09 2005, @03:37PM
    • Boehm Demers Weiser GC: 1988, AT&T: 1984 by SimHacker (Score:2) Sunday October 09 2005, @10:43PM
  • Ok, the JVM allocation works by Orycterope (Score:1) Sunday October 09 2005, @10:30AM
    • 1 reply beneath your current threshold.
  • Be prudent in what is Java and what is Native by cpu_fusion (Score:2) Sunday October 09 2005, @10:45AM
  • The issue (for me) is when, not how long by sixpaw (Score:2) Sunday October 09 2005, @10:49AM
  • Real benefit of C++ is not performance... by ivec (Score:2) Sunday October 09 2005, @10:51AM
  • The problem with Java (Score:3, Insightful)

    by Henry V .009 (518000) on Sunday October 09 2005, @11:01AM (#13750789)
    (Last Journal: Wednesday September 28 2005, @12:05PM)
    Garbage collection is nice. It does its job and it does that job well.

    But garbage collection only helps you manage one sort of resource. In C++, the RAII techniques that help you manage memory are good for every resource, from file handlers to database connections. Resource management in Java is not so nice. Often it is quite a hassle.

    Also, if you really want the benefit of garbage collection in C++, simply compile your program using something like the Boehm Garbage Collector.
  • Custom mallocs (Score:4, Insightful)

    by Mybrid (410232) on Sunday October 09 2005, @11:14AM (#13750860)
    (http://www.datarebels.com/)
    It is interesting that the benchmark was done against the standard malloc when I've found that most high performance systems software implement their own malloc and other systems code based upon workload characteristics.

    Which is the point.

    Systems programmers write systems code. There is no one size fits all. There is no silver bullet. Comparing out-of-the-box C/C++ to out-of-the-box Java is a non-starter in my opinion because I've never used out-of-the-box C/C++ for large scale performance applications. What Google did in writing custom systems software is something that cannot happen with Java and is the accepted practice for C/C++.

    Java programmers write applications in a "one-size-fits-all" performance environment. Comparing Java to C/C++ is like comparing apples to oranges.

    Serious C/C++ systems programmers write their own malloc and systems software.

  • Allocating all my RAM is fast, but it's not nice. by Vorlath (Score:1) Sunday October 09 2005, @11:25AM
  • Pick the right tool for the right job by ShipIt (Score:1) Sunday October 09 2005, @12:07PM
  • Give it up already by shaitand (Score:2) Sunday October 09 2005, @12:15PM
  • Java designed for humans, not performance. by Mybrid (Score:1) Sunday October 09 2005, @12:15PM
  • Let's be realistic by localman (Score:2) Sunday October 09 2005, @12:23PM
  • I spend a lot of time with Quantify by mi (Score:2) Sunday October 09 2005, @12:26PM
    • 1 reply beneath your current threshold.
  • BAH. by Wolfier (Score:2) Sunday October 09 2005, @12:27PM
    • Re:BAH. by the eric conspiracy (Score:2) Sunday October 09 2005, @07:37PM
      • Re:BAH. by salimma (Score:1) Sunday October 09 2005, @11:25PM
  • inherently slow? only partly. by markhahn (Score:1) Sunday October 09 2005, @12:38PM
  • What Language is the JVM coded in again? by Secret Rabbit (Score:1) Sunday October 09 2005, @01:02PM
    • Um... by warrax_666 (Score:2) Monday October 10 2005, @03:32AM
      • Re:Um... by Secret Rabbit (Score:1) Monday October 10 2005, @04:34PM
        • Re:Um... by warrax_666 (Score:2) Tuesday October 11 2005, @07:54AM
    • 1 reply beneath your current threshold.
  • C and C++ by vlad_petric (Score:2) Sunday October 09 2005, @01:15PM
    • Re:C and C++ by Anonymous Brave Guy (Score:2) Sunday October 09 2005, @07:40PM
  • CPU intensive code in Java by magoghm (Score:1) Sunday October 09 2005, @01:56PM
  • So why are all websites running Java slow as hell? by nazzdeq (Score:2) Sunday October 09 2005, @03:04PM
  • Article Summary and reality (Score:4, Insightful)

    by radtea (464814) on Sunday October 09 2005, @03:08PM (#13751986)
    Summary: "If JVMs were smart, garbage collection would be fast."

    Reality: "JVMs are mostly very stupid, and you can never be sure what JVM your users are going to use, so in the real world of deployed applications garbage collection performance--and Java performance generally--is a nightmare."

    I am so tired of GC advocates talking smugly about theoretical scenarios. Who cares?. When I can run a Java app on an arbitrary JVM and not have it come to a grinding halt every once in a while as the garbage collector runs--or worse yet bring the machine to a grinding halt because the garbage collector never runs--only then will GC will be useful.

    The weasel-words in the article are worthy of a PHB: "the garbage collection approach tends to deal with memory management in large batches" Translation: "I wish GC dealt with memory management in large chunks, but it doesn't, so I can't in all honesty say it does, but I can imagine a theoretical scenario where it does, so I'll talk about that theoretical scenario that I wish was real instead of what is actually real."

    This is not to say that there aren't one or two decent JVMs out there that have decent GC performance. But having managed a large team that deployed a very powerful Java data analysis and visualization application, and having done work in the code myself, and having had to deal with user's real-world performance issues and having seen the incredible hoops my team had to go through to get decent performance, I can honestly say that up until last year, at least, Java was Not There with regard to GC and performance.

    The most telling proof: my team did such a good job and our app was so fast that many users didn't believe it was written in Java. It was users making that judgement, not developers. Users whose only exposure to Java was as users, and whose empirical observation of the language was that it resulted in extremely slow apps. They didn't observe that it was theoretically possible to write slow apps. They observed that it was really, really easy to write slow apps, in the same way it's really easy to write apps that fall over in C++, despite the fact that theoretically you can write C++ apps that never leak or crash due to developers screwing up memory.

    Every language has its strengths. Java is a good, robust language that is safe to put into the hands of junior developers to do things that would take a senior developer to do in C++. But its poor performance isn't a myth, nor is its tendency to hog system resources due to poor GC. Those are emprical facts, and this article introduces no actual data to demonstrate otherwise.

  • The Least Efficient Can Be The Most Useful by oldCoder (Score:1) Sunday October 09 2005, @03:12PM
  • speed kills by planetfinder (Score:2) Sunday October 09 2005, @03:24PM
  • How about some actual DATA? by happycorp (Score:2) Sunday October 09 2005, @03:44PM
  • Java, It's not fat its big boned. (Score:3, Interesting)

    by pauldy (100083) on Sunday October 09 2005, @03:48PM (#13752266)
    (http://www.wantek.net/)
    This is about as much of a myth as the myth of the earth traveling around the sun. There is a lot more to allocating memory than this article lets on. Psuedocode will always be slower than machine code no matter how you slice it. You can do various tricks to make it seem faster by instruction count at certain things but in the end those same things can be applied to compiled code like c/c++. Most people can accept that as fact and move on using Java where it seems appropriate. Make all the excuses and extraordinary claims you wan tint the end Java is just plain old FAT n slow, anyone in any programming course who has used java can tell you that.

    Oh and it is hard to test out his little theory on the free malloc in C++ because you can't do the same thing in Java. You can try but it will get around to the free part when it gets good and ready and may not attempt the malloc until you use the memory.
  • Linear allocation faster than 'block list search' by master_p (Score:2) Sunday October 09 2005, @04:22PM
  • Java Still Useless To Me by nathanh (Score:2) Sunday October 09 2005, @04:33PM
  • I/o peformance? by cprice (Score:1) Sunday October 09 2005, @04:47PM
  • Java vs. PHP by Heembo (Score:2) Sunday October 09 2005, @05:01PM
  • The difference between malloc and new by exa (Score:1) Sunday October 09 2005, @07:19PM
  • Quantifying the Performance of GC vs. malloc by Ristretto (Score:2) Sunday October 09 2005, @07:46PM
  • There's nothing like comparing apples to oranges.. by Assmasher (Score:2) Sunday October 09 2005, @07:50PM
  • Okay by Trogre (Score:2) Sunday October 09 2005, @07:56PM
  • One fallacy in this article by ardran (Score:1) Sunday October 09 2005, @10:37PM
  • You Never Get a Second Chance by jalefkowit (Score:2) Sunday October 09 2005, @10:52PM
  • Ugh. Not this again by Heretik (Score:2) Thursday October 20 2005, @01:27PM
  • Re:Duh Stack wins whats to agonize over? by nighty5 (Score:2) Sunday October 09 2005, @08:24AM
    • Slashdot IBM? by totallygeek (Score:2) Sunday October 09 2005, @08:28AM
  • Re:Counter arguments (Score:5, Insightful)

    by LarsWestergren (9033) on Sunday October 09 2005, @08:40AM (#13750247)
    (http://www.ki.se/ | Last Journal: Tuesday August 28, @07:06AM)
    You so called counter argument is 6 years old... a lot of it weren't true to begin with, and a lot of things have happened since then.

    In the end though, the MOST important thing is that these days, processor cycles are cheap. Programmer cycles are expensive. Therefore it makes sense to sacrifice a little bit of program performance to get more productive programmers.

    [ Parent ]
    • Re:Counter arguments by Anonymous Coward (Score:2) Sunday October 09 2005, @08:42AM
    • Re:Counter arguments (Score:5, Insightful)

      by Michalson (638911) on Sunday October 09 2005, @09:10AM (#13750350)
      Then use Delphi, or better yet, C#. (or even Python and a few other choices)

      Faster productivity, less bugs, no ram guzzling 5 minute startup. Java isn't the only language that reduces development time, it's just the only one (besides VB) that makes you sacrifice big things to get it.
      [ Parent ]
    • Re:Counter arguments (Score:5, Interesting)

      by mikaelhg (47691) on Sunday October 09 2005, @09:22AM (#13750385)
      Programmer cycles are expensive.

      Indeed. It might be worth (pardon my pun) reiterating what those cycles really are, in regard to application performance.

      In all languages I know of, you get some library functions ready-made, and you need to code some stuff yourself.

      Most performance problems occur in the code you made yourself.

      In my experience, you get most bang for buck when you are able to efficiently allocate your programmer time to a) program a functionally complete draft version, b) optimize those parts which need optimization and c) maintain the program, in a manner which is BALANCED, but biased towards maintenance.

      De facto, you get better balance between those things, and most bang for buck, using languages such as Java, as opposed to languages such as C++, because (say) Java offers a pretty coherent conceptual framework (class libraries) for creating your draft in a maintainable way, provides default access to excellent non-invasive performance measurement tools such as YourKit and JProfiler which let you objectively find out where you need to do performance work.

      This means you can do only the optimization work that is necessary, and create optimized packages which extend the default class library interfaces which means that generally maintenance programmers don't have to put nearly as much work into figuring out how the optimizations affect the draft work.

      It's not perfect, but it gets you more bang for buck, which is what matters to you when you manage resources.

      Not the default developer perspective, I know.
      [ Parent ]
    • Re:Counter arguments by m50d (Score:3) Sunday October 09 2005, @09:45AM
    • Re:Counter arguments by Midnight Thunder (Score:3) Sunday October 09 2005, @10:36AM
      • 1 reply beneath your current threshold.
    • Re:Counter arguments (Score:5, Insightful)

      by aaronl (43811) on Sunday October 09 2005, @12:22PM (#13751177)
      (http://wire-head.org/)
      See, that right there is a huge chunk of the whole problem. If programmers weren't being lazy and arrogant jerks and assuming that nobody cares about how poorly designed and coded their algorithms are, or how blatently horrible their memory usage is, we would have a lot fewer problems.

      I don't care that Java will get there at some point, or that it's better now. I care about whether it actually works right, and right now it does not. It does have too long a startup, most of the UI toolkits are horribly slow, it does not follow native platform UI conventions, and it is just not as nice to use a Java app as it is an equally well written native app. It does take far too memory, especially compared to other languages. Even the cross-platform nature of the code is largely a lie. Different JREs don't support the same things, and many platforms lack a JRE. There are massive differences between the various editions of Java so as to make it useless to try to write something across them. Your Java app written against "Vendor X Version Y Edition Z JRE" should work fine on any other platform with the same version of "Vendor X Version Y Edition Z JRE". That's all you can safely say without a good amount more testing.

      However, most of all, my CPU time and RAM might be cheap, but they are abused every time I use an application written in that mindset. I have memory needlessly abused, and CPU time needlessly wasted every time I run some poorly coded program. That means that I lose time and productivity every time I run your poorly written app. That attitude pisses me off, why we should all squander our system resources so that a few lazy programmers can write some app a little faster and with less effort, rather than doing their job right.

      Programmer cycles are a lot cheaper than making thousands of people upgrade their hardware. I imagine those programmer cycles are a few orders of magnitude cheaper.
      [ Parent ]
    • Re:Counter arguments by Trejkaz (Score:2) Sunday October 09 2005, @05:09PM
    • 2 replies beneath your current threshold.
  • Re:Doesn't poke holes at all (Score:3, Informative)

    by fish waffle (179067) on Sunday October 09 2005, @08:56AM (#13750300)
    But all the examples in the article aren't tested in practise. Maybe the escape analysis the author describes works as advertised. But without actually testing and analysing real code produced and without actual benchmarks the article doesn't proof a thing

    The author is giving you a high-level, greatly edited view of some of the major optimization techniques in use today. The original academic/technical papers on which that is based demonstrate/measure their techniques on various benchmarks.

    One thing the author seems to forget is that you would at least need a fallback mechanism when a method is overridden in a subclass

    This is well-known. Code-patching, on-stack replacement, pre-existence etc are used in production jits to recover from that kind of thing. This paper [psu.edu] has a decent summary of current approaches:
    [ Parent ]
  • good programmers (Score:5, Insightful)

    by willCode4Beer.com (783783) on Sunday October 09 2005, @09:20AM (#13750374)
    (http://willcode4beer.com/ | Last Journal: Thursday May 12 2005, @07:33AM)
    A *good* C++ programmer will probably write code that outperforms the equivalent in Java. A *good* C+ programmer will remember to deallocate all of his objects to prevent memory leaks. A *good* C++ programmer will copy his strings correctly to prevent buffer overflow exploits.

    If you have been involved in developmnent for any reasonable amount of time or worked on projects of reasonable size, you know that *good* programmers are hard to come by. When you add the real world to the picture you find that simple things like garbage collection and a virtual machine can make a mediocre java programmer outperform a mediocre C++ programmer.

    If schools actually learned to produce good programmers, and HR departments learned how to identify them, and job interviews verified them, we wouldn't be having this discussion.
    [ Parent ]
  • Bragging about ignorance by gvc (Score:2) Sunday October 09 2005, @09:34AM
  • Re:Coral cache by gaj (Score:2) Sunday October 09 2005, @09:34AM
  • Re:Counter arguments by Silverlancer (Score:2) Sunday October 09 2005, @09:57AM
  • Re:Counter arguments by junklight (Score:2) Sunday October 09 2005, @10:11AM
  • Re:Not too bad by GuyWithLag (Score:1) Sunday October 09 2005, @10:40AM
  • Re:Counter arguments by dorkygeek (Score:1) Sunday October 09 2005, @10:42AM
  • Re:Not too bad by LDoggg_ (Score:2) Sunday October 09 2005, @10:57AM
  • Re:Java Urban Performance Legends by codepunk (Score:1) Sunday October 09 2005, @11:05AM
  • Re:Java GC is slower but it doesn't matter by matfud (Score:1) Sunday October 09 2005, @02:44PM
  • Real world results (Score:3, Interesting)

    by man_of_mr_e (217855) on Sunday October 09 2005, @02:46PM (#13751819)
    While I agree that in theory, and in labratory conditions, Java is just as fast (sometimes faster) than C/C++, in practice it doesn't usually end up that way.

    The way normal people write code, and the libraries and functions that normal people use, java is slow as snot. I don't care why that is, it just is, and it makes me steer away from Java client applications if there is something that is native or .NET available instead.

    Real world results are different from labratory ones as far as Java is concerned in my book. And that's just my experience.
    [ Parent ]
  • 21 replies beneath your current threshold.