Slashdot Mirror


C Faces Java In Performance Tests

catseye_95051 writes "An independent programmer in the UK (he does not work for any of the Java VM makers) has done a series of direct C vs. Java speed comparisons. The Results are likely to surprise some of the Java skeptics out there. " Author Chris Rijk admits, "This article is not supposed to be an attempt to fully quantify the speed difference between Java and C - it's too simple and incomplete for that," but the results are nonetheless food for thought.

302 comments

  1. FOURTH? by delmoi · · Score: 1

    I read about FOURTH in an assembly book once, mentioned in passing only as a language that had about the same appeal/hype as java.

    What exactly was it? My only guess is that it was supposed to be a Fourth generation language...

    --

    ReadThe ReflectionEngine, a cyberpunk style n
    1. Re:FOURTH? by JonK · · Score: 1
      What is Forth? Well, it's a rather groovy little language (note to FIGgers - I'm not trying to patronise Forth: I've got rather a soft spot for it) - it is not what is commonly understood by a 4GL (language for programming database applications). It's a very small stack-based language - Charles Moore, its inventor and evangelist, was an obsessive minimalist - which has been implemented on just about every microsprocessor going, making Forth code fairly portable. Since it's not much more costly at runtime than pure assembler, this makes it popular in the embedded world, where the ability to move code from one processor family to another is, for obvious reasons, highly valued.

      From the comp.lang.forth FAQ:

      "What is Forth?"

      Forth is a stack-based, extensible language without type-checking. It is probably best known for its "reverse Polish" (postfix) arithmetic notation, familiar to users of Hewlett-Packard calculators: to add two numbers in Forth, you would type 3 5 + instead of 3+5. The fundamental program unit in Forth is the "word": a named data item, subroutine, or operator. Programming in Forth consists of defining new words in terms of existing ones. The Forth statement

      : SQUARED DUP * ;
      defines a new word SQUARED whose function is to square a number (multiply it by itself). Since the entire language structure is embodied in words, the application programmer can "extend" Forth to add new operators, program constructs, or data types at will. The Forth "core" includes operators for integers, addresses, characters, and Boolean values; string and floating-point operators may be optionally added."

      And, from Rather, Colbourn, and Moore: The Evolution of Forth in: History of Programming Languages (HOPL-II), ACM Press/Addison-Wesley 1996.

      "The name FORTH was intended to suggest software for the fourth (next) generation computers, which Moore saw as being characterized by distributed small computers. The operating system he used at the time restricted file names to five characters, so the "U" was discarded. FORTH was spelled in upper case until the late 70's because of the prevalence of of upper-case-only I/O devices. The name "Forth" was generally adopted when lower case became widely available, because the word was not an acronym."
      --
      Cheers

      --
      Cheers

      Jon
  2. Is the max-C really the best set of optimizations? by Lev+Bishop · · Score: 4
    I'm not sure about the set of optimizations he uses for his "max-C" setting, which is supposedly GCC with all the optimization options enabled. For example, he uses -funroll-all-loops, but the info for GCC says:

    `-funroll-all-loops' Perform the optimization of loop unrolling. This is done for all loops and usually makes programs run more slowly.

    Likewise, he doesn't use the -fprofile-arcs or -fbranch-probabilities options which would probably speed up some of the code quite a bit, I would imagine.

  3. Ours does both. I like this. by Wakko+Warner · · Score: 2
    The freshmen courses are all C++, but the upperclass courses are taught mostly in Java. Though it might seem the exact opposite way to do things, I think it's a good idea to get people to wrap their heads around the concept of pointers *before* eliminating the need to worry about them. The upperclass courses focus less on the semantics of the language and more on proper coding style, team coding, and good OO practice -- the *important* stuff, IMO.

    For team coding, Java just makes things easier. I can take home my piece of code and work on it on my Linux box; another person can test the code in Windows or Solaris. The final project can be run on anything. It greatly simplifies things, since you don't have to worry about platform or implementation idiosyncrasies.

    Also, I think it's _REALLY_ not important what language you learn, but the overall programming concepts you retain. Once I knew C++, it was simple to learn Java, Perl, etc. Even Lisp was easy to pick up, once I understood recursiveness. Learning every bit of a language seems a *tremendous* waste of time, to me, especially if it's at the expense of learning how to code properly.

    - A.P.
    --


    "One World, one Web, one Program" - Microsoft promotional ad

    --
    "Remember when the U.S. had a drug problem, and then we declared a War On Drugs, and now you can't buy drugs anymore?"
  4. This is a great discussion by Anonymous Coward · · Score: 3

    As someone thinking of picking up Java and adding it to my set of job skills, I must say that this discussion has been very valuable for me. I think it's fantastic that many posters here seem to loathe Java. As experience has shown me, if someone does the opposite of whatever /. recommends, they'll tend to be quite successful -- where success is defined as actually making a living, rather than shaving two microseconds off an executable's run time.

    If the next generation of programmers are as inflexible and intolerant as the /. bunch, I'm going to be employed for a long, long time.

  5. Re:This is nice, but... by Jordan+Graf · · Score: 1

    Am I the only one who thinks that Sun over did it with all the pluggable look and feel stuff? It's definitely very cool to be able to click a button and have your application switch from Metal to Motif to Win32, but this comes at an enourmous complexity (and presumably speed) penalty. Try running a simple swing program through an analysis tool like OptimizeIt and you'll be horrified about how many classes need to get loaded for even the most simple app. I kind of wish they'd done a straight forward implementation of Metal (Which looks great in my opinion.)

  6. No programmer is perfect. by Wakko+Warner · · Score: 2
    Any language in which a programmer has to manage the memory rather than a garbage collector is doomed to have memory leaks, _no matter how good the programmer thinks he is_.

    Nobody can catch everything, and to assume a "good" programmer won't write code which leaks memory is very naive. Why do you think people are trying to retrofit C and C++ with rudimentary GCs now?

    - A.P.
    --


    "One World, one Web, one Program" - Microsoft promotional ad

    --
    "Remember when the U.S. had a drug problem, and then we declared a War On Drugs, and now you can't buy drugs anymore?"
    1. Re:No programmer is perfect. by Alex+Belits · · Score: 2

      Any language in which a programmer has to manage the memory rather than a garbage collector is doomed to have memory leaks, _no matter how good the programmer thinks he is_.

      And no language -- with or without GC -- can prevent leaks if programmer is not careful about the lifespan of objects. The fact that physical deallocation is done by GC does not mean that progammer automagically becomes capable of removing all references to the object at the right time (or ever).

      Nobody can catch everything, and to assume a "good" programmer won't write code which leaks memory is very naive.

      I can -- as long as I am working on my own program.

      Why do you think people are trying to retrofit C and C++ with rudimentary GCs now?

      They don't. All garbage colloection mechanisms that I have seen for C and C++ are libraries -- they don't affect the language design.

      --
      Contrary to the popular belief, there indeed is no God.
    2. Re:No programmer is perfect. by Wakko+Warner · · Score: 1
      Nobody can catch everything, and to assume a "good" programmer won't write code which leaks memory is very naive.

      I can -- as long as I am working on my own program.

      You must not write large programs.

      Why do you think people are trying to retrofit C and C++ with rudimentary GCs now?

      They don't. All garbage colloection mechanisms that I have seen for C and C++ are libraries -- they don't affect the language design.

      Does it really matter if it's a change to the language spec or just the simple addition of a new "malloc" procedure? It's still retrofitting.

      -A.P.
      --


      "One World, one Web, one Program" - Microsoft promotional ad

      --
      "Remember when the U.S. had a drug problem, and then we declared a War On Drugs, and now you can't buy drugs anymore?"
    3. Re:No programmer is perfect. by Alex+Belits · · Score: 2

      You must not write large programs.

      They are very large -- just modularized well.

      Does it really matter if it's a change to the language spec or just the simple addition of a new "malloc" procedure? It's still retrofitting.

      Of course, it does. The beauty of C (and at some extent C++) is that the lanugage design is not tied to some [crackpot] idea (or fad) of how resources (of whatever kind) must be managed, and libraries can implement whatever they please as long as the language can implement some basic interface to allocators and support structures (as in C) or the same interface plus the idea of objects and methods (as in C++).

      --
      Contrary to the popular belief, there indeed is no God.
  7. Re:Some Schools... by Alex+Belits · · Score: 2

    A universities job is not to learn students how to fix memory leaks (an activity that cannot be avoided by newby c programmers) but to learn them the basic concepts of programming.

    The fact that "leaks" of objects, "forgotten" by sloppy programmer yet referenced by program are harder to detect does not make them go away.

    --
    Contrary to the popular belief, there indeed is no God.
  8. Re:Optimal FFT was not the point by Anonymous Coward · · Score: 1

    One more comment on aliasing: if you tell the MSC that aliasing isn't going to happen (/Oa), the speed of your FFT example improves by about 15%. Since Java does not have any usable pointers, it can always assume no aliasing. With any modern C/C++ compilers on all existing x86 CPUs well-written FP-heavy code will usually be bound only by the FPU performance (the non-FP part is so much faster on x86...). While it is certainly possible to replicate the results in other languages/compilers, it should be practically impossible to beat them by any decent margin. The huge deviation in your FFT results shows that something is badly wrong with the code. Anyhow, an interesting article.

  9. Re:Optimal FFT was not the point by jmv · · Score: 3

    There are some constructs in C that are almost impossible to optimize. Pointer arithmetic is an example. When the compiler cannot tell if two pointers point at the same place, it has to be very careful during optimization. Also, here's an example of what I mean by loop unrolling having an effect: consider these two dot product implementations:

    /* This one is not optimized and looks like the one for the FFT */
    double prod(double *x, double *y, int len)
    {
    double sum=0;
    int i;
    for (i=0;ilen;i++)
    sum += x[i]*y[i];
    return sum;
    }

    /*This function in an optimized version of the previous */
    double prod(double *x, double *y, int len)
    {
    double sum1=0, sum2=0, sum3=0, sum4=0;
    double *end = x + len
    /*this loop is unrolled by 4*/
    while (x end-3)
    {
    sum1 += *x++ * *y++;
    sum2 += *x++ * *y++;
    sum3 += *x++ * *y++;
    sum4 += *x++ * *y++;
    }
    /*this loop computes the remaining (non multiple of four) */
    while (xend)
    sum1 += *x++ * *y++;
    return sum1+sum2+sum3+sum4;
    }

    I have recently used this optimization on my code and found a performance increase of about a factor of 3 (on a Athlon 500). The fist version of the function has three problems:
    1) The loop overhead is very expensive compared to the 2 float operations inside it.
    2) The indexing is ofter more expensive than simple pointer increment (thought not always).
    3) This one is the most important. In the first example, each sum (+=) requires the previous result of the sum to compute. Now, the problem is that the FP ADD pipeline is stalled. The time it takes for each addition is no more one cycle, but the length of the pipeline. In the second example, the use of multiple partial sums prevent that.

    Also, as I said before, a good FFT coded in C can be as fast as the processor is. The Java code can be as fast if it is good, but not twice faster, as in the benchmarks. But because, the FFT code wasn't optimized, the performance difference likely came from the loop overhead.

  10. Re:Optimal FFT was not the point by jmv · · Score: 2

    ...Oops, the post screwed up all the less-than signs in the loops... but it should still be obvious what's missing.

  11. FORTH is dead?!? by caliban · · Score: 2
    maybe you should better tell these guys... :~) (current projects I found at SourceForge)

    • bigFORTH+MINOS
      bigFORTH is a native code Forth for x86 processors. MINOS is a portable GUI library for X11 and Win32, written in object oriented Forth, and includes the form editor Theseus

    • Portable Forth Environment
      the Portable Forth Environment implements the ANSI Forth Standard, it is fully written in C, the newer version has a module concept, and it is fully multithreaded. Autoconf used. Tested in embedded environments.

    • LYFO embedded forth
    • lsFORTH

      Native X86 Linux Forth compiler. Will be ported to other processors eventually

    • PPCFORTH for Embedded PowerPC
      FORTH for embedded PPC (IBM40x supported). Currently written in assembler (ASL dialect). Used for monitor or loading other programs via S-Records



  12. Re:How Java Floating Point Hurts Everyone Everywhe by Anonymous Coward · · Score: 1

    >java's floating point arithmetic is blighted by five gratuitous mistakes

    >My question is, is this analysis and the observations still valid now?

    The current version of the JDK (1.3) provides two math libraries one "fast" and one "accurate."

    Jim

  13. OT but useful info by gunner800 · · Score: 2
    This is off topic, but I think the people interested in this story will find this information useful.

    Two pissy things to avoid if you want C++ code to run really fast:

    1. Multiple inheritance is great for design and code reuse, but very bad for speed. Calling a virtual function can have 5-10 times as much overhead as a conventional call. This is because your program has to look up in a "v-table" to find out exactly which function is actually being used.
    2. Mixed mode arithmetic. I don't just mean floating point vs. integer, although that is very bad too. Don't mix integer sizes in an expression, i.e. unsigned int and unsigned long. Unless space efficiency is a very high priority, the time to convert should be avoided.




    1. Re:OT but useful info by WolfWithoutAClause · · Score: 1
      'Calling a virtual function can have 5-10 times as much overhead'

      It can be much, much higher than that! I set my compiler to -O11 (I knew it was a good compiler cos the optimisation goes upto 11!) and my code was compiled to just 10 bytes!

      It ran in only 10 ms!

      I then changed one line to 'virtual' and it came out to 150K, I started running it yesterday and it still hasn't finished! That just shows how bad C++ is.

      I hear that Java only has virtual functions. That must be slow as a rock! Everyone knows that C is the best language in the world, I can't see why anyone would use this object rubbish. I mean that must be the reason I hear all these software projects keep failing, they're all using Java.

      And as for security, Java's been out for years and we still get viruses! What gives I ask? When are people going to learn?

      --

      -WolfWithoutAClause

      "Gravity is only a theory, not a fact!"
    2. Re:OT but useful info by IkeTo · · Score: 2
      1. Multiple inheritance is great for design and code reuse, but very bad for speed. Calling a virtual function can have 5-10 times as much overhead as a conventional call. This is because your program has to look up in a "v-table" to find out exactly which function is actually being used.

      The v-table is nothing to do with multiple inheritance at all. It only has to do with virtual functions: the v-table tells the C++ program what function to call for the particular type of variable. This is why the "virtual" keyword is there: it get into performance.

      On the other hand, multiple inheritance didn't increase the overhead of function calls for most things--until you use virtual base. At that point you'll have another "base-pointer" to traverse whenever you want to call methods or access members of the base object. But of course, you can have virtual base class even if you only use single inheritance, its the "provision" of multiple inheritance that matters, not the use of it in fact. This is just like the virtual keyword.

  14. Re:Optimal FFT was not the point by jmv · · Score: 2

    results suddenly change about, which happens to be where the array size starts to exceed the Athlon's 64KB level-1 data cache

    AFAIK, the double values (and probably the float) aren't cached in the L1 on the Athlon.

    Also, I think I've found another problem with your FFT: the use of the "sin" function instead of tables. This function is very slow, and it's performance depends a lot on the math library implementation. It is possible that the JVM implementation of the sine was faster.

  15. Surprising that this is surprising by TimTaylor · · Score: 1
    The raw performance differences between C/C++ and, for example, HotSpot have been negligible for some time. Moore's law and clustering have made questions of raw performance irrelevant.

    The relevant questions are all about time to market, scalability (hand-helds to mainframes), networking, security, and quality. We should have benchmarks on these. Java would win hands down.

    Interested parties should check out the JavaLobby and consider joining. There is a very interesting discussion on JSP vs. ASP performance there now.

  16. Re:Java chip by DeepPurple · · Score: 1

    I beg your pardon, FORTH is anything but dead. It has just evolved for example the plugin-and-play ROMs on all your PCI cards are written in a FORTH derivative, the original aim being to achieve platform independence.

    Just because something isn't on view anymore doesn't mean that it doesn't exist.

    -dp

  17. Re:Just a few JVMs running on a box makes it crawl by scode · · Score: 1

    Then take a proper multiple-process JVM and compare THAT with you're native code, and see which one hogs the most resouces...

    You are making a complete unfair comparison.

    --
    / Peter Schuller
    --
    peter.schuller@infidyne.com
    http://www.scode.org
  18. Give me a Java COMPILER! by DamnYankee · · Score: 3

    Java as a language is fine. But Java on a VM just doesn't cut it for real-world apps.

    I am currently developing a product series of WAP servers and gateways. A few competitors have chosen Java and they can support a maximum of 500 simultaneous users, and that with at least 256 MB RAM and 2 to 4 Pentium III 600 MHz+ processors.The C versions of similar products have no problem supporting several thousand users on a single processor 64 MB machine. Java just ain't in the ballpark.(I should also point out that the Java VM's are not very stable and crash frequently.)

    Java's specs as a language are really nice. Why don't we leave this VM stuff to the specialty apps that need it and start using Java as a COMPILED language?

    --

    Life is a tale told by an idiot, full of sound and fury, signifying nothing.
    William Shakespeare

    1. Re:Give me a Java COMPILER! by sjmurdoch · · Score: 1

      You might want to have a look at Toba: "Toba translates Java class files into C source code. This allows the construction of directly executable programs that avoid the overhead of interpretation. Toba deals with stand-alone applications, not applets." at: http://www.cs.arizona.edu/sumatra/toba/ I hope this is of help.

      --
      Steven Murdoch.
      web: http://www.cl.cam.ac.uk/users/sjm217/
  19. Re:It's all about optimization by jsquyres · · Score: 1
    I would have to agree -- it's all about optimization. In addition to good code, you must have a good optimizing compiler (regardless of your language).

    And the fact of the matter is, the author of the article neglected to mention that gcc's optimizer is well known to be horrible.

    Conventional programming wisdom is that "the compiler's optimizer can do far more than you could ever do in your source code". This is an indisputable fact, since the compiler optimizes not only the high-level language (e.g., C), it also optimizes at the assembly level, even taking into account specific assembly instructions for the architecture that you are running on.

    Don't get me wrong -- gcc is a fine compiler. But anyone who knows anything about high performance computing knows and acknowledges that gcc is not used for performance-oriented code. One reason for this is because one of gcc's main goals is to be portable. As an author of portable unix software, I can appreciate how demanding this task is. Making software portable is extremely time-consuming and resource-demanding. Making software high performace is doubly so, particularly across multiple platforms and operating systems. It is extremely difficult to get both high portability and high performance, particularly for something as large and complex (and system-depedant) as a compiler.

    gcc has (rightly, IMHO) chosen to emphasize portability and give reasonable optimization (vs. extraordinary optimization).

    More conventional wisdom -- this time from the "Beowulf" side of the fence -- get your hardware cheap (i.e., x86), pay for good RAM and hard disks, but don't pay for any software except for a commercial compiler. There are several vendors who produce very high quality C compilers for x86/Linux, and there's even at least one freeware effort that has produced a pentium-optimized version of gcc (Mandrake Linux uses this compiler, for example). The difference in real-world performance between code produced by gcc and code produced by a good optimizing compiler can be measured in orders of magnitude.

    So while the rest of his article seemed to be reasonable (although admittedly short and incomplete), I believe that the results are extremely skewed by using gcc as the "base-C" and "max-C" cases. I would like to see the tests re-done with a better compiler.

    Final note: why does it matter how long it takes you to come up with a good set of optimization flags for a C/C++ compiler? By definition, optizations are highly configuration-specific (e.g., OS, architecture, etc.). The fact of the matter is that they can provide substatintial performance improvements. Java, despite the uniformity of VM behavior across platforms, might very well benefit from the same thing (it may only be a matter of time before such specific optimization flags are introduced, anyway).

  20. Re:Java vs ? by earache · · Score: 1
    PASCAL IS NOT A TOY LANGUAGE.

    Besides templates, macros, and multiple inheritence (which can sort of be done using interfaces instead of classes) ... there really isn't an incredible amount of difference between OPascal and C++.

    At least they borland and freepascal have implemented it.

  21. Re:Java is a FAD. by earache · · Score: 1

    The entire MacOS, at one point, was written in Pascal.

  22. Poor tests by BagMan2 · · Score: 2

    I think it's unfair to compare the two languages by using test programs that are algorithmicly identical between the two languages. Any language can translate simple math and array functions into nearly equivalent assembly. The differences between the languages comes from the types of constructs that can be produced.

    While I am only vaguely familiar with Java, I am a seasoned C++ programmer. My understanding is that Java doesn't support pointers. A well designed algorithm will often do things such as walk a pointer through an array instead of indexing off of it. I can't speak for everybody, but most veteran C/C++ programmers I know use pointers extensively to create optimizations in their algorithms that simply can't be simulated with references or other constructs. It's the ability to design these sorts of things that makes C++ a more powerful language.

    I look at Java as little more than a C++ that has been dumbified so a Visual Basic programmer can use it. All that said, I have to agree that the vast majority of program time is spent waiting for external dependencies like SQL servers, hard drives, system calls, etc... As such, Java is likely to produce just as acceptable of programs as C++ the vast majority of the time.

    1. Re:Poor tests by damm0 · · Score: 1

      First off, Java references are VERY different from C++ references.

      In Java, you only get a reference to an object, *ever*. There is no 'real' or pointer objects. This makes the syntax much more managable. Java references are capable of representing a polymorphic object, can be assigned to new objects at will, and compared (as a memory location) with other references.

      Thus, Java references are really more like C++ pointers, and not at all like C++ references, which are almost useless.

  23. Re:Java is a FAD. by earache · · Score: 1
    Borland's (InPrise) C/C-- Compiler is written in OOP Pascal (product name : Delphi).

    Umm no. C++ Builder's compiler is most definitely not written in Pascal. You're confused with the VCL which is largely written in Pascal, but linked as .obj files after compiled with Delphi's compiler. And I'm not certain that is that case in anymore.

    Actually the Borland OOP Pascal / Java objects models are almost identical. You want native Java code try Delphi (loose32) / Kylix (happy penguin and loose32 with qt ). Different language, same model..., faster (?) code.

    It's not the same model, although there are striking similarities; just like there are striking similarities between the VCL and BEOS's APIs.

  24. Re:I think the answer is obvious by blane.bramble · · Score: 1

    I take it you haven't read the article, and probably have no intention of doing so. Go read, then post.

  25. Re:Memory allocation by dne · · Score: 1

    Sure, but the point is that GCC can be used with several different libc implementations.

  26. Re:A good tool can do anything by slamouritz · · Score: 1

    I think I get you point, but seriusly, would you like to assemble a house using a skrewdriver as hammer?

    And I still belive that you never should prechoose a tool for ANY situration, no matter how convenient it is for me to use my favorite programming tool.


    --


    "Theres alotta savages in this town.."
  27. Re:Purpose built processors Re:Wrong... by Drone-X · · Score: 1

    'On traditional processors: probably, but what about the MAJC processor (see article) or Crusoe?'
    Purpose built processors don't usually help. Sure they start off fast, but unless you have a huge development budget (and Intel has a huge budget!) you quickly get outdeveloped and then you are slower.

    Purpose built processors may remain slower than the traditional x86 platforms but that is irrelivant. *If* the Crusoe processor becomes a success and *if* it would have special morphings code for Java then the end-user would experience no difference between traditional and Java programs.

    And isn't that what it's all about?

  28. Java excecution speed actually good by Waltzing+Matilda · · Score: 4

    Most Java VM's are quite good at executing Java code, so the results are not all that surprising.

    Java's biggest problem is in memory requirements. Metadata for classes is frequently much larger in size than both bytecodes and allocated objects. This needs to improve if Java is to become a more mainstream language.

    1. Re:Java excecution speed actually good by costas · · Score: 3

      Yeah, but this test was comparing apples to oranges:
      * C was given the choice of two not-very-good compilers: GCC and MSVC. From experience, I have seen the same code (especially math or array-intensive code) execute an order of magnitude faster when compiled with Kai CC or Portland Group CC. OTOH, Java was using the top of the line compilers and JVM (e.g. MS's JVM is well known to be much faster than even Sun's in Solaris...)
      * Java had the advantage of run-time optimization. If you go to Ars Technica and read up on HP's Dynamo, you'll see how run-time optimization *alone* can give you a 15-20% improvement in speed with *compiled* binaries. Granted, run-time optimization is 'in the box' for the Java platform while, besides Dynamo, C/C++ are stuck without it.

      Even if you dismiss the run-time optimization advantage as an integral part of the test, the choice of compilers *did* have a speed effect...

      At any rate, I *am* a Java fan --I am just curious to see some true, fair benchmarks.

      engineers never lie; we just approximate the truth.

    2. Re:Java excecution speed actually good by perfecto · · Score: 1
      even C is much faster in terms of compile-run-test cycles

      use jikes. i disagree anyway.

      --
      J Perry Fecteau, 5-time Mr. Internet
      Ejercisio Perfecto: from Geek to GOD in WEEKS!

    3. Re:Java excecution speed actually good by perfecto · · Score: 1
      Yeah, this is really hard to believe. Last time I did anything with Cygwin on Windows (compile Jikes!) the Cygwin binary was much slower than the MSVC one.

      i think that's because you have to do all the optimizations yourself in cygwin! have you seen the size of the binaries it makes?!?! that's why i switched to free borland c++!



      --
      J Perry Fecteau, 5-time Mr. Internet
      Ejercisio Perfecto: from Geek to GOD in WEEKS!

    4. Re:Java excecution speed actually good by pivo · · Score: 1
      jikes -depend compiles each file referenced by the file it's compiling no matter weather that file needs compiliation or not. I'm not sure why it thinks it needs to do that, but you're right, when you use that option it's slow. It's not really a fair comparison with javac since javac does not do this.

      My company contributed what used to be the +CSO option (now a default) to jikes, the ability to compile files without compiling all other imported files. It will compile imported and other dependent files that don't have associated .class files however. It's not perfect, but I can compile my 3000 files in about 10 minutes, something that would take javac over an hour.

    5. Re:Java excecution speed actually good by axlrosen · · Score: 1
      OTOH, Java was using the top of the line compilers and JVM (e.g. MS's JVM is well known to be much faster than even Sun's in Solaris...)

      This test wasn't using MS's JVM, it was using Sun's and IBM's...

    6. Re:Java excecution speed actually good by norton_I · · Score: 2

      I think (hope!) some of the newer JVMs are better, but no, early JVMs used mark and sweep. This is one of my main complaints about Java -- the hype has always far exceeded the technical capabilities. Even still, I think Java's (or Java implemntation's) memory management is lagging.

      There are a lot of eveidence to show that GC whould outperform manual memory management, especially in firm-realtime applications such as multimedia applications (hard realtime systems generally do no allocation at runtime). Basically, GC allows collecting memory to be defered out of a critical loop, or to be scheduled seperately from critical processes, while free() has to be run immediately. Also, malloc()/free() need to do a lot more bookkeeping to know to manage the heap, reduce fragmentation, and so forth. GC can avoid some of this, and amortize the rest over multiple allocations.

      Of course, nothing is going to beat performance on a static/automatic array in C w/o bounds-checking. Java really has no way to support such a beast (even *with* bounds checking). This is one (or many) examples of Java "generalizing" to the extreme, which makes a lot of modern static (compile-time) optimizations impossible. They sort of make up for it with dynamic optimization, but as the article about Dynamo on Ars Technica indicates, they tend to compliment each other, so it would be better yet to have a language like C or C++ + run-time optimization ala dynamo.

    7. Re:Java excecution speed actually good by randombit · · Score: 1

      Metadata for classes is frequently much larger in size than both bytecodes and allocated objects. This needs to improve if Java is to become a more mainstream language.

      Last year I was taking Data Structures, taught in Java. I wrote a Markov chain program. It ran quite well on my dinky little machine (only 64M of memory at the time), with the latest JDK (1.1.8 IIRC). Then I got a score of 10/20 when memory allocation failed on a Sun server with 4 gigs of RAM, using JDK 1.1.6. Probably things have improved significantly since then, what with Java 2 and all, but even so JVMs take a hell of a lot of memory.

      One time, I was running about 20 JVMs on a single machine [each JVM was a client on a diskless machine]. It had 256 megs of RAM and ran FreeBSD, so the machine handled it, but the load was pretty high, and memory was totally full (though it never hit swap AFAIK). But that's a lot bigger memory load than 20 (or even a hundred) processes written in C, C++, Perl, etc would use.

    8. Re:Java excecution speed actually good by pen · · Score: 2
      Agreed. Loading a little tiny proggie or applet will often eat 8MB of RAM. However, don't forget that the entire JVM is loaded.

      In a few years, the JVM and Java programs will probably become so commonplace, that it may be allowed to just lurk in the RAM. Sort of like <gasp> the way IE works in Windows. (Why did you think it opens so quickly?)

      --

    9. Re:Java excecution speed actually good by Waltzing+Matilda · · Score: 1

      If you are just running a single Java applet, this is a huge overhead. However, once you have a couple of Java processes running at once, it's fairly trivial. 8Mb of overhead for 10 processes? That's about 800Kb per process - not a huge amount.

      If you have several applets running, that's true. However, the use of full-blown Java applications is becoming more common, especially since applets become unwieldy after a certain complexity level.

      In this case, several Java applications mean several Java VMs running. While the operating system can share the native code running the VM, all the Java bytecode and metadata resides in the data portion of the process, which typically cannot be shared (although a lot of work is being done on this front).

      Another big problem is Swing. My current Swing application eats 24 megs just showing a fairly simple window. It's the last time I'll use Java for anything GUI until both the language and the UI framework mature.

    10. Re:Java excecution speed actually good by perfecto · · Score: 1
      You are a moron. You must be thinking of DJGPP or something. I routinely have 5k executables for fairly good size programs.

      if you're saying you do this without optimizations then you are either full of shit or you're not programming win32 applications.



      --
      J Perry Fecteau, 5-time Mr. Internet
      Ejercisio Perfecto: from Geek to GOD in WEEKS!

    11. Re:Java excecution speed actually good by Westley · · Score: 1
      Last year I was taking Data Structures, taught in Java. I wrote a Markov chain program. It ran quite well on my dinky little machine (only 64M of memory at the time), with the latest JDK (1.1.8 IIRC). Then I got a score of 10/20 when memory allocation failed on a Sun server with 4 gigs of RAM, using JDK 1.1.6.

      Um, did you tell Java to *use* that much memory? Java has a default maximum heap size to avoid it eating up all the system memory before garbage collecting. There are options to increase this, however.

      Jon

    12. Re:Java excecution speed actually good by garver · · Score: 2

      Java's requires more memory simply because you are loading a Java Virtual Machine.

      • You have to bring in the overhead of another operating system environment. Imagine loading another instance of Linux every time you had to launch a program.
      • When a JVM is launched, the maximum amount of memory it can use is set. Since the JVM uses garbage collection, it will eventually use all of this memory, whether it needs it or not. Most JVMs don't clean up after themselves until they have used up most of their available memory. This way garbage collection is more efficient since it is done less often.
      While Java's program code can be larger, I think it is only a small part of the memory usage most people see. Personally, I want a JVM that will only use as much memory it needs plus a "buffer" so it doesn't have to garbage collect everytime I free something. It would probably just need to garbage collect every few seconds whether it needed it or not. It would sacrifice some performance for memory; therefore, it would be best of the client side and useless on the server side. I missing an existing one that does this?
    13. Re:Java excecution speed actually good by BeerSlurpy · · Score: 1

      Java uses two methods to garbage collect. One is to garbage collect methods that are not directly referenced by anything. This is actually very efficient and doesnt hurt programs.

      The other is much less efficient and it removes objects that are reffered to only by objects that have no refernces. For example, lets say that you have a btree in which all the nodes reference back to the node at the top, and there is a reference to that node somewhere in your code. When you declare that reference null, the jvm must determine that all the objects in the tree are no longer referenced.

      This is done via "tag and sweep" in which the whole program is frozen and every reference is followed to its object and that object is tagged, as are all objects referenced by that object. When all references have been resolved and tagged, the remainder are garbage collected.

      Notice that I said that the program stops. This is necessary so that the state of the objects/references does not change while you are performing the check. This hurts performance when it occurrs.

      You cannot force gc to occur however. When it happens is determined by the jvm, not your code.

    14. Re:Java excecution speed actually good by Cyberdyne · · Score: 2
      Java's biggest problem is in memory requirements. Metadata for classes is frequently much larger in size than both bytecodes and allocated objects. This needs to improve if Java is to become a more mainstream language.

      If you are just running a single Java applet, this is a huge overhead. However, once you have a couple of Java processes running at once, it's fairly trivial. 8Mb of overhead for 10 processes? That's about 800Kb per process - not a huge amount.

      I think the biggest issues so far have just been the usual `chicken & egg' scenario: not enough people use Java for normal apps, so nobody writes Java apps since there's no market.

      I must admit, I'm a Java sceptic myself; to begin with, the language was a real pig. The near-instant load-time compilation of Perl knocks Java out of the window; even C is much faster in terms of compile-run-test cycles. However, no doubt that will change in time.

      The result that really surprised me, though, was Cygwin32 beating MS VC almost across the board - running on Windows! WTF?!

    15. Re:Java excecution speed actually good by pivo · · Score: 2

      No Java VM garbage collects every time you free something. Where'd you get that idea? GC happens on a thread a regular intervals or when it's out of memory.

    16. Re:Java excecution speed actually good by pivo · · Score: 2
      even C is much faster in terms of compile-run-test cycles. However, no doubt that will change in time.

      I don't agree. The reason Java compilation is slow is that the standard java compiler, javac, is written in java so you have the overhead of loading the VM, often for each file. Try a recent verion of jikes, an Open Source java compiler written in C++ from IBM. It's at least an order of magnatude faster than javac.

      The result that really surprised me, though, was Cygwin32 beating MS VC almost across the board - running on Windows! WTF?!

      Yeah, this is really hard to believe. Last time I did anything with Cygwin on Windows (compile Jikes!) the Cygwin binary was much slower than the MSVC one.

    17. Re:Java excecution speed actually good by stripes · · Score: 3
      No Java VM garbage collects every time you free something. Where'd you get that idea? GC happens on a thread a regular intervals or when it's out of memory.

      No Java VM doesn't have any defined tome to collect. Diffrent JVMs do it at diffrent times.

      Most have a low pri thread that will GC either whenever it is runable (for GCs that are intrruptable), or when it has waited "long enough", or when "enough" memory is allocated. All JVMs I know of also GC when they are out of memory. Except for the Java subsets that don't GC at all (like SmartCard Java).

      The one time Java doesn't GC as a rule is "when you free something", because it doesn't know when you free anything. There is no free operator. You can assign a pointer NULL, but that won't free the object unless that is the last pointer to it! Running a GC on every NULL (or other!) pointer assignment would be staggeringly expensave. Java could keep a reference count hint with each object (like Limbo does), but that has it's own problems (and advantages). I don't know of any JVM that does.

    18. Re:Java excecution speed actually good by randombit · · Score: 1

      Would you load twenty copies of your kernel? Statically link libc into every program you run? If you feel the need to run more than one JVM on a box, figure out java.security.* and cut it out.

      I didn't write the code, it was provided to us, and I strongly supect that making changes would not have gone over well with the "people in charge".

    19. Re:Java excecution speed actually good by randombit · · Score: 1

      Um, did you tell Java to *use* that much memory?

      4 gigs? Hell no. If it ran on one JVM, with a measly 64 megs of memory in the system, I don't see why it would run out of memory on another machine (with much more avialable), unless the JVM had serious serious problems. The exact same input was used each time, so that's not an issue.

    20. Re:Java excecution speed actually good by Seahawk · · Score: 1

      You say tou cant force gc to occur! What about System.gc()?
      As a programmer you could call this when your program does nothing!

      Off course its not 100% control, but at least you have the option to suggest the vm taht now would be a good time to gc, and thereby minimizing the risk of gc occuring when your doing something time critical

    21. Re:Java excecution speed actually good by pivo · · Score: 1

      What I meant was that the VM does not garbage collect immediately when you free something. "No Java VM" as in, "There is no Java VM that garbage collects every time you free something".

    22. Re:Java excecution speed actually good by Cramer · · Score: 1
      • Imagine loading another instance of Linux every time you had to launch a program.
      That would waste about 4M of memory compared to most VM's need of 32M or more. Please try to keep in mind, JAVA is interpreted therefore it will always be slower than native instruction code -- some people will argue a few percent doesn't matter, but those are the same "idiots" who want the entire computer world to be text based (an "int" passed between programs as ascii text.)

      VMs don't always have a "max memory" setting. Neither Netscape nor IE have any place to specify the maximum memory the VM is allowed to eat -- it'll eat all the memory the machine has and then crash. If you invoke a runtime VM from a command-line then you can specify a max, but it won't necessarily have one if you don't set it.

      Where I work, "we" use far too much java. It's slow (much slower than native C++) and wastes several orders of magnitude more memory. (Plus, JAVA doesn't have direct access to CORBA or ObjectStore.) AND jre's X11 display engine is the most horrid thing I've ever seen -- god help you if it's not displayed locally.
    23. Re:Java excecution speed actually good by SuperKendall · · Score: 2

      I don't agree. The reason Java compilation is slow is that the standard java compiler, javac, is written in java so you have the overhead of loading the VM, often for each file. Try a recent verion of jikes, an Open Source java compiler written in C++ from IBM. It's at least an order of magnatude faster than javac.

      Of course, the reason that Jikes can be so quick is that it doesn't do depenedancy checking by default and so can be a dangerous compiler if used carefully - try jikes -depend sometime to have it do the same things javac does, and it's no longer an order of magnitude faster.

      It becomes a real issue when you're trying to compile Java code from a makefile - if you don't want to generate dependancy files, your only option is to use javac or compile with jikes -depend.

      --
      "There is more worth loving than we have strength to love." - Brian Jay Stanley
    24. Re:Java excecution speed actually good by stripes · · Score: 3
      When a JVM is launched, the maximum amount of memory it can use is set. Since the JVM uses garbage collection, it will eventually use all of this memory, whether it needs it or not. Most JVMs don't clean up after themselves until they have used up most of their available memory. This way garbage collection is more efficient since it is done less often.

      Generational Garbage Collectors try to run a GC sweep after every X K of allocs (where X is about the size of the cache). They are quite a bit faster then most GCs that only collect when memory is critically low (memory accesses in cache are an order of magnitude faster then out of cache references). The downside is they GC more frequently, so rather then being "fast" for five minutes, and then a short pause, they nick you for a few 100ms all the damn time. Of course that is also an upside, they don't feel jerky.

      Generational GC also tends to pack items allocated at the same time (and still live) together, which for many programs increases the locality of reference, and helps a whole hell of a lot if the system is paging.

      I don't know how many JVMs use generational GC, but since it is a 70s Lisp technology, I can't imagine they use something worse. GC hasn't been a red hot research area, but it has had a lot of good work done in the last 20 years (and a lot more before that!)

      I do know many JVMs run GC sweeps periodically if there is idle CPU (get a Java profiler, and check out the activity in the GC thread).

      What the original post was complaining about was the "overhead" with each object. I'm not convinced that exists. I know every object has the equivalent of a C++ vptr (four bytes). Every object type has a virtual function table (possibly shared if it doesn't define new functions, or override any of the parent's), and a small description of the data fields, and the name of the type, and the function names and such.

      That's a lot of crap -- say 400 bytes. Easily more then a simple structure (say a 2D point, 2 4 byte ints). If you have one point object, you probably have 100 times as much memory dedicated to describing the point object (in case you need to serialize it and send it via an RPC or something). But if you have 5000 points, the overhead of the meta data is vanishing low (400 bytes out of 40,400 bytes, 1%). Er, except for the vptrs (4 bytes on most systems), that'll bring it up to 20,400 overhead bytes for 60,400 total bytes or about 33%.

      So for very simple objects Java does have a noticeable overhead. But for less simple objects the overhead is much smaller. If you compare any Java class with a C++ class that has virtual functions the per-instance overhead is identical. The per class overhead is different (with Java almost certainly having more overhead), but the per class overhead isn't interesting. There are not enough classes in most programs to make a difference (and believe it or not, with templates it's far easier to "accidentally" make 1000s of different classes in C++ then in Java).

      That leaves arrays. C/C++ arrays need not have a length stored with them while Java ones do. Java is behind 4 bytes per array on that score. Relevant if you have lots of small arrays, irrelevant otherwise. Except....

      You know C++ does need to know how many elements are in an array so it can call the destructor for each one (it can omit this, if there is no destructor, but I don't know of compilers that do that). So it doesn't beat Java, it ties.

      ...Oh, and C needs the length for dynamically allocated arrays (via malloc) so it can free them again. But it does win on static arrays.

      Personally, I want a JVM that will only use as much memory it needs plus a "buffer" so it doesn't have to garbage collect every time I free something. It would probably just need to garbage collect every few seconds whether it needed it or not. It would sacrifice some performance for memory; therefore, it would be best of the client side and useless on the server side. I missing an existing one that does this?

      Pretty much all of them if you make a thread that calls java.lang.runtime.gc() and then sleeps for a few seconds in a loop. Or even most of them (I think) if you merely have some idle CPU.

    25. Re:Java excecution speed actually good by stripes · · Score: 1

      D'oh! Sorry, we appear to be in violent agreement. Sorry.

    26. Re:Java excecution speed actually good by RobNich · · Score: 1

      True, GCC and MSVC are not considered the very best compliers, but they are by far the most popular compilers.
      Also, while run-time optimization can improve performance quite a bit, so compile-time optimization should improve it. It's very interesting to me how run-time optimization in some cases actually worsened performance.


      --
      Hello little man. I will destroy you!
    27. Re:Java excecution speed actually good by delmoi · · Score: 2

      The result that really surprised me, though, was Cygwin32 beating MS VC almost across the board - running on Windows! WTF?!

      Well, Cygwin with an insain amount of hand-tweaked, unstable compiler optimizations VC++ beat the baseline most of the time.

      --

      ReadThe ReflectionEngine, a cyberpunk style n
  29. Benchmarks misleading - Java vs C by GodSpiral · · Score: 4

    There's a few things they've done that make Java look better than than real world situations.

    1. Medium to big Java apps need 128mb-256mb system RAM to be useable. HotSpot increases memory footprint (uses memory for compiler + bytecode and native code is in memory), but does not enhance every type of app. HotSpot looks great on many benchmarks (small loop intensive apps tested on systems with much memory), but for many apps it slows things down.

    2. By pre-running the code for 1 second to get how many iterations to use for 10 seconds, you're making sure that hotspot and JITs fully kick in, without countin any of their execution overhead.

    3. Contrary to what you might expect, there's no UI in the game of Life benchmark.

    4. The benchmarks are set up to favour run-time optimizations by having function parameters that are constant for long periods of time (ie matrix size)

    Java is just fine when you have tons of memory, but if your users have 64mb or less, go with vb or cpp.

    The benchmarks in the article have completely avoided any JVM/hotspot initialization overhead, as well as sticking to things JIT compilers are good at.

    1. Re:Benchmarks misleading - Java vs C by catseye_95051 · · Score: 1

      Actually, if you look at the notes under the "Inifinite Life" (heavy allcoation/deallocation test), you'll see that in fact the test was NOt run long enough for Hotspot to really 'do its thing."

      When it was run lomnger, the dip totally vanished.

      JK

    2. Re:Benchmarks misleading - Java vs C by catseye_95051 · · Score: 1

      This WOULD be informative, if it were'nt full of assertions that are misinformtation.

      I encourage everyone to look at the actual data and arctectural explainations on Hotspot. Some of it is on java.sun.com, you can find real users reports on javalobby.

      But for what its worth...

      (1) Hotspot in fact works much BETTER on real world apps then benchmarks. Among other thing, reall apops runa lot longer then benchmarks generally do, giving Hotspot more time to tune itself.

      This is a running problem with benchmarking hotspot. There is an article on this issue at java.sun.com that explains the issues and actively ENCOURAGES people to use real-world apps to get a proper feel for Hotspot's true feel.

      (http://java.sun.com/products/hotspot/1.0/README .html)

      It is a touch outdated in that it refers to 1.0 . In aprticualr the "on-stack repalcement" thing is no longer an issue. Noentheless its worth looking at.

      (2) The first JDK that shipped with Hotspot (client) included was JDK1.3 JDK1.3 has DECREAESED startup and over-all memory footprint by something like 6 meg over 1.2 So much for the assertion that Hotspot uses more memory.

      In poitnt of fact the logical "proof" offered for this is nosnenseical: "uses memory for compiler + bytecode and native code is in memory" has been true since JITs, way back in the 1.1.x days. Hitspot actually does NOT compile seldom used methods, unliek the older JITs, tehreby generating LESS code. Hpwever the size of the compield code is not a terribly relevent thing in over-al;l footprint. Meta-data and objects take the vast majority of the space in modern JVMs.

      3) Letting a program run for a decent amount of time better simulates real world apps. How many real apps typically run for 30 seconds or less?? In fact, Chris's benchamrks to a degree cheat Hotspot by NOT running long enough. He comments on this and what it does to the output in the notes under "Infinite Life."

      4) In re No UI in his life test. The point ehre is to comapre the speed of code generated NOT the comaprative speeds of various graphcis libraries. As soon as you start going through the libraries you bring other issues into play. Whetehr or not Swing and 2D are fast enough is an intresting subject, but a different one.

      5) In re "favoring run time optimization"... yiou'll need to explai nwhy you feel this makes adiffference. I dont' see it. Farnkly ythese all do small bnut 'real world" kinds of jobs anbd thereofr seem, to me to pretty accurately reflect some real world tasks.

      In point of fact, the bounded Life test rather seriously favors C/C++ because it invovles intensive array access, which C/C++ doesn't sanity check but Java does. Yo ucna see this when you loo kat thsoe resulrts as comapred to the "Infinite Life" results which are much lighter on array access and much heavier on allocation/deallocation.

    3. Re:Benchmarks misleading - Java vs C by GodSpiral · · Score: 1

      By benchmarking a short loop, you are guaranteeing that all of the code that executes has been converted to native by the JIT or Hotspot.

      That 1 second test run is plenty long enough to get hotspot to see it as "hot" code, and precompile it before it gets benchmarked. I believe the threshold is about 50 code passes before it gets converted to native. These programs should be hitting 100K iterations/second easily.

      I think hotspot and dynamo are great technology. Their strength though lies in their ability to trade off memory consumption in order to improve cpu throughput.

      Some of the techniques used by run-time compilers that aren't available to static ones is the ability to compile several versions of each function (much like a template) for each combination of semi-constant parameters. This eliminates branches and even unconditional jumps, and keeps the Athlons pipelines from stalling.

      Its great technology and it works, and its why dynamic compilers aren't some marketing fluff, and serve a useful purpose, but they need lots of available memory to do their best, and they don't help me run forte on a 64mb wintel machine.

      Much negative sentiment towards java stems from people experiencing nightmarish swap file delays from apps whose native alternatives run smoothly.

    4. Re:Benchmarks misleading - Java vs C by catseye_95051 · · Score: 1

      Oh, I won't argue woith you about memory usage. Thats perfectly legitimate IMO,as far as it goes. Pulling machinery into the run-time by definition has a memory cost. Its worth noting though that much of the memory cost on the meta-data side is actually the reflection information. Static binding wont help that unelss you reduce the degree of reflection possible.

      Still, when people ask me abotu static compierls I DO say that if yo uare going itn oa memory limited environment, where you don't need crposs platform capability (such as in a PDA) there may be some value to that approach.

      In the multi-purpsoe ciomputer world, though, memory has gotten so cheap that a 64meg box counts as a "legacy system".

  30. Mindcraft? by Money__ · · Score: 2
    . . .it's too simple and incomplete for that.

    So it's a Mindcraft test?
    ;)
    ___

    1. Re:Mindcraft? by GooberToo · · Score: 1

      A poor benchmark, on it's own, does not constitute a "Mindcraft test." A "Mindcraft test" is a test created and designed to achive ones goals. As such, the test is specifically biased to meet or exceed one initial objective. I don't belive this was the case here.

    2. Re:Mindcraft? by Money__ · · Score: 1

      I would have to agree with your assesment of the test and it's conditions. This wasn't "Benchcrafted" because it wasn't bias with the expressed desire to produce a controlled result.
      ___

  31. Newer Ver Of Most Programs Is Usually Slower! by pjrc · · Score: 1
    Sure some people use older programs, but think about it. In programs where performance really matters, do you use anything older than two years?

    Yes, usually the faster code is much older than just 2 years back!

    Where I work, most people un-install gnome and use fvwm, because its so much faster.

    When I draw simple low-res diagrams for my web site, I use MacPaint 2.0 (1988) on a 50 Mhz '030 mac, and it's certainly the fastest and most responsive simple pixle-level paint program I've seen, running on 386-class hardware!

    I think any long-time computer user can think of many examples where a newer version of a program ran more slowly than the last, often times much more slowly... and on the flip side of the coin, it seems (at least to me) that a newer version of a program rarely ends up being faster than older versions.

    What actually happens, year after year, is an effort to add new functionality, sometimes very useful, other times bells and whistles. What doesn't tend to happen is an effort to make programs execute faster. Sometimes there is an effort to not hurt performance "too much", but the comparison (when made at all) is between the older version running on older hardware, and the new version running on state-of-the-art hardware, or sometimes even the hardware expected to be on the market when the program comes into wide-spread use!

    Often times the tests of performance are highly subjective, and the subjective decision is made by the programmer (who would have to do a lot of difficult work re-writing his code), or worse yet by a manager, who would have to cost-justify the time and money spent to improve performance without adding new functionality!

    Using gnome as an example, the last two interviews I've read with their developers, someone complained about general slowness. The attitude expressed by the developers was the usual "fast enough". Maybe it is, but it certainly is quite slugish compared to fvwm if all you want to do is run a bunch of xterms, netscape, and maybe a couple other plain X apps.

    1. Re:Newer Ver Of Most Programs Is Usually Slower! by be-fan · · Score: 2

      Really, you use an old mac to do website stuff? Increadible. I just buy new hardware. I am performance obsessed too, but I wasn' talking about a pixel level editing program. Neither was I talking about operating system-level stuff like GNOME. (Wether Linux people like it or not, for all intents and purposes, the DE is part of the OS.) I was talking about the 3D renderers and the Office apps, and the web browsers, and the photo editors and the video editors. The meaty stuff that people use every day. Sure there are those who have powerful hardware, but use older programs for the sheer speed, but unhappily, they are a rare case. My point was that developers know what kind of CPUs their stuff will run on (at least in the mainstream, I don't know about UNIX though) because people tend to run modern programs on new hardware. I am sure that the developer of that plain X app had no idea how powerful a PIII would be or how to optimize for it. But that's okay, because 99% of the time, nobody will use that old X app on a PIII. The point is that the compiler doesn't really have to worry about optimizing for different architectures from the future (in the same instruction set) because the program will rarely be used on those architectures. The post I was responding to thought that dynamic compilation would win out, because when the K8 or K9 comes out, software written for the older CPUs would be optimized better for these new CPUs. A static compiler can't do this, because it can only optimize for CPUs that are known at the time. I was saying that it doesn't matter, because people probably won't be using that app when the K8 or K9 comes out. Even then, the software won't need optimization, because it will have been writtent to run well on an older CPU.

      --
      A deep unwavering belief is a sure sign you're missing something...
  32. What about Java - native? by Seth+Golub · · Score: 2

    It would have been nice if he'd also tested Java compiled to native code (such as with gcj) . He says the the point of his tests is to measure dynamic vs static compilation, so his experiments would be better if that were the only variable. It would also help squash the myth that coding in Java requires using a VM at runtime.

    1. Re:What about Java - native? by Seth+Golub · · Score: 1
      The problem is that ther are no free trial versions of those compielrs.

      Not true. gcj is GPL'd. That's free enough. It was probably just a matter of time, but it would have been more illuminating to compare VM-java vs static-java than VM-java vs static-C++.

    2. Re:What about Java - native? by catseye_95051 · · Score: 1

      In Chris's orginal web page (I don't knwo if it made it into the article or not) he mentions this.

      The problem is that ther are no free trial versions of those compielrs. (hmmm.. wonder why... you'ld think if they coudl live up to their claims they'd want people to try their code in them...)

      If the static Java compiler manufacturers wanted to send Chris a free copy I'm SURE he'd be happy to add those tests. Letting them do the runs ofcourse is pointless as part of the point here is that Chris doesn't work for any of the company's whose products he tested.

    3. Re:What about Java - native? by jilles · · Score: 2

      "It would also help squash the myth that coding in Java requires using a VM at runtime"

      It actually does if you intend to use dynamic loading. In any case, Java without all its interesting features is not very interesting to me. It's not just the language that makes it attractive but also that it is a very safe environment to program in: no crashing software, no memory leaks, array bounds checking, etc. In addition, the standard library coming with Java is very good for productivity since it provides a lot of well designed functionality.

      Java as we know it is not really possible without the VM, and as the article points out quite clearly, there's not much to be gained anyway by compiling statically. I haven't seen any benchmarks where a static java compiler is much faster than a regular VM (not enough to justify accepting its limitations).

      I think this article smashes one myth: Static compilers are slower than dynamic compilers. The C compilers were in a good position here: under development for decades and code they should be able to run well. Yet, despite the novelty of JVMs and despite the fact that the JVM has to do bounds checking on arrays, it delivers comparable performance. The only logical conclusion is that if a dynamic compiler for C were developed it might actually be faster than statically compiled C.

      I agree that it would have been nice if he'd thrown in a static java compiler. My guess would be that there would be no surprises and that its performance would be mediocre compared to the c compilers and the JVMs. Even a static java compiler still has to do bounds checking and thus the static c compilers have an advantage (plus that their implementation can be assumed a little more mature).

      --

      Jilles
  33. Java chip by ch-chuck · · Score: 3

    Patriot Sci. has a Java processor - actually it was a FORTH in Si processor origionally, but was 'retargeted' since FORTH bit the big one and became as relevant as LATIN. I'd like to try one out, since the RTX2010 only comes in (expensive) radiation hardened form.

    --
    try { do() || do_not(); } catch (JediException err) { yoda(err); }
    1. Re:Java chip by HerringFlavoredFowl · · Score: 1

      and what about swift-X from forth incorporated ? Forth for the Winbloze user...
      Forth is anything but dead, the problem is when you usually see it, it's embedded and most embedded "appliances" don't tell you squat about what they are using... (raise you hand if your company files the ID off of your MCU's).

      I can say with confidence that all the instruments from the divison of the company I work for are FORTH. (and the Windows Apps. are written in Delphi, which in my experience runs quite a bit quicker than Micro$oft C apps).

      I love those 4K embedded compilers, just say HELLO to it ;-)

      TastesLikeHerringFlavoredChicken

      --
      TastesLikeHerringFlavoredChicken
  34. Re:A view from a sceptic. by cheezehead · · Score: 1
    Of course it is apples and oranges. Although Java is advancing in the embedded world, it is probably not the best solution for most embedded software projects right now. I also would probably not want to write a device driver in Java.

    On the other hand, I am currently writing a prototype for a system that needs a lot of graphical bells and whistles (for demo purposes). I'm glad I have the Java AWT and Swing that I can use for this. In the past I worked on a project that needed a GUI, and needed to be written in C/C++. Our GUI code was produced by a GUI builder. You really don't want to touch the C-code that those things produce, it is typically a case of "it works, so let's keep our fingers off it".

    It seems to me that software projects do not pay enough attention to the choice of the implementation language. It is often determined by personal preferences, without a proper analysis of the problem.

    As for taking it seriously: it seems to me that the author makes plenty of disclaimers in the article. I think the purpose of his experiment is to see if all the prejudices against Java are justified. At the very least his conclusion should be food for thought.

    --

    MSN 8: Now Microsoft even has bugs in their ad campaigns.

  35. Re:Haiku by Mike+Buddha · · Score: 2

    IF Program equals
    OS or Driver use C
    ELSE Java does fine!

    --
    by Mike Buddha -- Someday the mountain might get him, but the law never will.
  36. Re:Some Schools... by cheezehead · · Score: 1
    Personally I think it's stupid to replace C/C++ with a language that's less used in todays industry.

    I agree. Did you know that COBOL is the programming language that is still used the most nowadays? So, let's bring COBOL back in the universities' curriculum.

    --

    MSN 8: Now Microsoft even has bugs in their ad campaigns.

  37. Re:Java is still not ready. by slamouritz · · Score: 1

    I constantly see people struggling to get their java programs working- a new release comes out, and poof things break
    Sun describes which classes that becomes dated when ever they update the JDK? And are you suggesting that java dont work?(which would be kinda lame, the language works, if somebody has problems. 99% of the cases the problem will be a programmer related one)

    My colleague spent a few days trying to use java app to access a database and do a simple web app. At every step there were obstacles - money, flakiness, etc. In the end, he switched to perl, and he was doing stuff in no time
    Ok, im sad to hear that. J2EE is far more suited for web apps. but ok, youll need to learn the language first. (AND NOT JUST READ SOME FREAKING TUTURIAL ON THE EXACT SUBJECT YOU FIND INTERESTING).. I bet the reason that the process was easier in perl, is simply your colleague has more experince with CGI perl.

    At the moment, Java is good for mobile phones and smart cards. But for other things I'd give it a miss till the third/fourth generation of Java.
    Ok, if you say so..

    --


    "Theres alotta savages in this town.."
  38. Java vs. C speed by kune · · Score: 2

    Benchmarks are HOTSPOT-friendly. The same functions are called again and again.

    The Life game is the only test which requires the garbage collector a little bit, but here C looks not so bad.

    The Fibonacci test is not so important, it proves only that HOTSPOT and the IBM JVM do function calls faster on Athlon. It seems that both C compilers don't do good opimizations here for Athlon. Pipeline stalls might be the cause.

    The FFT C code uses calloc() to create the FFT matrixes. malloc() would be sufficient. For arrays with 2^16 doubles the clearing of half a megabyte needs some time. A for-loop is used for copying data and not memcpy(). The Java code uses System.arraycopy() :-).

    The result is predictable.

    Running current C compilers on an Athlon is also not fair, because both compilers will not produce good code for it. The Visual C++ didn't even had the Pentium specific flags.

    I think that the compiler-based JVMs have gone a long way. I wish some of that developement resources had gone into the C++ compilers of both companies.

    My conclusion: The Java performance penalty is reducing on some platforms. Linux on x86 is one of them, thank IBM. I doubt, that we will see a free JVM with that performance anytime soon.

  39. Re:Memory allocation by Old+Wolf · · Score: 1

    C is a low level language. It is like ASM but with lots of structure that allows for much faster coding. The programmer is supposed to be in tune with his/her hardware, and so be able to write code to best suit it. It is amazing the number of C/++ programmers I see now who do not know the difference between the stack and the heap, or who do not know the mechanics of a function call or a memory allocation.

  40. Re:What I think... by Kanasta · · Score: 1

    Java may be owned by a corp, but it has a good side-effect that it doesn't takes years for a 'standard' to appear. Sun is extending and changing Java as new ideas and problems arise. This is good, as Java probably has a lot more evolving to do.

    On the other hand, there are small problems with objects moving to different packages in new releases, stuff being deprecated already, etc.

    I really wouldn't mind a compiled version of Java. I know it's against Sun's cross platform philosophy, but having a fast version of Java for certain uses would accelerate its acceptance in some new areas.

    Since the bytecode is compatible, we only need each OS to provide a single compiler that converts the bytecode to native code. We could even have this done by the user, and not the developer!


    ---

  41. Applets are important by zipwow · · Score: 1

    I really feel that Applets are the way things are going to have to go. Thin clients running with limited permissions in a secure environment, this lets you do what you need to do.

    Sure, there's "everything you need" in HTML constructs, but you either have to have every step go through your server, which doesn't let you do dynamic things like updating the list of stated based on the country selection, or you have to use some *other* client-side language, all of which have horrible problems in my experience.

    Sure, you could say that applets have bushels of their own problems currently, but in the end, isn't this how we want applications to work on the net?

    Zipwow

    --
    I don't know which is more depressing, that 2/3 didn't care enough to vote, or that 1/2 of those that did are crazy.
    1. Re:Applets are important by supersnail · · Score: 1

      Try this at home.

      Go into your web browsers "preferences" , "options" or whatever menu and TRUN OFF the JVM.

      Then go surfing.

      I personally have my JVM turned off. About once every three or four weeks I get a "cannot run Java applet" message.In most cases this happens when browsing a really cr*ppy looking web site.

      For many valid reasons, time to load, inconsitences in JVMs , piss poor performance, profesionals avaid java applets like the plague.

      Interestingly, while there is a lot of hype about Java servlets, and, they are not inherently evel like applets, a quick survey of top websites will reveal a pretty unanimous consensus.

      OS is linux or solaris.

      Webserver is apache.

      CGI scripts are PHP or Perl.

      --
      Old COBOL programmers never die. They just code in C.
    2. Re:Applets are important by syates21 · · Score: 1

      Interestingly, while there is a lot of hype about Java servlets, and, they are not inherently evel like applets, a quick survey of top websites will reveal a pretty unanimous consensus.

      ..snip.. ridiculously biased results for "top" web sites ..snip..

      I know this has got to be a troll, but what definition do you use for "top" websites. Anything run by andover.net maybe?

      I'm guessing most people consider, oh I don't know say, yahoo.com, microsoft.com, and wsj.com pretty major sites that don't fit so nicely into your few choices.

      And PHP??, puhleeze. I'd be surprised if they have more than single digit market share.

  42. I don't like Java by Broccolist · · Score: 4
    Maybe Java is really popular right now, but personally, I don't like it.

    First, I wouldn't say it has everything one could want in an OOP language. The language feels like watered-down C++: templates (and STL), objects on the stack, const, references, and true multiple inheritance, are all missing from Java, but clearly would be useful. Yes, the absence of these features makes life easier for beginners, but it's painful to work around Java's deficiencies when you know how to use such features.

    Unfortunately, Java isn't really multiplatform, either, unlike what Sun's marketing team would have you believe. Java is multiplatform in the same way that my Super Nintendo ROM is: I can play it on windows, linux, solaris, etc. I need an emulator, of course. Similarly, I need a "Java Virtual Machine" to run my Java bytecode: it's really just an emulator for a platform that doesn't exist. And if the emulator isn't ported to your favorite platform, well, tough.

    But the main thing I don't like about Java is how gratuitously integrated it is. Why should the Java standard library (which is really a platform in itself) be inextricably bound with the Java language? It could easily have been made into a C++ library, since C++ has direct support for all the language features of Java. Then, they could have written the Java language/bytecode interpreter separately, and made it an option to use the Java platform. This would clearly be better for everyone (except Sun): I could use the well-designed Java APIs in my C++ project with no loss of speed.

    The same thing goes for much of Java. Why does Javadoc, a program that generates documentation from comments in your code, have to be integrated with the rest of Java? It could also be used to document C/C++ code, with minor modifications.

    IOW, Sun is trying to lock you into their platform in the same way that MS is with their strange APIs ; except that Sun's method is much more effective. I am sticking with C++.

    1. Re:I don't like Java by Broccolist · · Score: 1
      A well-reasoned reply. Of course, Java has it's good points also (but I don't like it :). A few points I'd like to make, though:

      It's true that templates are _strictly_ necessary only for generic objects that work with primitives. However, some problems can be solved naturally better using them. The classic example is containers: it's impossible to have a generic, non-intrusive container without templates.

      MI is easy to misuse, but it has it's uses. For example, the C++ iostreams library uses it effectively.

      Final is no match for const :). The main use of const is that it allows you to create a constant and non-constant interface. e.g.
      int Read() const;
      void Write(int);
      So, people who have const objects can only read from them.

      As for the 'political' issues, you have good points, and integration to a certain degree is good, but I think Sun takes it too far.

    2. Re:I don't like Java by mikpos · · Score: 1

      Well a language like C (OK, I'm C-biased) would be multiplatform IMO, since it has a compiler written for every platform I've ever seen (though admittedly there will be a platform somewhere without a C compiler, which is annoying). Multiplatform != binary multiplatform.

    3. Re:I don't like Java by Mr.+Nedd · · Score: 1

      Bah. Binary multiplatform is where stuff gets really COOL. I mean, write once, compile anywhere is nifty, but it doesn't even start to approach how cool binary multiplatform is.

      And, really, how meaningful is the fact that there's a compiler for everything? I mean, geez, that makes FORTRAN and Pascal and just about every other mainstream language I can think of is multiplatform.

    4. Re:I don't like Java by Anonymous Coward · · Score: 2

      First, I wouldn't say it has everything one could want in an OOP language. The language feels like watered-down C++: templates (and STL), objects on the stack, const, references, and true multiple inheritance, are all missing from Java, but clearly would be useful. Yes, the absence of these features makes life easier for beginners, but it's painful to work around Java's deficiencies when you know how to use such features. Templates have no use other than creating generic objects whose paramters include primitives. The wrappers for the primitives (int, float, etc.) in Java handle this fairly smoothly. Everything else you can do with templates you can do using object references. I have NEVER seen a good use of multiple inheritance except for pure virtual classes, which java has in interfaces. OTOH, I have seen alot of absolutely disastrous uses of MI. (Microsoft COM) As for const, every heard of the final keyword? Unfortunately, Java isn't really multiplatform, either, unlike what Sun's marketing team would have you believe. Java is multiplatform in the same way that my Super Nintendo ROM is: I can play it on windows, linux, solaris, etc. I need an emulator, of course. Similarly, I need a "Java Virtual Machine" to run my Java bytecode: it's really just an emulator for a platform that doesn't exist. And if the emulator isn't ported to your favorite platform, well, tough. Ah, but the difference is the Nintendo emulator is not designed to be multiplatform. In many respects, Java is. If you know anything about processor architechture and you look at the JVM spec, you see that they went with the simplest machine design possible so that it could be easily implemented on other platforms. Because it hasn't been ported to your favorite architechture doesn't mean it isn't multiplatform. The JVM spec is there for anyone who wants to read it and implement it on any platform they like. BTW, whens the last time you saw a N64 emulator for the Mac or Irix? But the main thing I don't like about Java is how gratuitously integrated it is. Why should the Java standard library (which is really a platform in itself) be inextricably bound with the Java language? It could easily have been made into a C++ library, since C++ has direct support for all the language features of Java. Then, they could have written the Java language/bytecode interpreter separately, and made it an option to use the Java platform. This would clearly be better for everyone (except Sun): I could use the well-designed Java APIs in my C++ project with no loss of speed. Why is stdio.h so gratuitously integrated with C? Or iostream.h with C++? Because by making things standard, it made it alot easier for people to learn the language and write code. You don't have to use iostream.h if you don't want. You don't have to use java.lang if you don't want either (actually, you'd need java.lang.Object, but thats about it)

    5. Re:I don't like Java by Mr.+Nedd · · Score: 1

      "Unfortunately, Java isn't really multiplatform, either, unlike what Sun's marketing team would have you believe. Java is multiplatform in the same way that my Super Nintendo ROM is: I can play it on windows, linux, solaris, etc. I need an emulator, of course. Similarly, I need a "Java Virtual Machine" to run my Java bytecode: it's really just an emulator for a platform that doesn't exist. And if the emulator isn't ported to your favorite platform, well, tough. "

      Um. DUH. How would you make a language that's multiplatform without an interpreter or a compiler for every platform you wanted to run it on?!? If you say java isn't multiplatform, then nothing is, it seems to me.

    6. Re:I don't like Java by Hard_Code · · Score: 3

      "do you even know C++? const in C++ has nothing to do with java's final directive. final is the opposite of virtual in C++."

      The final keyword in Java also serves the purspose of constant declarator for variables. This /is/ what const is used for in C++, right? You /can/ declare constants in Java. Is there something else special "const" does that you are saying Java does not support?

      "In java, in addition to Object, you need a classloader to load your code. And you get no strings, because the compiler has specific syntactic sugar for dealing with strings (why oh why did they hack this into the compiler isntead of just supporting operator overloading?) I'm sure there are more, but its been a while since I hacked java at that low a level."

      If you are griping that VMs are too dependent on the Java language itself...well, tough. Sun created the VM spec FOR the Java language...not as some universal VM and byte code instruction set that anybody could write any arbitrary language on top of (although that is certainly possible). People write Java in Java...they don't write in bytecode, against the VM directly.

      Also, somebody was griping that the standard libraries and default utilites from the Sun JDK were written in Java. Well...DUH. They are Java libraries and tools. They should be written in Java. Java was created for easy cross-platform development...it would be stupid then to write all the libraries and tools in some native language, then have to ALSO port all those on top of writing a VM. With the libraries and tools written in Java itself, all VM writers have to worry about is writing a VM, and presto, the support libraries and tools are all magically available. It would be hypocritical and tragically stupid to write the supporting tools and libraries for platform-neutral Java in some platform-dependent language.

      --

      It's 10 PM. Do you know if you're un-American?
    7. Re:I don't like Java by strobert · · Score: 2

      "The final keyword in Java also serves the purspose of constant declarator for variables. This /is/ what const is used for in C++, right? You /can/ declare constants in Java. Is there something else special "const" does that you are saying Java does not support? "

      uh yeah...I guess you haven't done much C++. const can also be used to make a constant object. an object where only constant methos can be called. it can be quite handy to hand back a reference or pointer to a const object. that way the person can't change the object (it becomes read-only). this is a missing item in Java. you would need to clone the object, but assuming you are dealing with Objects (like if you are deserializing from a DB and caching them, so you need the caller to get a readonly copy), you can't assume clone is available, since String isn't cloanable...

  43. Java is still not ready. by TheLink · · Score: 1

    I constantly see people struggling to get their java programs working- a new release comes out, and poof things break.

    And the thing is, the old release isn't good enough to stick to - you can't say, sod the new release.

    My colleague spent a few days trying to use java app to access a database and do a simple web app. At every step there were obstacles - money, flakiness, etc. In the end, he switched to perl, and he was doing stuff in no time.

    At the moment, Java is good for mobile phones and smart cards. But for other things I'd give it a miss till the third/fourth generation of Java.

    Cheerio,
    Link.

    --
    1. Re:Java is still not ready. by TheLink · · Score: 1

      Java is - write once, test everywhere, and test for every release (because every release is still pretty major, somewhat like Perl 5.0 to Perl 5.6). This is changing tho (and rapidly which is blessing+curse :) ). Things are looking not too bad now.

      My colleague had more experience with CGI perl?
      Nope. IIRC, he didn't even know perl yet! And even if he did, it was because I had just passed him the Learning Perl book.

      Java multithreads are far better than Perl's. That's what I may use it for, with webapps- when I really need em threads.

      However the Linux apache jserv stuff only _recently_ got decent sometime this year. Jserv was a bit strange b4 that... Still has some weirdness but better now. e.g. rarely see java orpan processes. Still dunno why jserv stuff is so much more complicated than say mod_fastcgi.

      Perl is evolutionary, kludgy and arbitrary like English, but somehow many people can easily do stuff with em.

      Maybe most ppls brains are evolutionary, kludgy and arbitrary :).

      Another colleague who likes C++ thinks lowly of English (so I passed him a url to Lojban and he seems to think it's a good idea).

      Cheerio,
      Link.

      --
  44. OK - glad to hear it! Here's another one... by ch-chuck · · Score: 2

    would love to get my hands on Smart Firmware - Imagine switching on your PC, having it boot FORTH from ROM, ala Sun workstations. Sweet. Demo for Linux available.

    --
    try { do() || do_not(); } catch (JediException err) { yoda(err); }
    1. Re:OK - glad to hear it! Here's another one... by friedo · · Score: 2

      My G3 Powerbook does that all the time. It's called Open Firmware. Kinda like a BIOS on steroids.

  45. Re:What language is the JVM written in? by UnknownSoldier · · Score: 1

    someone mod this up as funny.

  46. Who needs portability? by Marcus+Green · · Score: 1

    It would be handy for anyone who wanted to write code that would run on Linux and Windows. This is important if you think that Linux is going to be sucessfull (chuckles) Marcus

  47. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  48. Re:Optimal FFT was not the point by QuoteMstr · · Score: 1

    I hate to be pedantic, but wouldn't:

    struct vec { double x; double y; double z; double w;};

    double prod(vec* a, vec* b){
    return a->x*b->x+a->y*b->y+a->z*b->z;
    }

    be even faster, since it involves no loops at all? You don't have variable-length vectors anymore, but are you going to do dot products in four dimensions, or two?

  49. Re:Optimal FFT was not the point by QuoteMstr · · Score: 1

    Actually, in modern processors, the trig asm ops are faster than a lookup table, and have more precission. To get the accuracy required today with a lookup table, you would have to use megabytes of memory, which is clearly unacceptable.

    You are correct in that it relies upon the implementation, yes.

    He really shouldn't have used any standard library functions at all (except for output).

  50. Re:It's all about optimization by QuoteMstr · · Score: 1

    pgcc produces very fast code, even *gasp* on non-intel platforms. It sometimes generates internal compiler errors, but in this case, simply send in a bug report and either reduce the optimizations or do what you were trying to do another way.

    Also, why are portability and performance manually exclusive? The x86 gcc backend is certainly not suitable for a ppc, and, although large portions of the code are shared, the backend for each processor supported are not, and should be able to optimize heavily for that processor, in the same way that a JVM probably optimizes for the platform it is running on. Much of the optimization can also be done by the frontend, before intemediate code is generated; this does not rely much on the specific backend (and much of the system-specific things can be done by the backend). If this is not the case, and the frontend needs to optimize for one specific processor, there is always the -m option.

  51. You're all too l33t for your own good... by Llama+King · · Score: 1
    The reasons Java is good go hand in hand with the reasons it is bad. They're all noted above (especially the negatives). You can't have your cake and eat it too. What Java loses in performance it more than makes up in other areas and it is still improving. Is a performance advantage of even 10% really that significant when you take into account the exponential rate in which hardware is improving?

    Why does everyone hate Java so much? Is it really based on its shortcomings or is it like a teenager not liking a band as soon as everyone else starts liking it? You're all too cool for Java!

  52. "Game of Life" is a meaningless benchmark by Anonymous Coward · · Score: 1

    Chris Rijk's "Game of Life" benchmark is completely bogus because it only uses a fixed array. Real world applications have to allocate, use and free memory. A realistic benchmark must allocate, use and then free large mounts of memory (more than will fit into cache). A much better benchmark is John Tromp's Fourstones benchmark, which is implemented in both Java and ANSI C.

    1. Re:"Game of Life" is a meaningless benchmark by catseye_95051 · · Score: 1

      Look at Chris's "Infinite life."

      It does exactly what you ask for and Java pummels C a whole lot worse :)

      In general, the clsoer benchmarks get ot "real world' problems, the better Java performs. The mdoern VMs are tuned to watch for and deal with real world situations.

  53. Re:What I think... by warmi · · Score: 1

    Hey, you are one hell of a strange dude ...

    Seriously.

  54. Re:Dynamic Optimization by QuoteMstr · · Score: 1

    C/C++ has dynamic optimization too. It has for a while now; try using the -pg flag sometime and gprof on the generated file. You will be amazed.

  55. Re:Size matters by battjt · · Score: 1

    Actually, because of the memory usage of Java and our under estimation of the bottle necks of our system, we've had our server run on WinNT and AIX wihout a hitch.

    I develop on Linux and deploy on NT all the time. It's a pretty sweet feeling to be able to do that.

    Joe

    --
    Joe Batt Solid Design
  56. My Criticisms of Java... by istartedi · · Score: 3

    ...never focused on the fact that it is slow. It was always the fact that they had to go and invent another language that isn't any better than C or C++. I'm all in favor of cross-platform development, but forcing us all to maintain yet another codebase, in yet another language is just a royal pain.

    If Sun had produced a platform independant C/C++ environment... wow... just imagine. We may never know how good it could have been.

    --
    For all intensive purposes, "whom" is no longer a word. That begs the question, "who cares"?
    1. Re:My Criticisms of Java... by jeremy_a · · Score: 2

      Yep, a platform-independent C/C++ environment would have been great. Except it wouldn't have been platform-independent. C/C++ depend too much on being close to the hardware. Pointer arithmetic, and endian-dependent code come to mind. Use of this type of functionality introduces dependencies on the platform the code is running on.

      Of course, they could have put in some special checks to allow the program to determine what the standards are for the particular platform the program is running on. But C/C++ already does this (#ifdefs) and it is gross. Yes, you can write platform-independent C/C++ code, but you have to be careful to avoid certain language features, and the code tends to be a bit difficult to maintain.

      Instead, Sun chose to start with a C/C++ish base, and take out a lot of the error-prone constructs (including those which cause platform dependencies). I have found that these constructs are rarely needed: occasionally it would be nice to use some of the "missing" features (I'd be especially happy to have enums back), but in nearly all cases, thinking about the problem for an additional 5 minutes will result in a solution that works just as well, and in most cases the code comes out a bit cleaner in the process.

      I'm not saying that Sun did a perfect job coming up with Java. But I will say that for platform independence, Java is much better than C/C++. I'm not just talking about the basic language constructs either: JDBC (for cross-platform, multi-database SQL), Servlets (for cross-platform, multi-web-server CGI-type programs), and other APIs greatly simplify development for server-side applications. I won't speak on the client-side, since I haven't worked as much on that end of things (although the work I have done tells me that I would much rather develop a GUI in Java than some other language, especially if it has to be cross-platform).

  57. Javascript: True Heir of Hotspot Technology by Baldrson · · Score: 2
    First some data on trends in demand for language skills from Randall J. Burns (www.outlander.com) extracted from www.dice.com:

    As of 8/14/99 the ratio of Javascript demand to Java demand was .304 and as of 4/6/00 it was .331

    Since the dynamic optimiazation of Hotspot is actually in the lineage of dynamically typed languages (Smalltalk, CLOS, Self, etc.) it is poetic justice that the most widely deployed programming language, Javascript, is not only of that lineage, but it is overtaking Java -- the language that made dynamic optimization fasionable despite its less-dynamic heritage of Object Pascal and Objective C.

  58. Re:Java is a FAD. by Betcour · · Score: 1

    Well - what to do when you have to hire programmers that only know C because they were all trained into it by using Unix and Winblows ? You have to switch to C. This is not because it is the best language, it is because of the market... in the IT industry, the winner is rarely the best products. Can you say "Microsoft" ?

    Don't forget that before Windows came out people were still using all kinds of languages. When MS-DOS was king, plenty of guys used Turbo Pascal to code, as well as assembler.

  59. Re:Kernel times by QuoteMstr · · Score: 1

    If the code spends most of its time executing system calls, why not use something easier and faster to develop in than Java, such as Python, Perl, Tk, or Pike?

  60. you've got to be kidding by muchandr · · Score: 1

    Java has no asynchronous networking - every time you make a networking call, you block the thread that made it. I can't think of a less suitable language for network server programming than Java.

  61. Re:What I think... by perfecto · · Score: 1
    It is also multiplatform... we all know about that.

    this is important with regards to server-side java. i build on my nt station and just drop in the jars on the production hp-ux server. I LOVE THAT. plus the fact that i can use my classes across various different application servers is a big plus. we're using the same business logic that we use as our gui client application. they say java doesn't live up to the hype but it definitely lives up to the portability and scalability hype! java is very powerful in this arena. i plan to use it for years to come.



    --
    J Perry Fecteau, 5-time Mr. Internet
    Ejercisio Perfecto: from Geek to GOD in WEEKS!

  62. Re:Kernel times by greg_barton · · Score: 1

    Here's the link: http://java.sun.com/aboutJava/communityprocess/jsr /jsr_051_ioapis.html

  63. Re:Kernel times by norton_I · · Score: 2
    Actually I always thought that while Java was OK for network client programming, it sucked for server programming due to the mentioned lack of non-blocking IO, as well as the lack of true destructors (finalize doesn't) which makes resource management impossible to do in an OO fashion.

    C doesn't have any particularly aesthetically pleasing IO libraries for this, primarily because by the time network programming becase so ubiquitous that better frameworks were needed, much new development had moved to C++. For an example of an extremely well designed C++ networking framework, see the ACE project which supports many different single and multi-threaded programming models in a portable fashion while still allowing you to use high-performance features (such as asynchronous IO) that are not supported on all platforms if you want to.

  64. on Linux: Sun JDK 1.2.2 vs 1.3 vs IBM by tau_ · · Score: 1

    Thanks for your efforts benchmarking Java - it was very interesting to me, and I've been thinking of doing similar benchmarks myself. You beat me to the punch!

    I ran your code through some tests on my Linux laptop (Mobile Pentium II 400MHz, 128 MB RAM, Red Hat 6.2) using Sun's (Blackdown) JDK 1.2.2 and the 1.3 preview releases from Sun (utilizing HotSpot) and IBM (with their high-performance JIT).

    Overall results: compared to un-optimized GCC baseline, IBM's JVM ran 22% faster (while full GCC optimization was only 17% faster than the baseline!). Sun's "stable" 1.2.2 release was 72% slower, and the 1.3 preview (with HotSpot) 17% slower. Interestingly enough, the 1.3 classic JVM was 5 times slower than the 1.2.2 release, so there's probably a huge amount of debugging code in the preview release. Full release might be a totally different story.

    Anyhow, bottom line is that the IBM 1.3 JVM runs faster than C, given the type of code in the benchmarks - which, incidentally, is probably algorithmic optimization wise pretty much like most code out there: written in a hurry, and "good enough".

    --
    Ask a silly person, get a silly answer.
  65. Re:Java vs ? by muchandr · · Score: 1

    Yep. Never understood the JVM, which is essentually an arbitrary definition of a stack
    based processor that happens to rub every modern
    RISC CPU the wrong way. Why not use the AST for executable format instead of some arbitrarily
    chosen instruction set with no connection to reality?

    Pascal is a toy language, but I remember Turbo Pascal being the most wicked PC compiler by far for a while. It did really evil things, but the generated code kicked the crap out of contemporary C compilers.

  66. Re:Jikes is NOT faster than Javac by pivo · · Score: 1

    The product I work on has over 3000 .java source files and various other non-java compilation related activities interspersed in the build process. We did have solution similiar to what I imagine your "ant" is like, but for us jikes is still faster.

  67. mixed int float hack by muchandr · · Score: 1

    does not apply to CPUs which have a special fully
    pipeling int-float conversion instruction like SPARC, otherwise hell yeah. Even consider float loop iteration counters...

  68. Re:Too good to be true by prizog · · Score: 1

    A faster VM would certainly help, and perhaps better algorithms in their painting and event dispatch schemes.

    Heh, painting algorithms.... Swing can paint just fine, at 640 by 480 I was getting a full 3 FPS on a simple 2d app (I had to draw about 50 circles of average radius 5, onto a black background).

    And that's why Swing is worthless. Because you can't even write a turn-based space strategy game in it.


    -Dave Turner.

  69. Re:Optimal FFT was not the point by mikpos · · Score: 2

    Note that C now has a "restrict" type qualifier, specific to pointers, which addresses the very optimisation problem you describe. If a pointer is restrict-qualified, it is a hint to the compiler that the objects pointed to by that pointer cannot and will not be referenced by any other pointer.

  70. Haiku by 575 · · Score: 2

    Test C and Java?
    They fit not in the same mold
    Apples, Oranges

    1. Re:Haiku by Frymaster · · Score: 1

      karma whore am I thus, I steal a poet's muse... moderate to 2

    2. Re:Haiku by Frymaster · · Score: 1
      ... and forget to use my tags....

  71. Re:Kernel times by ahodgson · · Score: 1

    That's why the math guys use Fortran ;)

    Seriously, though, C's never been known for even decent math performance.

  72. Where's the use of OO? by Tom7 · · Score: 1

    I didn't check out the source to these tests, if available, but my guess is they don't use very many OO features. (Probably about the same code for C and Java).

    I'm not surprised that java performance can approach C's for for loops on integers. Since the base types aren't Objects, you don't have any of Java's class mechanism overhead. There's a reason that they made these (int, char, etc) not be classes, and that's because without it, performance would be hideous. (Of course, you lose a lot of orthogonality and beauty... too bad.)

    The java class mechanism is cute and easy to learn (with some exceptions), but incurs a lot of overhead because of the way it was designed. Some of this stuff must use runtime checks to make sure the language is still safe (like during downcasts and modifying arrays of objects). No matter how many optimizations you perform, OO in Java will be significantly slower than static languages like C++. And Java without OO is just a dumbed-down (but perhaps more portable) C.

  73. Re:Memory allocation by dvdeug · · Score: 1

    Sorry, I did mean 2.96. I think they are planning to go directly to 3.0, but I'm not sure.

  74. Re:Memory allocation by Ben+Hutchings · · Score: 1

    There is no standard C library under Win32. (However, the Microsoft C/C++ library is sort of standard under Windows CE.)

  75. Re:It's all about optimization by logicTrAp · · Score: 2

    Actually, I believe Mandrake no longer uses pgcc because of the instability (someone correct me if I'm wrong). If pgcc barfs on you during compile, that's one thing. If it causes wrong answers or segfaults during program runtime, that's completely another (in response to another poster).

    Your comments about gcc tho are pretty much on the mark, although I was under the impression that on x86 gcc was a decent optimizer.

  76. Another Java Comparo by steveoc · · Score: 1
    I recently had to take part in a serious look at Java for creating radar displays (as opposed to C - motif / GTK / Qt)

    Apart from the obvious memory footprint and CPU overhead problems - java did not come anywhere close to GTK for the actual problem at hand.

    90% of our displays will be running on remote Xservers over 100mbps links, and Java's lowest-common-demoninator approach to graphics means that the whole screen gets updated as 1 big pixmap refresh each time through the loop. Some of our displays need to do 5-6 fps over 100mbs LAN connections on 1024x768 8bit displays, and Java cannot acheive that using swing.

    For remote displays, Java is not there yet.

    Having said that, we got good performance using Java-GTK bindings, and writing the demo application in a totally non-swing fashion. But then again, python-GTK looked better all round (faster, leaner, easier to read, etc).

    In the end, we are going all C/C++ using Motif, for politcal reasons, (adaptability of all the old codebase ...) but GTK or Qt is not out of the game .. yet.

    Btw - we did not get any measurable difference between Qt and GTK. GTK was generally a bit quicker and leaner in most cases, but required more code than doing the same thing in Qt. For some other things Qt was quicker and leaner.

    1. Re:Another Java Comparo by catseye_95051 · · Score: 1

      Remote X performance is a known problem. Its not a question of the speed of the lagnuage/JIT though but of the way the 2D libraries were implemented.

      There are people workign on this. In teh mean-time, there are thinsg you can do to imrpove your remote X performance. Take a look at the document at:

      http://java.sun.com/docs/books/performance/1st_e dition/Additional_Material/additional_mate rial.html

  77. Kernel times by sql*kitten · · Score: 4
    One area in which C does not offer significant benefits over Java is in the area of network server programming, where the code spends most of its time executing system calls, rather than processing logic in userland.

    The results of these numeric tests surprised me, but I'd like to have seen Watcom/Borland C compilers used, as both have a reputation for superior numeric code generation to Microsoft's Visual C++ product and GCC.

    1. Re:Kernel times by randombit · · Score: 1

      The results of these numeric tests surprised me, but I'd like to have seen Watcom/Borland C compilers used, as both have a reputation for superior numeric code generation to Microsoft's Visual C++ product and GCC.

      From my experience (with Borland, VC++, gcc, and others), Borland doesn't generate really great code (passable, maybe a bit better than gcc, but not amazing). Also, their compiler is buggy (despite these failings I really like Borland's IDEs). VC++ actually generates fairly fast code, at the cost of cutting corners on ANSI compliance (especially for C++). KAI C++ is my favorite compiler: really really fast (3x gcc in some cases for numerical code), and as standards compliant as you can get.

    2. Re:Kernel times by axlrosen · · Score: 1
      Java does not do non-blocking I/O.

      Coming soon - in JDK 1.4 (Merlin) hopefully.

    3. Re:Kernel times by anonymous+moderator · · Score: 3

      One thing I have found is that if you port a mathematical program to java from c, it may actually speed up!

      I remember writing a small test program in c and identically in Java (a couple of syntax changes only). Using IBM's jdk with -O made it faster than pgcc with all the optimization flags we could think of!

      Then I rewrote the program in an OO-way in Java, and of course it was slow:)... but it does show that Java isn't nessecarily slower than C for some tasks.

    4. Re:Kernel times by QuoteMstr · · Score: 1

      I do pay attention. Whitespace is also a syntatic element in Perl, Python, and nearly every other programming language in existence save Brainf***.

      The indentation required in Python is very flexable, anyway, and that is the only whitespace-sensitive portion of it. Why don't you want to indent your code?

      Makefiles are whitespace sensitive too. Does that make them evil?

    5. Re:Kernel times by garver · · Score: 3

      One area in which C does not offer significant benefits over Java is in the area of network server programming

      I agree, but with one exception: Java does not do non-blocking I/O. Therefore you have to use tons of threads, at least one, likely two, for each connection. For a server handling thousands of connections, you can see where this gets out of hand. In Linux's case where all threads are kernel level threads, performance is back in the shitter since it has to make a new set of system calls to manage the threads. But of course, you want to use native threads so that you can take advantage of multiple processors.

      If non-blocking I/O were possible, one thread and a huge select is all that is needed. Squid is a good example of a server that can handle thousands of connections using one thread. The cost here is complexity, but the reward is performance.

      I'm not advocating non-blocking I/O. I think Java's approach makes for much simpler and more stable servers, but JVMs must make threading as lightweight as possible while still supporting SMP for performance to compete with C-based servers. I think this means supporting a mix of kernel and user level threads.

    6. Re:Kernel times by AndroSyn · · Score: 1

      This is the way I implemented stuff for ods.org(sorry to plug). But instead of using a java servlet, I wrote a servlet in C using pthreads and a UNIX socket to listen on. The web pages ended up being written in php and that just connects to the unix socket to get whatever data it needs. So all in all, anything you can do with a java servlet, you can do just as well with an equivlent design using C.

    7. Re:Kernel times by mbaker · · Score: 1

      You can do non-blocking reads, by using ready() or available() (depending on what stream you're using) and in conjunction with setSoTimeout, this can be quite effective. The writes are a different story, though.

      I use this in conjunction with pools of connections with one thread. Then I use groups of the pools as needed. It's not perfect, but it's an improvement when you're taking a large beating.

      Sun's approach of trying to force threads on I/O is a bit irritating and non-sensical. Any heavily loaded Java application that spawns all of those threads will choke on most hardware.

      I'd also not say that Java is inherently better for network programming, but its default library is simply more robust than C's, which has no inherent networking, very much a framework for it.

      I think they're both quite viable, as are Python and Perl. It's simply a matter of what you need, and when you need it.

    8. Re:Kernel times by mbaker · · Score: 1

      Java actually supports no inherent threading model, in terms of user vs. kernel. Its attitude is more along the lines of "we leave it up to the implementation, so when in doubt, yield()."

      Either way, a purely threaded network solution doesn't scale well for many users, unless you've some less than commodity hardware to run it on.

    9. Re:Kernel times by jilles · · Score: 3

      Of course having multiple threads makes java programs really scalable. On a server you should use servlets. Servlets are actually quite efficient and have load balancing built in. You also avoid the non blocking IO problem this way since the webserver (apache for instance) takes care of the connections and passes the request to the servlet. Servlets are not spawned for each request but typically are reused for new requests. That and the ability to scale to multiple CPU's make that Java is very suitable for server side network programming.

      In my opinion making a program complex for performance reasons only is a bad idea unless we're talking about long term usage of a program. Developers often forget that most of the cost of developing a product goes into maintenance. Java servlets provide you with a nice scalable architecture for serverside programming and it allows you to focus on the parts of the program that provide the functionality you need rather than performance related stuff.

      --

      Jilles
    10. Re:Kernel times by GooberToo · · Score: 1

      I would like to point out that Java supports two thread models. One is an user space implementation, while the second is a kernel space implementation. In a nut shell, as a rule of thumb, user space implemenations scale better on single CPU systems. The sole exception is when the application is not the sole application running on said system. As such, the application gets scheduled, competting with any other applications. What happens is that the process must now divy it's available slices among the many user based threads. The result typically leads to poor performance. Likewise, when you use kernel based threads on a single CPU, you pay the cost of additional scheduling overhead. On a multi CPU system, Linux does have some "thread based" optimizations that allows multiple threads on a multi-CPU system to scale rather well. With current implementations on Linux, there are some gotchas to watch out for. Most of these should be addressed in the 2.3/2.4 kernels.

    11. Re:Kernel times by jilles · · Score: 2

      I should add some stuff to this:
      Servlets are usually more efficient than cgi scripts (such as perl scripts) because they are already running and don't require the overhead of spawning a new process to handle the request. That and jvms such as discussed in the article make that java servlets are a very good alternative for perl (and we are just talking performance here, not all the other nice features of java such as readable source code, OO features etc.).

      --

      Jilles
    12. Re:Kernel times by alexk · · Score: 2

      Ever heard about mod_perl (you know they use it on that obscure slashdot site), FastCGI, or a few other ways to avoid respawning the perl scripts? Beside, I think the original poster was talking about writing servers rather than doing web server programing. I don't see how Java servlets can help you writing something like Apache. In my experience, non-blocking I/O is always more efficient on heavy loads then multithreading. It makes code more complex though.

  78. A view from a sceptic. by BillGodfrey · · Score: 2
    • Java requires a JVM interpreter, C does not require anything of the sort.
    • C is compiled for the target CPUs own machine code. Java needs an extra translation layer at run time.
    • The C integer types change with the CPU, so the "int" type is always the fastest integer about. Java integer types are fixed. (If you want integers of a certain size in C, use the new C99 types.)

    I'm sceptical. I would doubt any review that puts Java even close to C in terms of raw performance of code.

    Sure...

    • Java is (supposedly) easier.
    • Java code runs anywhere a JVM has been written. (BTW, my old 6502 driven 32k BBC micro had a C compiler. Could Java be run on this?)
    • The Java standard library includes a GUI.
    • Java is OO, but C can do OO with structs, pointers to functions and a bit of help from the pre-processor.
    • Java is sexy.

    Bill, embedded software developer.

    1. Re:A view from a sceptic. by catseye_95051 · · Score: 1

      A few thinsg to think about...

      >>Java requires a JVM interpreter, C does not >>require anything of the sort.

      Java does not need to be interpreted in the classic sense, rather it is compield at run-time. Thsi is a common misunderstanding.

      >C is compiled for the target CPUs own machine >code. Java needs an extra translation layer at >run time.

      Actually the opposite is true. Windows code for instacne needs to be compiled for a lowest common denominator (Pentium, multi-processing). The JIt on the other hand looks at the siutatio nat run-time and compiels for that specific situation.
      (Hotspot for instacne generates PII code on a PII, and different code on single and multi-processor machines.)

      >The C integer types change with the CPU, so >the "int" type is always the fastest integer >about. Java integer types are fixed.

      Hardly significant on a modern machine. You're talkign about a few more CPU instructions at most. In fact, since Java expects 32 bit integers, it matches well the machiens in use today by and large.

    2. Re:A view from a sceptic. by chedrick · · Score: 2

      I Strongly agree. Comparing C and Java is "apples and oranges". They are two completly different languages, created for two distinctly different purposes. Some people seem to have forgotten this. There are so many factors that this comparison neglects, it's hard to take the results seriously.

  79. Re:It's all about optimization by astrophysics · · Score: 2

    For an example of loop unrolling in C++ code, see the Matrix Template Library. Pretty cool.

  80. What I think... by pen · · Score: 5
    Speed or no speed, Java is becoming one of those languages... you know what I'm talking about. One of the languages, along with C, C++, etc. Why?

    One of the easiest languages to learn (provided that you understand OOP). I tried C++, and I failed (for now). I tried Java, and it is very easy for me. And for the ease of learning, it gives me immense power. Everything anyone could ever want in a true OOP language.

    It is also multiplatform... we all know about that.

    The only language I can think of that comes close is VB. VB is Windows-only, (well, you have VBA in Office98 on MacOS, OK) and it doesn't give you much of OOP (inheritance, etc.).

    Finally, there are a lot of people out there that will learn a language simply because it's in demand, so that they can get a lot of money paid for writing things in it, and Java wins here as well. Just go do a search on Dice.

    The only thing that bothers me is that Java is now definitely being controlled by a corporation. I'm pretty glad it's not Microsoft, but I'd still rather have it controlled by an unbiased group. OTOH, without Sun's promotion and development, who knows if Java would ever rise to where it is today.

    Let's just hope that the damn applets will fade out... I just hate them! Please correct me anywhere you think I'm wrong - that's what the Reply link is for.

    --

    1. Re:What I think... by rifter · · Score: 1

      FWIW, I find c++ easier for userland tasks than c, mainly because of the routines that were added to make C++, and the way classes work (they are easier to deal with and conceptualize than structs...

      Accourse I could be wrong. Nevertheless, to each his own, like the guy who finds transmission rebuilding easoer than programming his VCR, or a certain famous scientist that found quantunm physics easier than remembering to comb his hair and remember to take his lunch to work.

    2. Re:What I think... by umoto · · Score: 1

      The corporate control of Java has already lead to major problems. For instance, Sun's JDK 1.2.2 on RedHat and Mandrake Linux STILL has a bug that prevents all InstallAnywhere installers from working. In the open source world that would be inexcusable--ZeroG, Sun, or anyone who uses InstallAnywhere would get it fixed. And there are a lot of InstallAnywhere users.

      I came to Java from Borland C++ 5.0 on Windows 95... it was an incredibly refreshing change. But after two years I started moving away because of the many bugs that never got fixed. Then I discovered Python.

      Python has most of the advantages of Java, much greater flexibility, and only a couple of disadvantages. This isn't a Python article, so I won't go into too many details, but IMHO the Python way of programming leaves Java in the dust.

      Cross-platform? You betcha. More platforms and better support than Java, in fact. Rich library? Even richer than what Java offers. Open? Yep. Extensible with C? That too. Fast? Well, it generates code very similar to Java bytecode, so if Java bytecode can be fast, Python can be fast too. GC? Yes. Type safety? For the most part. Better than C, not as strict as Java.

      You be the judge. But don't just ignore Python.

    3. Re:What I think... by Money__ · · Score: 1
      I would agree that Java has become one of the languages. In my mind, it already is part of the "web API" when implementing a wide area aplication.

      I would take issue with your comparison with VB. When looking at the initial learning curve, and prototyping, I think that Python is more comparable to Java in that respect. The point about having VBA in Office98 on Mac is, how can I say, laughable.


      ___

    4. Re:What I think... by Shadow99_1 · · Score: 1

      Strangely I couldn't learn C to save my life, but I learned C++ with no problems... I never did get around to learning Java though I've left programming since then...

      --
      we are all invisible unless we choose otherwise
    5. Re:What I think... by BeerSlurpy · · Score: 1

      I couldnt agree more with everything you said (except applets). Java is definitely offers a lot to many people and I love to program in it.

      About applets, there are many very cool possibilities for applets. Have you ever considered distributed processing via applets? You just load up the web page and you get some of the load distributed to you automagically. Could be used for raytracing, passwd cracking, you name it. All you need to participate is a browser. Although the bandwidth requirements are a little high right now, i would like to make a distributed mpeg encoder for those extra big jobs.

      What do you think?

  81. Re:Java is a FAD. by weirdal · · Score: 1

    Just a thought... If you have to rewrite your Java code, it might be because that it wasn't written well in the first place. Of cause we all know, that if we write something in M$ java, it will only be able to run on a Windows PC. But if we write some Java code based on Sun's Java specifications, we have a piece of code, that needs no rewriting. ... and just another thought: If a programmer makes some good Java code, that runs well and stuff, the user of the program (or the webpage) won't see that it is Java. But if the programmer makes some bad, slow Java code, then user will right away see that its java (u know: "Loading Java..." for example, if we are talking applets). Then here is my point: Every time people use some bad Java code they see it's Java right away, but if they use some good Java code, they don't even regencies that they are running Java! (because it runs just as well as a program written in C/C++ or another good/fast language) - That could be one of the reasons why Java have such a bad reputation and why it's having such trouble getting rid of it... but who am I to know?

  82. Speed and server applications by pieterh · · Score: 3

    In my experience, aside from gross overheads such as those imposed by interpreted languages, the actual performance of server-side business applications depends primarily on database access. Put simply: the cost of database access is so high that it wipes out subtle shades of difference between language A and B. The key to building fast applications is the choice of good tools, and an understanding of the impact of SQL clauses like ORDER BY. The relative speed of compiled Java over C would be a very bad basis for chosing the language for an important project.

    1. Re:Speed and server applications by pen · · Score: 1
      And considering that Java supports DB connection pooling pretty much transparently...

      --

    2. Re:Speed and server applications by Arg! · · Score: 3

      Indeed! Don't waste money on Oracle unless you're going to get a good DBA as well! About Java, I find that it's very modern in relation to C/C++...which is actually very refreshing. Object-oriented-programming with Java seems very natural, which is in stark contrast to the against the grain feel of C++. The use of unicode over ASCII I think is another more "modern" advantage of Java (even though it may imply some performance loss due to the increased size of character and string datatypes). The "write-once, run-anywhere" properties of Java certainly get the most press, but I think a lot of it is actually downplayed. Sure, Java is not the first language to be cross-platform without recompilation, but I think it's probably the most successful. Being able to take a servlet from a Solaris system and run it flawlessly on Windows NT is pretty impressive, I must admit. I think this is a major reason for Java's success on the server. While the public may be content with platform-bound applications, Developers have grown tired of endlessly porting code. The web is a cross-platform, "write-once, run-anywhere" application, so why can't the applications that power the web do the same? Seriously, though, if I sound like a University professor endlessly extolling the virtues of Java and OOP, please tell me to stop! ;)

  83. Re:metadata by Waltzing+Matilda · · Score: 1

    The main problem with the metadata and the bytecodes are that they reside in the data portion of the process running the Java VM, and hence are typically not shared among processes, the way code portions can be shared.

    I'm aware that Sun and Apple are working on this, but I'd like to see a day when my Swing application doesn't eat 24 megs just to show a simple window.

  84. Benchmark strange (try to reproduce it!) by SomeOne2 · · Score: 1

    I was quite astonished by this benchmark, especially the fibancci part; there is virtual nothing to optimize her beside perhaps calls and inlining (which all compilers should handle somewhat descend in this simple case) and tried to reproduce the benchmark using the given source code. The results where somehwat different from their results...

    Results on unmodified (*) source taken from the website: (Average values given by the program)

    Sun JDK 1.3 HotSpot + javac: 111.8,120,123,120,119.0,119.8,120,118.8

    Borland CBuilder 5 C++ mode, max optimization (IDE button+PPro setting+use registers): 133,135,130,131,132,131,132,131

    (*) I adjusted the baseline for my PC but that's just a constant factor to the results for all programs.

    Of course if you do yourself a havor and change the declaration of doFib from "int doFib(int fib)" to "inline int doFib(register int fib)" the results are much better... :)

    Again Borland CBuilder as above: 210,188,162,161,161,161,161,160

    I would think the benchmark is somewhat strange, especially at the fibonacci benchmark both languages should be nearly the same (given a reasonable JIT resp. C++ compiler) since the function is so simple that it could be written by hand in ASM without any trouble!

    1. Re:Benchmark strange (try to reproduce it!) by catseye_95051 · · Score: 1

      recursive in-lining.

      Hotspot inlines recursion. Many other compilers do not.

      In general if you expect the Hotspot JIt to asct liek a C compiler you WILL find the results strange.. its much more advanced, frankly.

      The needs of Java have been pushing the JIT makers out into brand new territory. Thsi is aprt of the whoel point of the comparision.

    2. Re:Benchmark strange (try to reproduce it!) by SomeOne2 · · Score: 1

      In general if you expect the Hotspot JIt to asct liek a C compiler you WILL find the results strange.. its much more advanced, frankly.

      Um, actually C++ was much faster than Java (as given above; try the benchmarks yourself if you don't believe me). And I don't see why in this very simple example C++ couldn't optimize as well as Java, there is nothing to gain here from runtime information.

    3. Re:Benchmark strange (try to reproduce it!) by catseye_95051 · · Score: 1

      I have tried them. My results concurr with Chris's

      **shrug** The wonders of differnt machines. If you have different numerbs you should post them, as completely documented as Chris did.

      And the big benefit Hotspot gets ehre is that Hotspot inpoines recursive calls to a certain depth. I doubt the C compierls are doing that.
      Agaiun, looking at output code wouold probably answer the question if you're really intrested in exploring it. You can examine Hotspot code by breaking within the loop in a good debugger or Software ICE and examining executing byte code.

    4. Re:Benchmark strange (try to reproduce it!) by SomeOne2 · · Score: 1

      You can examine Hotspot code by breaking within the loop in a good debugger or Software ICE and examining executing byte code.

      When I'm really bored I will try it... :)

      However I was curious and analysed the Borland C++ code which did everything reasonable beside avoiding tail recursion (if you "enforce" that by modifying the code it gets much faster... :) Than I checked the IBM JDK (1.2) which is almost identical in performance to the C++ code so the JIT will probably produce the same code. However the Sun JDK 1.3 is much slower. (btw. all on a 128 MB 450Mz PIII NT 4.0 SP 6)

  85. Re:Too good to be true by mbaker · · Score: 1

    Not that I get jollies from plugging one of my own projects, but perhaps you should take a look at

    http://pysdl.sourceforge.net

    It's a Python binding for SDL, SDL_image, SDL_mixer, and SDL_ttf. Currently there is no circle primitive, but adding one would be trivial.

  86. Re:Java is a FAD. by rifter · · Score: 2

    The only problem with JAVA is that the poseter is right about the write once, rewrite anywhere. Java under LInux != Java under MacOS != Java under Windows != java under Solaris. In fact on the Mac, Java can take three forms, Apple JVM, Microsoft explorer JVM, or Netscape JVM, and they are not the same.

    To say nothing of JVM versions within a given platform...

    Sun tried to make a great technology, where you could have true cross-platform compatability, and where it was easy to learn to code for it because of its similarity to other languages (most like C++ IMHO). It is not working for the same reason networking and the www are not working, Vendor-introduced incompatabilities.

    The only reason these technologies are thought viable at all is mainly the dominance of certain technologies (eg 90% of pc's are Wintel, so if you write for MSJVM, you have 90% of the audience.)

  87. Volano benchmark by Krakus+Irus · · Score: 4

    In order to help you choosing the best VM, you can check the Volano Benchmark .
    You will see there that the best VM is Tower TowerJ 3.1.4 for Linux !
    Second point, I never doubt that java on the server is a good solution now. For me, the only trouble with java now is the memory gluttony.
    If some of you want to test Jsp/Servlet, here are some good open source products : java.apache.org (JSP, servlet), www.enhydra.org (JSP, servlet, EJB)

    1. Re:Volano benchmark by haggar · · Score: 2

      No wonder the TowerJ resulted fastest: it is a static compiler!

      --
      Sigged!
  88. This is nice, but... by /ASCII · · Score: 2
    As everyone who has done any real amount of Java coding knows, and as the article also points out, there are still speedissues when it comes to the widgetsets and other basic libraries. The SWING-library is so large that it takes several seconds to start a simple notepad-style app.

    Hopefully we will see an effort to optimize the Java libraries soon, for startup time as well as for speed, or else Java will become a pure Serverside language.

    --
    Try out fish, the friendly interactive shell.
    1. Re:This is nice, but... by Jordan+Graf · · Score: 1
      This article is old enough that probably nobody will ever read this, but anyway...

      Swing does not use AWT for the "lowest level stuff". Most Swing classes derive from AWT components, but all the pixel pushing is done in Java, rather than with the OS widgets.

      So Swing needed to specify the way all the widgets look. Aside from creating a great looking Look and Feel (Metal) Sun decided to make everything themable so that you could make Java apps look like Win32 apps or Mac apps or whatever. There is no doubt in my mind that all this generalness comes at a performance penalty. Take a look at the swing source sometime (in src.zip with the JDK) and note the incredible complexity. Undoubtedly stripping it out would result in a performance improvement. The question is whether the performance trade off is worth it.

  89. Re:metadata by pnkfelix · · Score: 1

    Wouldn't a logical way to workaround this problem be to run multiple Java applications using one JVM?

    I believe I saw some Java application a while back that would start up the main() function of other classes, acting as a sort of shell for Java...

    Of course, in doing this you lose isolation between your applications (which can be a problem if your application doesn't play nicely with other threads that are running in the current JVM) but still...

    -Felix

    --
    arvind rulez
  90. Compiler choice by Nygard · · Score: 1
    These two may not be the best compilers known to man, but you must admit that they are the most commonly used.

    --
    "Genius may have its limitations, but stupidity is not thus handicapped." --Elbert Hubbard (1856-1915)
  91. Philosophy of a Programmer by Nexx · · Score: 1

    The problem is many of these sort of /.'ers have no actually (sic) programming skills, they just want to say Open Source in a zealous fashion.

    I, a professional programmer, whose life depends upon the sale of my services rather than my code, would like to comment.

    I scream "Open Source", because it makes my life a lot easier. I use a lot of proprietary software in my work (Oracle, Sybase Jaguar, etc. etc), and I can think of many times when a quick glance at a source code would've answered my question, rather than pouring over the endless amounts of absolutely useless documentation.

    Of course, I see useless documentation in the Open Source world as well, and they annoy me as well. However, with OSS, I can just as easily read the source, and find my answers within. The overhead of doing so many be higher than reading a good set of documentation, but when such documentation does not exist, then with OSS, one is left with an alternate source of information.

    OTOH, many /.'ers sound like I did in college--eager, intelligent, but lacking in experience. They scream "Open Source", may or may not have actual programming experience (and for the most part, undergraduate academic experience do not count), and tend not to see the picture from a "business standpoint". Yes, performance is important in many cases. However, at the same time, only in a handful of cases is it the most important aspect. My managers (and therefore, my paycheck) will not give a rat's ass if my code was the most optimised piece of art available if it was even days overdue. At the same time, if it were "acceptably" fast, they'll see me as "effective", "efficient", "productive", blah blah blah.

    I see their point, though. Most traffic I see on these sites that I create tend to garner more revenue-per-user than your average portal (or even the average ecommerce site) does, making them a low-volume site. At the same time, many of the clients we service have strict deadlines; a manager at a Fortune 500 company's time being wasted for even hours due to a slipped deadline ends up costing us greatly.

    Of course, this often means that I write code that is not even up to par with my own standards of cleanliness and performance, but that is life. Fast, cheap, good. Please choose any two.

  92. Re:Dynamic Optimization by QuoteMstr · · Score: 1

    Thanks for the information. I had never heard of this before.

  93. Re:These number are worthless... (unless you read by panang · · Score: 1

    the problem with the relative-to-baseline normalization of the graphs is that a bump in performance could actually represent a dip in the baseline performance and vice-versa. they should have been done relative to the average performance (and shown the absolute average performance somewhere).

  94. Memory allocation by wowbagger · · Score: 4
    One of the interesting comments in the article was about "gcc's default dynamic memory allocation": technically this isn't gcc's memory allocator, but libc's. I wonder a) if the Cygnus malloc/free routines are as optimal as those under glibc2, and b) if there aren't better routines out there.


    It's a bit unfair to blame gcc for poor memory allocation: unlike Java memory allocation isn't built into C.

    1. Re:Memory allocation by catseye_95051 · · Score: 1

      I think you HAVE to blame C (and even more C++) for bad memory allocation. All system-side memory allcoatio nis lousy. Anyone who has done high performance programming knwos this.

      Modern Java VMs supports highly advanced memory handling algortihms (again, see the Hotspot docs at java.sun.com), so they can do much better at memory related tasks.

      Sure there is NOTHING Java does that C++ couldn't with a similar byte-code->run-time-compiler and VM system, but thats nto the point. If C or C++ have to become MORE like Java to compete with it, that says a lot about the performance of java technologies as oppsoed to C/C++ technologies today.

    2. Re:Memory allocation by catseye_95051 · · Score: 1

      Well then someone shoudl do the comparison.

      I know what Hotspot does internally, and I doubt any of the libcs can compete in heavy allocation/deallocation uses, but I'd be happy to be suprised.

    3. Re:Memory allocation by fatphil · · Score: 1

      I disagree.
      It is the compilers job to separate the programmer from the operating system. If the underlying allocator in the OS is abyssmal, the GCC is perfectly within its rights to shield the user from this by providing a superior heap. The user shouldn't even need to know whether this is happening or not. If gcc's malloc/realloc/free/new/delete is suboptimal because it relies directly on the OS, then it is only gcc to blame.

      Phil

      "Hey f*** off big-titted woman, we're talking about _software_"
      - Finnish man to Finnish lady in pub 2 nights back

      --
      Also FatPhil on SoylentNews, id 863
    4. Re:Memory allocation by vherva · · Score: 1

      Cygwin very likely suffers from from large overhead and suboptimality in malloc stuff. I'm not sure how it is implemented, but likely it adds an extra layer between malloc() and win32 malloc(). MSVC, OTOH, is supposed have optimized malloc pools etc.

      Cygwin is intended for portability (and does tremendous job IMHO) -- the performance is not the first concern. Glad to see gcc doing so well where the cygwin library is not involved, though.

      --
      -- v --
    5. Re:Memory allocation by GooberToo · · Score: 1

      The results are seemingly suspect to me. MS's compiler historically optimizes rather well. Additionally, gcc is known for poor optimizations on Intel platforms (compared to MS and Borland; gcc is said to do well on CPU's with lots of registers - aka RISC). MS/Borland are able to take advantage of CPU specific instructions. GCC can not. Remember, -mpentium, et al, only does CPU specific scheduling and does not actually generate pentium specific code. That's why a program compiled with -mpentiumpro will still run on a 486. The second obvious oversite is that I assume (I didn't look at the code) that the benchmarks were measured from within application run-time (whereas, each measure's it's own run-time). If this is the case, all of the Java benchmarks are incorrectly measured. I, for one, think that startup time is an important measure. This is one of the biggest reasons why I choose not to use Java, as I don't like the three hour startup time required for everything to get going. Having said that, if the application startup is included, typcially, Java falls far back to the pack unless the benchmark is long enough to effectively make it noise in the overall test.
      Overall, I consider these tests to be interesting but worthless. I also completly agree with posting above. Memory allocation performance is not a function of the compiler. As such, if you know you are going to have a memory intensive application in C/C++, it's easy to get optimized allocators (or write your own) to address performance issues. Likewise, in Java, when allocation is an issue, the results are again biased unless the benchmark runs long enough to account for memory collections within a Java program (I assume that the benchmarks don't account for this). Not to mention, collection algorithms used tend to vary from implementation to implementation. So, it's difficult to say if this is already included in the returned results.

    6. Re:Memory allocation by vherva · · Score: 1

      Please understand something here: gcc is a C compiler. malloc is not part of the C language but a part of the C standard library. Thus, gcc does nothing for the malloc call -- that's the job of the standard library implementation. In this case that happens to be the cygwin libc -- not the native win32 libc, but a non-optimal porting library. Under linux, with native glibc, the results might be different.

      Java does separate the programmer from the platform, C very much doesn't. There are libraries that do that (partly.)

      (Miksi *tussa suomalainen mies puhuisi suomalaiselle naiselle englantia baarissa? Tarkoititko "suksi vittuun, isotissinen nainen - puhumme pehmosta!"? HTH, hand.)

      --
      -- v --
    7. Re:Memory allocation by jmv · · Score: 2

      I'd be curious about the C++ allocation. I think some STL classes have a special allocator that's supposed to be faster than malloc (is new using the same allocator as malloc?).

    8. Re:Memory allocation by Halo1 · · Score: 1
      Actually, GCC optimizes best for 80x86 and iq less good for other architectures. The reason is simple: most OSS people are using 80x86 hardware and as such there's more manpower available for 80x86 development.

      Recently, there was a post in a (codewarrior) newgroup from an Apple employee who stated that GCC for PowerPC generates quite slow code (when compared to CodeWarrior, which itself isn't bad, but not great either). However, since Apple is using GCC as main compiler for MacOS X, they have some of their compiler guys working on GCC (and are committing the patches back to Cygnus/FSF/whoever-is-in-charge) so this situation should improve.

      --

      --
      Donate free food here
    9. Re:Memory allocation by vherva · · Score: 1

      Gcc i386 optimizations have gotten much better lately. They recently integrated a new i386 backend (I don't think that was used in these tests, though.) Pgcc still has some edge, though. MSVC is not that spectacular compiler, Intel's compiler is much faster for example.

      --
      -- v --
    10. Re:Memory allocation by GooberToo · · Score: 1

      Interesting followup on the x86 backend, but I don't think that it effects my original comments.
      As for MSVC being a good compiler or not, my comments did not address this; even though, MS typically does a very good job of optimizing. However you choose to rank MSVC, fact is, for x86 platforms, GCC typically scores much worse than most compilers.

    11. Re:Memory allocation by vherva · · Score: 1

      2.95.mumble-mumble also lacks most of the (deemed unstable or too hackish) optimizations from pgcc.

      AFAIK, 2.95 also does not have the new i386 backend yet. However, I've seen no benchmarks on that, so I really don't know how it does.

      --
      -- v --
    12. Re:Memory allocation by mbaker · · Score: 1

      The C malloc() routine, on Windows, isn't actually Win32. It's actually a thunking call on top of GlobalAlloc and the like.

      Cygwin's library has a lot of thunking for POSIX, so it may very well use a less than optimal memory allocation system, as well.
      There's a non-thunking variant of win32 gcc called mingw32. This might be better suited.

    13. Re:Memory allocation by mbaker · · Score: 2

      And so you would have a C compiler modify a programmer's intent, and implement a memory management system (either on top of malloc, or kernel interfaces) itself?

      Perhaps it should also be responsible for providing an implementation for various kernel modules, because the underlying OS's may be suboptimal. And while we're at it, let's have it compile in its own kernel, since the underlying OS's might be suboptimal.

      malloc is a C standard library routine.
      gcc is a compiler suite.

      libc shouldn't try to compile my programs, and the C component of gcc shouldn't try to do anything other than compile my code.

    14. Re:Memory allocation by stripes · · Score: 2
      Gcc i386 optimizations have gotten much better lately. They recently integrated a new i386 backend (I don't think that was used in these tests, though.)

      The test claimed to use some version of gcc 2.95.mumble-mumble. 2.95 has a lot of x86 improvments (and generic improvments!) from egcs. What 2.95 doesn't have, that the dev snapshots do is -mtune=k7 and -march=k7, which should have made the FP stuff go faster (scheduling for the PPro and running on a K7 isn't bad, but scheduling for the K7 and running on a K7 is better).

      There is also some experimental code to do cach line prefetching, but I didn't follow the thread to see how it turned out (last I say it made the streams benchmark numbers twice as good, or better, but there was some concern that it might make other things slower).

    15. Re:Memory allocation by stripes · · Score: 2
      AFAIK, 2.95 also does not have the new i386 backend yet. However, I've seen no benchmarks on that, so I really don't know how it does.

      According to the egcs/gcc news page from 2Sep99: Richard Henderson has finished merging the ia32 backend rewrite into the mainline GCC sources. The rewrite is designed to improve optimization opportunities for the Pentium II target, but also provides a cleaner way to optimize for the Pentium III, AMD-K7 and other high end ia32 targets as they appear.

      That was post 2.95, and post 2.95.1, but before 2.95.2. Looking at the article it was using 2.95.2, so I assume it has the new x86 backend.

      2.95.mumble-mumble also lacks most of the (deemed unstable or too hackish) optimizations from pgcc.

      I think the issue they had with pgcc was it did a lot of x86 things at the machine independent level of gcc, and a lot of machine indepenedent things were in the x86 code (like branch prediction). A lot of the pgcc optimasations are in the new x86 backend, or were properly added to the machine independent code.

      That is to say a lot of the stuff pgcc did someone re-did and put in gcc. Not all of it. And gc now does stuff I don't think pgcc does.

      I don't know which is faster at this point, but I could beleve either. After all egcs got a whole lot of MI speedups that pgcc hasn't.

    16. Re:Memory allocation by stripes · · Score: 3
      I'd be curious about the C++ allocation. I think some STL classes have a special allocator that's supposed to be faster than malloc (is new using the same allocator as malloc?).

      C++'s new tends to be a thin layer over malloc. The STL allicator wasn't designed to be faster then new/malloc, but to deal with segment issues, shared memory issues, and maybe even object perminance.

      The allicator SGI's STL (which gcc currently ships) allocates about 20 objects when you ask it to allocate, and doles them out one by one. That's for "small" objects. Anything over about half a K (or maybe 2K? I forget) goes through to new. This might be faster then 20 mallocs. Or not. Some mallocs are pretty good. Better then the STL allicator overhead. It does tend to reduce fragmentation. By a whole lot more then I expected.

      If you don't like the default allicator, they are easy to write, and Alloc_malloc is allways ready to step in. There is even a #def to ask it to be used everywhere.

    17. Re:Memory allocation by vherva · · Score: 1

      Interesting followup on the x86 backend, but I don't think that it effects my original comments.

      However you choose to rank MSVC, fact is, for x86 platforms, GCC typically scores much worse than most compilers.
      I do agree with most what you said. However, I wouldn't go ahead saying gcc always scores worse than by MSVC. It's more complicated than that.

      As for MSVC being a good compiler or not, my comments did not address this; even though, MS typically does a very good job of optimizing.

      You did say "MS's compiler historically optimizes rather well.". What I ment by "not being spectacular" was it's optimizations (loses to Intel compiler). I don't even want to begin with other C++/C compiling aspects.

      --
      -- v --
    18. Re:Memory allocation by dvdeug · · Score: 1
      That was post 2.95, and post 2.95.1, but before 2.95.2. Looking at the article it was using 2.95.2, so I assume it has the new x86 backend.


      No. 2.95.* releases are bugfix releases on 2.95. The new x86 backend will be coming out in 2.95 or 3.0, which ever comes first.

    19. Re:Memory allocation by stripes · · Score: 1
      No. 2.95.* releases are bugfix releases on 2.95. The new x86 backend will be coming out in 2.95 or 3.0, which ever comes first.

      Ah! Yeah, that would make sense (other then you saying "2.95 or 3.0" when 2.95 is out...did you mean 2.96? or is there something about gcc release numbers that I don't understand?).

  95. Java performance comparison by herwin · · Score: 1

    These results are of some interest to me, because my department (I'm a CS adjunct at GMU) has asked me to consider learning Java well enough to teach the third-year OOP course in it; my daytime employer has asked me to get up to speed in it for a proposal; I'm very interested in multithreading (which C++ is not so hot at); and I'm currently using a Java application (CCTool, built using the IBM compiler) to write security targets for a gov't agency. Current Java compilers remind me of the first Ada compilers back in the early 1980s. The Java application sloshes as it walks around, mostly due to thrashing. The thread features and the garbage collection are just a bit dangerous to use, and I've been told that Java applications have to be carefully written if you want them to run faster than a turtle. The posted comparisons don't seem to fit the real world experience I've been having, but most such comparisons tend to be cooked to favor one or another language. Cheers,

    1. Re:Java performance comparison by BagMan2 · · Score: 2

      You're the second person who has suggested C++ is slower than C in a round about way (this is a reply to both posts). There are certainly constructs you can make in C++ that will incur a fair amount of overhead; however, remember always that C++ started out as a pre-compiler (CFront) that translated it into C.

      You suggest using structures and pointers to functions to accomplish OO techniques in C. I used to do this about 12 years ago when C++ was not portable/standardized enough to use for the project I was one. But don't fool youself into thinking that you are getting better performance. The C constructs you talk about are largely the same thing that was produced by the CFront compiler in the first place.

      The problem now days is that most programmers don't understand how the various features of the language they are using ultimately get implemented at the assembly level. If you use the MFC CString type (for example) as proof that C++ is slower than C you truely are missing the point. In the case of CString, you are sacraficing performance for notational and functional convienence. If you are writing a word processor, that probably isn't the best idea. If you are writing a game that rarely deals in text, it's probably worth the slight speed hit you get for the manageability.

      The bottom line is that C++ will produce every bit as tight of code as C will and it will do multi-threading every bit as well as C does. Proper multithreading has a lot more to do with algorithmic design than it does the language you are using.

      More often than not, C++ will actually produce faster code than C. The reason being is that few programmers will go to the hassle of setting up arrays of pointers to functions in order to accomplish the polymorphism that is often needed in a programs design. They resort to switch statements and such as the easy way out.

      If you blindly put 'virtual' in front of every function cause the manual suggested it, and then wonder why the implementation of a simple GetValue() function is so slow when you marked it 'inline', then is it any wonder? A good knowledge of what is being produced at the assembly level will make you a MUCH better coder and largely if not completely eliminate any C++ performance gotchas.

    2. Re:Java performance comparison by Graymalkin · · Score: 2

      Your comment on multi-threading is very true. If you write a visual app with a thread doing the hard work and then a thread which handles the interface you're not doing yourself much good. One of the nice thing about the way Be sets up their libraries is everything is multi-threaded and they usually help you multi-thread things in an intelligent way as to actually speed up the code on multiple processors. Silly C programmers.

      --
      I'm a loner Dottie, a Rebel.
  96. This is a flawed study- but I like it! by WolfWithoutAClause · · Score: 1
    On this basis C++ would be as fast a C. But we know it isn't really. What they have done is taken a C program and compiled it under the Java compiler, using little of the Java languages class features. You can do the same thing with C++ and get similar results.

    But real world applications use objects extensively- we go to Java partly because it lets us do that (although there are other reasons, like added security.)

    OK. I hear you say- why do you like it?

    Well, it shows that if you really get stuck with a Java applications performance, it is often possible to redesign it to get C's level of speed.

    And besides I love seeing the C++ lovers choking in their beers. (Java is as fast as C?! sppkkthth) - I get wet but its worth it.

    --

    -WolfWithoutAClause

    "Gravity is only a theory, not a fact!"
  97. Jikes is NOT faster than Javac by AShuvalov · · Score: 1

    You have overhead of loading JVM each time. If you don't than it's different.
    I'm using "ant" - java compile utility, which compiles something very complicated at one JVM run.
    We are compiling our company product - 500 Java classes with jikes and ant/javac. You know the result? Time is equal.
    So java is NOT slower than C anymore, even on big tasks, like compiling 500 files.

    --
    Andrew
  98. A Java COMPILER wouldn't help by GGardner · · Score: 2

    The problem with writing servers and gateways in Java is that there is no way to do non-blocking i/o, or select(2) in the Java libraries. Instead, you need (at least) one thread per fd, which is often memory expensive. VolanoMark shows this off, and the fastest Java VM for Volano (TowerJ) is the one with the most scalable thread implementation. There is a proposal in process (java.nio) to fix this, but who knows when it will see the light of day.

  99. Re:It's the database, stupid. by Money__ · · Score: 1

    I couldn't agree more. In my mind, Java is an integral part of the "Web API" when building wide area applications. I think the original post on this thread nailed it right on the head when he pointed out that the overhead is in the DB and not the logic before or after. Given this situation, portability and stability are higher priorities than eeking out another .1% of overall speed of the wide area application.
    ___

  100. Re:Too good to be true by pen · · Score: 1
    Well, there's the Netzero dialer... heh

    --

  101. Java references by AShuvalov · · Score: 1

    Java references are even more than that. They are in fact abstractions, "handlers" to refer to the object. In fact, you can imagine JVM where you have reference to the objet, which is located at the different computer. And the program doesn't know that!

    --
    Andrew
  102. Re:Tell that to Netzero . . by Money__ · · Score: 1

    . .who more than 4 million registered users in 2,500 cities across the United States all using Java.
    ___

  103. Should compare to C++, not C by codealot · · Score: 1

    A good JIT will perform optimizations that C will never attempt, like code inlining. Inline functions are not standard C, but they are part of C++.

    I modified the life source for C++, adding `inline' in a few strategic places... compiled with g++ it runs up to 50% faster than gcc.

    Add garbage collection for C++ and I doubt if the HotSpot VM will do much better, if at all. At a certain level (i.e. machine instructions) they work about the same, anyway.

  104. Re:It does not matter by bored · · Score: 1

    I understand, that to properly optimize the run time, a good profile of the code will be required.

    My real point was that if the guy didn't even know that calloc() 'c'lears the memory then it sort of indicates a general misunderstanding of the language. A good
    C/C++ programmer will have a firm grasp of the language and what kind of code his compiler is generating. This allows him to structure his code in a way that is
    just as readable (maybe more so since there won't be any extraneous fluf) and performs far better.

    Of course a good grasp of the algorithm helps too. Life is a program that should never have its main loop coded in more than 5 lines of code.

  105. on java and efficiency... by phlake · · Score: 1
    it's true that Java is a very good language for developers, giving both simplicity, power, and (mostly) portability.

    it's also true that the JVM takes a serious performance hit, due to its very nature. interpreted languages are slow. period. using a native compiler can result in a drastic speed increase, but the trade-off there is that most of these native-code compilers are in their infancy, and have difficulty compiling perfectly valid Java code. and compiler errors on valid code is a very frustating thing indeed.

    in an ideal world, Sun would step up and produce a native-code compiler for their favorite platforms (solaris, windows, and linux, in that order, leaving apple to fend for themselves). this native-code compiler would also compile Java byte-code. does this sound like JIT? sort of, but let's keep in mind the phrase "optimized for speed". while JIT is faster, it still does not approach the speeds of native code.

    however, this is actually indicative of a deeper problem. writing tight Java code is tough. it's hard to do. the standard API is large, bloated, and plagued with inefficiencies. this may sound sacriligeous, but it's true. to their credit, Sun has managed to tighten the code with every subsequent release. Java 1.0 ran slower than 1.1, which in turn was slower than 1.2, and in keeping with this, 1.3 seems to improve the speed even further, especially the JFC stuff.

    but the real problem simply comes from OOP overhead. when you write "proper" Java code, you try to rely on Sun's supplied API as much as possible (so that you reap the development-time gains). but there is a penalty for doing so: you have no control over the inheritence, the efficiency, and the size of the API code. in a few projects i've done, i've been forced to go into the API, and tweak certain parts that i needed. specialize parts of the API, or rewrite them. this may take away their general-purpose nature, but also removes unnecessary crap from my core loops, which is most important to me.

    a further problem with this is that development time then increases. i have yet to meet a project manager who truly sees the value of making code efficient. especially since doing so makes that little bar on the Gant chart, the one that represents me, stetch a little farther. they don't care. do it quick. dirty. they don't care so long as it's done _on_time_.

    i've basically come to the conclusion that if you want it to run fast, you should (still) write it in C. if you can afford a slight performance hit (or your mind has been permanently warped into OO thinking), use C++. on the other hand, if you want to write it quickly, and speed isn't such an issue, go ahead and use Java. hey, it's fun to write. it makes sense.

    but it's going to be a long wait for efficiency. i don't think that was really ever more than an afterthought with Java.

  106. C++ slower, C faster than Java by Cinquero · · Score: 1

    I have just done my own little and dirty performance test: http://www.physik.uni-freiburg.de/~stier/Miletus/p ub/Programming/Algorithms/Sorting/SortCl ass.doc.html Gnu C++ may be slightly slower than IBM JDK 1.1.8, but GNU C seems to be a lot faster.

  107. Re:Java is a FAD. by rifter · · Score: 1

    Well, I think the problem is that since it is code, it is prone to bugs. One thing I have foudn in my cursury examination of standards in general, is that there are often grey areas, and in those grey areas differences. Often this turns out to be harmless, but sometimes it does not.

    In particular there was a problem with MSNT DHCP at one point, in that it did not work properly with Macs. Both were technically following the standard, but there were enough differences in the messages Macs were sending at particular times, and the MSNT DHCP server's interpretation of those messages, that the end result was no IP for the Mac. Apple ended up changing their behaviour just so that this would not happen anymore.

    HTML is a great standard, as is TCP/IP, but with different browsers/oses/etc YMMV. Ethernet can be subverted with the "wrong" frame types, etc.As for Java, I would imagine that basically you would find that your program works in one JVM but not in others, variously because of differences, grey areas, or bugs in the implementation you are using.

  108. Re:Locking and reference counts in Java = Slow? by catseye_95051 · · Score: 1

    Java does not refernce count.

    Anotrhr common misunderstanding.

    Java Garbage Collects, but no VM I have ever heard of uses reference counting for that.

    Go to the java.sun.com page and read up on the Hotspot compiler if you want to get a bit of a picture of how mdoern garbage colelction works.

  109. Re:Benchmarks by catseye_95051 · · Score: 1

    The problem with "real" benchamrks is that, sicen they are a fixed and rpecitable test suite, all the vendors trick out their systems to do maximally well on them.

    The BEST benchmarks actually are randomly selected real world programs. Unfortunately they can be tricky to measure, and none exist for the cross-platform type of tests Chris is doing.

  110. Absolute numbers mean nothing by catseye_95051 · · Score: 1

    They are too system dependant to be of any value.

    A well seasoned benchmarker always does so by comparison. You could argue about what to chose as your baseline, but I think Chris's choice of gcc -o was reasonable, myself.

  111. These number are worthless... by bob@dB.org · · Score: 1
    I'd like to see some numbers/graphs on execution time, not just execution time relative to gcc -O. This might make the graphs harder to read, but the data presented in this article tells me nothing except that a set of five programs have different execution times depending on whether they are run using x/y JVM or compiled on m/n/o compiler. The difference could be 0.03% or 2130%, and I have no way of finding out. So, for me at least, until I see some real number, this is nothing but misleading statistics.

    B. Johannessen

    --
    Acts@core.mailboks.com Acrux@core.mailboks.com Adam@core.mailboks.com Adar@core.mailboks.com Ada@core.mailboks.com
  112. Wrong... by Anonymous Coward · · Score: 1

    Then what happened to Corel Office for Java, or Lotus SmartSuite for Java, or any of the other apps that were promised.

    In the real world, Java apps are slow, and feel sluggish, the way VB apps feel also.

    The diff between C and C++ is fairly minor. the difference between any compiled language and Java is quite large.

    Every couple of months for the last 5 years, some Sun shill has put out numbers "proving" that Java is as fast as C/C++. Too bad the JDKs aren't compatible, and the apps that really get written are pigs.

    Java has been all hype since the very start. A lot of anti-MS people grabbed on to it, but it will always be too slow.

    1. Re:Wrong... by WolfWithoutAClause · · Score: 1
      Um... The Java JDKs are much faster now.

      Hey, here's an idea. How about you read the report Mr Anonymous?

      --

      -WolfWithoutAClause

      "Gravity is only a theory, not a fact!"
    2. Re:Wrong... by Drone-X · · Score: 1

      Then what happened to Corel Office for Java, or Lotus SmartSuite for Java, or any of the other apps that were promised.

      Those applications were started back in the Java 1.0 days. There was no HotSpot (see article) back then.
      But the biggest problem probably was that the Swing library wasn't created yet. Swing is the collection of widgets used in modern Java apps.

      Too bad the JDKs aren't compatible

      What makes you think JDKs aren't compatible?

      but it will always be too slow.

      On traditional processors: probably, but what about the MAJC processor (see article) or Crusoe?

  113. Re:Too good to be true by Jackrabbit · · Score: 5

    Look, I code Java for a living. I don't want to be a Java-evangelist (Javangelist?), but I've got a few problems with your post.

    As far as getting the latest JDK in anything but Windoze, you can currently get Java2 v1.3 in Windoze, Solaris and Linux (with other ports on the way). The fact that they came out with the Windoze port first should be no real surprise to anyone: most folks are still using Windoze, hence there is more demand for upgrades on this OS than any other.

    I've written Java stand-alone apps that are monumental in size and I've written Java server-based apps. I think that Java's main glory lies in server-side programming for web-enabled applications, but it is no slouch in the large stand-alone application market. You keep hearing people complain that Java eats up so much memory when all you want is a simple Notepad app. You need to understand what Java is doing and learn to work with/around it.

    If you load a large app that utilizes many of the Swing widgets and interfaces, the memory load becomes a bit more understandable. On the large apps that I've written for Java, it has actually performed quite well (sub-second sorting and display on a 10K row table, etc).

    Most of the comments that I see bashing Java are from people that have only taken a cursory pass at the language. If you try to code a Swing interface using the same paradigms as AWT (or C, C++, etc), you'll wind up with a slow monstrosity. If you code Swing the way it was intended to be coded (using the MVC architecture), you'll find that it's a remarkably powerful and full-featured GUI API.

    At any rate...I'll get off my soapbox now. I really don't mean to tout Java as the be-all end-all of programming languages (it's not). But it is one of the better languages out there for the current direction of Internet-enabled programming.

    --
    In the immortal words of Socrates, "I drank what?!?"
  114. Re:Volano benchmark (is lousy) by catseye_95051 · · Score: 1

    For all the reasons already mentioned.

    Spec98 (www.spec.org) is a much better, much more compelte test of the entire system.

    However I STRONGLY recommend when I speak on this topic that you take ALL standardized synthetic benchmarks with a healthy dose of salt.

    (1) They don't behave like real apps.

    (2) ALL the manufacturers trick their systems out to do unnaturally well on these tests. That one manufactuer can trick its VM out for a particular stadnardized benchmark then another says NOTHING about how it will run your app.

    To paraphrase Mark Tawin, there are 3 kinds of lies: "Lies, Damn Lies, and Benchmarks." The only real test is the speed of your own applications.

    On the bright side, since Java is a standard, if you stay away from VM specific tricks 9aa bad idea for many reasons) you can plug a different VM under your app and test it with no effort at all.

    www.

  115. Re:I think the answer is obvious by catseye_95051 · · Score: 1

    Well thats new. A self-reflexive troll :)

  116. I don't see how... by sesca · · Score: 1

    I don't see how anyone can make such a sweeping generalzation that Java is faster than C from these tests. Java and C are both compiler languages, what determines their speed is the compiler, or JVM used. So these tests mearly show that some JVMs can beat some C compilers. Since Java is a fad it is getting a lot of attention and optimization so some JVMs may be better optimized than some C complilers. I just doesn't make any sense to me to attribute speed to a language.

  117. Size matters by Anonymous Coward · · Score: 1

    1. The first problem with java : Have any of you ever given thought as to how many of the business production systems you've seen is limited by I/O or memory, as opposed to the number of systems limited by CPU ? The problem with java is the HUGE size (MEGABYTES) of libraries,JVM etc. A program twice the size will give a severe performance reduction on an I/O and memory limited system. A factor of 10 will ... slow everything to a crawl. 2. The second problem It's easy to learn ... for small tasks, thus when making large systems you'll end up having inexperienced people, who cut their teeth to fast to really learn anything creating things .... not good ! (As some say - No pain , no gain) 3. who really needs portability Have you ever wondered how much of the software you wrote, would need instant portability - why risk suffering any performance penalty. - just my view

    1. Re:Size matters by damm0 · · Score: 1

      I must dissagree with your point #2.. this isn't a Java problem. If you put inexperienced people on a big system, it doesn't matter what language you are using, you will still end up with a mess.

  118. Re:What language is the JVM written in? by catseye_95051 · · Score: 1

    The answer is that,as Java matures, more and more of the run-time system in general is moving to Java code.

    Obviously there always has to be a central "bootstrap" layer that starts out in compiled code. How muich of that rmains in C++ in the various VMs only time will tell.

  119. Then stop using... by chris.bitmead · · Score: 1

    those slow RDBMS and start using an object db like Versant to take one example. If you do it right with client side caching the database shouldn't be too much issue.

    1. Re:Then stop using... by pieterh · · Score: 1

      There are faster and slower databases, and one of the great mysteries for me, over the last ten years, is how pedestrian relational databases like Oracle have conquered the market although they are at least 10 and sometimes up to 1000 times slower than the ISAM systems they replaced. I've not had the joy of playing with an OO database, but the problem remains: access your data without care and every other tuning you've done is lost. Unless Versant or its like are capable of enforcing properly-indexed data access, I can't see how they would help. Many of the so-called 'applications' my team has been called in to fix or rewrite pay no attention to the cost of shunting data across networks, and blithely perform full table scans as if they were going out of fashion. It's humdrum, but IMHO simple good practice in database design and access would improve the performance of most database-related applications more and easier than switching to new languages or databases. Motto: when one does not know how to use one's tools, it's no use calling for replacements.

  120. Re:How Java Floating Point Hurts Everyone Everywhe by BeerSlurpy · · Score: 1



    http://java.sun.com/j2se/1.3/docs/api/java/lang/St rictMath.html

    Actually, there is a StrictMath in 1.3 now. It produces slightly slower results than regular Math, but it conforms to c floating point exactly.

    it looks pretty useful

    -jim

  121. There are still java issues. by catseye_95051 · · Score: 1

    I agree with that actually.

    A big one is that VMs don't yet share the calss data so every time you launch a VM you get a significant memory hit (6 or 8 meg currently, I believe.)

    The point thoguh is nto that java i 100% perfect but that at least one "intractable problem", Java computational performance, has been solved to some degree and is likely to gwet even better.

    As someone else pointed out, dyncamic compilers are in their infancy. If they can already compete favorably with the older, well evolved technology of static compilers, it doesn't take much imagination to guess what the future holds.

    In re memory usage, thats actually a much easier problem. I would expect to start to see solutiosn in the next few major releases of the VMs from the top VM makers.

  122. Hello World ? by JoostFaassen · · Score: 1

    The tests they did here didn't use any memory in comparison to any normal, usable program out there... the game of life ? Why didn't they test this with 'Hello World!' ?

    What I'm trying to say is that if they had used a little more advanced program then you would see that Java would start coughing and choking and crying for memory and other resources in no-time!

    Write a little graphical app for example... use swing if you like (gnah gnah gnah:)

    You know, when I saw the headline I seriousely thought about quiting C and start using Java!
    (Wow that was so funny, I'm can't stop laughing:)

    --
    This post is powered by caffeine
  123. Not a contest of Java vs. C but of Heap Allocation by phoebe · · Score: 1
    Many of the comments mentioned previously are perfectly valid however if you study the C code of many of the alogrithms they are just C ports of Java code. Almost every function is performing a calloc memory allocation and clear. It would be interesting to see the performance figures with this allocation changed. Possibilities include:

    • Use static memory allocation, i.e. char output[200] instead of char *output = calloc (200, 1).
    • Use a global memory block and cast pointers into it.
    • Use a 3rd party memory allocation library which can perform some kind of huge heap pre-allocation.

    Another test would be of course to take some C algorithms then convert them into Java and compare the performance.

    Also interesting to note is that no other typical C coding techniques are being used - such as variable localizing, all variables have been set to scope an entire function not just the loop / section it is used in. However gcc and MSVC should be able to automagically perform those optimizations for you.

  124. How Java Floating Point Hurts Everyone Everywhere by superid · · Score: 2
    Catchy subject, no? I read this article about a year ago and found it fascinating. Sorry I can't cut and paste because its a PDF document, but it can be summarised as:
    java's floating point arithmetic is blighted by five gratuitous mistakes

    And they give several examples where java will produce incorrect results in numerically intensive applications.

    My question is, is this analysis and the observations still valid now?

  125. Re:It doesn't matter... by __aasmho4525 · · Score: 1

    in the last 2 years i've seen some *beautiful* applications written in java and implemented using swing..

    just because the average bear might not be able to build great applications with the toolkit does *not* mean the toolkit is horribly deficient.

    check out argouml, togetherj, etc, etc, etc.

    there are some really well done ui's these days in swing..

    cheers.

  126. Dynamic Optimization by gotan · · Score: 3

    I can't estimate the extent to which dynamic optimizations went into the results of the article in contrast to good optimizations from scratch.

    Nevertheless i think dynamic optimizations are the thing to come: it costs a lot of man hours to find ideal optimizations to code, (you need to figure out the core routines, think about which optimizations make most sense for the current architecture, check those assumptions against reality) and man-hours, in contrast to cpu-time, don't become much cheaper. The dynamic optimizer does all that work for you, and even optimizes for different starting conditions/parameters by looking at what is *really* taking time now.

    Look at the success (regarding computing power per bucks) of transmetas crusoe. A dynamic optimizer can gather far more hints for optimisations (branch predictions, loop length, array sizes, memory lookups) than a static one, in the latter case the programmer has to give all the hints (compile a subroutine with the correct set of optimisations, sort the loops right, sort branches, keep in mind some ranges for parameters and how they affect loop length, for some compilers throw in compiler directives, etc.) and even has to reconsider when porting to another architecture.

    So with static optimizations it's either optimization limited to the part the compiler can see at compiletime (except for very basic stuff, every decent compiler will get that matrix multiplication right) or man-hour intensive and thus costly optimization.

    --
    "By the way if anyone here is in advertising or marketing... kill yourself." -- Bill Hicks
    1. Re:Dynamic Optimization by IkeTo · · Score: 1

      I don't really know, but the original sender might be refering to this:

      --- from gcc info ---
      `-fbranch-probabilities'
      After running a program compiled with `-fprofile-arcs' (*note
      Options for Debugging Your Program or `gcc': Debugging Options.),
      you can compile it a second time using `-fbranch-probabilities',
      to improve optimizations based on guessing the path a branch might
      take.

      With `-fbranch-probabilities', GCC puts a `REG_EXEC_COUNT' note on
      the first instruction of each basic block, and a `REG_BR_PROB'
      note on each `JUMP_INSN' and `CALL_INSN'. These can be used to
      improve optimization. Currently, they are only used in one place:
      in `reorg.c', instead of guessing which path a branch is mostly to
      take, the `REG_BR_PROB' values are used to exactly determine which
      path is taken more often.
      --- end quote ---

      Of course, it is no dynamic optimization, but at least it is a step closer to it.

    2. Re:Dynamic Optimization by vherva · · Score: 1

      For interesting results on the subject, see this Ars Technica article on HP's Dynamo optimizer.

      --
      -- v --
    3. Re:Dynamic Optimization by be-fan · · Score: 2

      I don't think you realize that you aren't talking about dynamic optimization, you're talking about optimizing compliers in general. A dynamically optimizing complier has a few edges over a statically optimizing complier, but in general, the static compiler wins. Think about the differences in hardware archicture. Aside from something like an OS, a developer already knows what CPUs their program will be used on. If I make a performance critical program now, say a 3D renderer, I know that it will be used on PIIIs, PIIs, Athlons, Willamette, and Maybe K8. That's it. People will not be still using my program on K9s and 10s. Sure some people use older programs, but think about it. In programs where performance really matters, do you use anything older than two years?

      --
      A deep unwavering belief is a sure sign you're missing something...
  127. Java vs ? by chris.bitmead · · Score: 1
    I think like most people, the first time I realised Java speed was in the same general ballpark as C I was surprised.

    The pity of it is that the Java VM is not quite general enough to cleanly and nicely support all kinds of programming languages. Wouldn't it be nice if you didn't _have_ to use the Java language to take advantage of all the work put into the VM and libraries? Not that Java stinks that much, but lets face it, there are better things out there for sure.

    Well of course you can, you can use Kawa for example to write Scheme, but there were a lot of hoops to jump through to do it and even then there are difficulties.

    I guess Sun couldn't care less about this. Probably they actually consider it a feature. It would be great if the open source community developed a competing VM specification that is designed to support pretty much all languages equally as well.

    1. Re:Java vs ? by MythMoth · · Score: 1

      Hmm. Well, circumstances would seem to support your view; there aren't many alternative languages for the JVM therefore it can't be easy to do.

      On the other hand, I can't imagine having much difficulty implementing a C compiler in Java, therefore I wouldn't have thought that byte code had any inherent restrictions to prevent you from so doing.

      Having used C and C++ extensively, I would always choose Java over these where execution speed was not imperative. And if speed were of prime importance I wouldn't be likely (even with these results) to use a bytecode environment.

      So I don't really need alternatives; maybe this is the reason few exist ?

      --
      --- These are not words: wierd, genious, rediculous
    2. Re:Java vs ? by JohnZed · · Score: 2

      No, there are definitely limitations in the bytecode. I wrote a compiler to take another language (Tiger, it's a toy language, kind of like Pascal, I guess) to Java bytecode. It was definitely like fitting a square peg into. . . well, you know what I mean.
      Java bytecode is completely centered around the Java class system. So it has low-level primitives to handle virtual methods, Java interfaces, exceptions, and all of that. But, as a result, it's really painful to use something that can't be shoehorned into Java's class system (though it can be done with lots of "static" junk).
      JPython does a REALLY beautiful job, though. I highly recommend it to anybody interested in a high level language for the JVM (www.jpython.org).
      --JRZ

  128. It doesn't matter... by Karma+Sucks · · Score: 1

    ...what the analysts may say.

    As a user, for me Java applications are second-rate applications. The bottom line is that on my computer and OS of choice they slow and buggy as hell. That is my perception as a user, and until that problem is addressed, really, who cares what the numbers say?

    Mind you, as a developer, I love Java.

    --
    (Please browse at -1 to read this comment.)
  129. Although Java still sucks... by JoostFaassen · · Score: 2

    ... I'd have to congratulate whoever came up with the coffee cup to attract all those coders :)

    --
    This post is powered by caffeine
  130. Re:Some Schools... by Ambien · · Score: 1

    You're a fucking moron. I would argue against what you said in that post, but it is so retarted that isn't worth any more keypresses then what is here. I pray to God that you are just trying to be a troll, and you're not really serious.

    --

    WAR IS PEACE, FREEDOM IS SLAVERY, IGNORANCE IS STRENGTH. The Party - 1984

  131. Re:Why do we need Java: by Graymalkin · · Score: 2

    Uh dude? Most companies who want to make a profit on their software don't want to release their code to the public without licensing fees. Open Source is not nearly as profitable as closed source. Support and advertisments are pidly shit compared to licensing fees. And to help you out, Java is a good language for portability because there is no porting. If you want it to run quick on your processor you just compile the code for your system. C++ and C are portable but across platforms you need to make library changes and such things. Java needs none of that. And of course you can always compile a Java applet as just bytecode which will be run on a machine's JVM. If we could get some JVM modules in our kernels things would be awfly nice...

    --
    I'm a loner Dottie, a Rebel.
  132. Affaid of new things? by slamouritz · · Score: 1

    first off , pick the tool that suits your need. Now with that out of the way, i must vent my frustrations. I really cant understand the all the "Java is slow", "Java dont work" , "Java arent opensource" i am getting from my fellow coders around the world. Most of which never have use the language for a serius task. (cumon, a hello world applet arent a application). It seems like the Java is facing fire from to camps, both the Pengiun coding dudes, AND the Microsoft community. The Microsoft coders i understand, they see Java as an attack on their bread and butter, VB. But the linux folks? Why? As an example i created a node on a certian (very cool)website (claming to contain Everything :o) about why you should use serverside java for webside application logics instad of perl based CGI.. Im a freaking consultant, people pay me to hear what i have to say about theise things(and I actually have tested thiese things in different senarios). But my node? Was offcource heavily down voted(same as bad carma), and well i guess that tells a bit about our linux developer community. Look at the other comments.. The linux developers have a problem. They do not belive in the saying "use which tool fit".. They just wanna code C/PERL/Phyton or what ever..
    I know i am being very general in my judgement, but I belive the fact that Linux users are a bit TO nerdy for their own good. I for example have convinced my boss(a side node is that we are VERY much in bed with M$(i work for Denmarks third largest IT consulting firm)), that Open Source arent that bad an idea for consultant firms. But convince one of my good (linux using)friends to try out photoshop for instad of that crappy little gimp(i hate it.. after working with Image manipulation programs like PhotoShop, Photogenius(amiga) and likes.. It seems very unmature(well, stop crapping D, and help out..!)) they blow up.. Why? ALLWAYS LOOK AT THE JOB YOUR DOING, THEN PICK A TOOL TO DO IT WITH

    --


    "Theres alotta savages in this town.."
  133. Some Schools... by Ambien · · Score: 1

    At some technological Universities such as Michigan Tech they have actually dropped C/C++ as a class, and have replaced it with java. If you want to learn C/C++ you have to take this small post Java class that basicly only teaches you the difference between the two languages. Personally I think it's stupid to replace C/C++ with a language that's less used in todays industry.

    --

    WAR IS PEACE, FREEDOM IS SLAVERY, IGNORANCE IS STRENGTH. The Party - 1984

    1. Re:Some Schools... by kb9vcr · · Score: 1

      The university that I attend has actually started to mix classes. Some professors want to teach in java and others in c++. Replacing c/c++ completely seems to be a horrible idea but mixing them appears to work well. The more languages you know the better perspective you have on coding a solution to a problem. Since you're able to break away from a particular 'coding mindset' when you learned a language you don't feel so locked down. I know it's helped my coding a lot.

    2. Re:Some Schools... by jilles · · Score: 1

      A universities job is not to learn students how to fix memory leaks (an activity that cannot be avoided by newby c programmers) but to learn them the basic concepts of programming. I started university in 94 (with ansi C), I had to learn the hard way about pointers. The year after me they used C++ (same problems). The year after that they started using Java (and they still use that as far as I know).

      Java is good as a teaching language because it allows teachers to get to the point quickly (OO, how to properly design, etc.). Once you're a good programmer it is pretty easy to learn new languages. I learned quite a few different languages during my study and consider that to be very usefull. I'm a researcher now but if I were to go work in industry I would be up to speed programming whatever language used in that company in no time.

      --

      Jilles
    3. Re:Some Schools... by DanaL · · Score: 2

      Well....I used Pascal in my first couple of years, and I don't seem to have been hampered by it. Thing is, your courses should be teaching you programming concept..."How to program", not "How to program in Language X". If you know one language reasonably well, it is generally pretty easy to jump between languages. Unless you go to an odd-ball like APL :)

      My university switched to Java from C++ because of the perception that it is easy to learn, and because they were having problems will people using different compilers. The profs were answering more questions about compiler warts than programming. At least in Java, the warts are relatively standard across various platforms :)

      It's also easier for the profs to do interesting graphics assignments, small games n' stuff that are more interesting to most people than, say, printing out Fibonacci numbers.

      Anyhoo, my point is, the language taught in the first two years doesn't make a lot of difference.

      Dana

    4. Re:Some Schools... by EnglishTim · · Score: 1

      A University's job is not to 'learn' students at all. It is to teach them...

  134. My crappy typing by catseye_95051 · · Score: 1

    Try : "And the big benefit Hotspot gets here is that Hotspot inlines recursive calls to a certain depth. I doubt the C compilers are doing that."

  135. Re:These number are worthless... (unless you read by havardw · · Score: 1

    100 is the baseline. 110 means 10% faster than 100

  136. Re:Wrong again... by chris.bitmead · · Score: 1

    You're wrong because Java is a compiled language, just one compiled at run-time.

    This is unfortunate for start-up times of gui apps because the whole swing stuff needs to be compiled on startup. I'm sure someone, sometime will solve that. In the meantime it's fine for non-gui apps, and not all that bad for gui ones as well.

  137. Re:Optimal FFT was not the point by IkeTo · · Score: 1

    I have the impression that the aliasing problem happen only on "real" programs, not on benchmarks. Aliasing is usually a problem only if the program contains a number of function which calls each other. At this point there are ways for variables to be aliased. For benchmarks, usually every big things happen in a single function which define everything as local variables, there is no problem of alias at all.

  138. There's at elast one mistake... by catseye_95051 · · Score: 1

    ... if you're running the raw 1.3 then your running Hotspot 1 -- client. Try Hotspot 2 for Servers.

    Again I'd like to know all the details of your envrionment. If your running so low on memory that Java is swapping, for instance, then we KNOW what the outcome will be before you start.

    Nobody has suggsted that a VM can run in as memory tight conditions as native aseembly code executables do. That would be ratehr amazing if anyone pulled it off. BUT memory is below a buck a meg these days. I'd argue systems with less then 128meg are becoming pretty rare and outdated. After all, even Winfroze 2K requries more memory then 64M.

    1. Re:There's at elast one mistake... by SomeOne2 · · Score: 1

      ... if you're running the raw 1.3 then your running Hotspot 1 -- client. Try Hotspot 2 for Servers

      That's true, I only use the standard JDK 1.3. Perhaps someday... (I code quite a bit in Java but only for fun; I earn money with C++ :)

      Memory usage is ok, total memory usage of all processes is about 80MB which is well below 128MB (no swapping). Oh, I just remembered that I even have a Microsoft JVM installed (a short check later...) it's about as fast as the Sun JDK, perhaps a tiny bit slower (about 1-2%, could be inaccuracy)

    2. Re:There's at elast one mistake... by catseye_95051 · · Score: 1

      This is on Windows right? I thought i better check that. On Linux you'ld need to use the just-released Sun JVM for Linux.. which is in beta so its a bit of an unfair test even so.

      I know that Hotspot2 can run more or less neck and neck with the IBM VM. IBM wins on bounds checks. Hotspot wins on memory allcoation/deallocation. Obviosuly both teams are workign on integrtating the other teams' advantages and, over time, they will grow closer and closer together,

      But if either IBM or Sun can keep up with the C code, then thats really the point. Java today can give a respectable performance v. C. Considering the C compilers are mature products and the VM/dynamic compilers are still actively growing and developing, ist l;ikely that in the not to odistant future we will here peopel syaing "why can't C have a dynamic compiler???" :) :) :)

  139. Danger! Deceptive Graphs. by triso · · Score: 2

    Hi,

    Those graphs in the article are extremely deceptive since the y-axis does not start at zero. If they did, the curves would be much closer together. As it stands the difference between most curves is less than 30 percent and that is nothing to get your shorts and knickers all bunched up over.

    Still, it was a good article even though the sample programs are a little trivial.

  140. Self optimizing binaries? by Canis+Lupus · · Score: 1

    There were a couple of ideas from the article that struct me. A) Java is run-time optimized B) Java requires (most of the time except things like jcc) a JVM. Another point mentioned was that the size of memory blocks allocated by one of the JVMs (HotSpot?) would adjust to conditions given enough time. Well, I wonder if any one has considered a system whereby the JVM caches and constantly improves operating parameters for a given program (somewhat like Transmeta's architecture).

    Of course, this raises some classic questions about amount of resources to spend on optimization vs. running the code, yadda, yadda, yadda.

    Oh well. It is early and it is going to be a long day....

    --
    The real silver bullet to good programs is caffeine; lots and lots of caffeine! *twitch, twitch*
  141. It's all about optimization by jmv · · Score: 5

    I can't comment about the other tests, but I've looked at the FFT code and can say it is very badly optimized. There are some things a C compiler can't optimized because of aliasing, but a Java compiler can. There are ways to code these kinds of things so it can work, for example doing explicit loop unrolling. In the FFT code he had, the FPU pipeline would always be stalled, because lots of loops only have 4 multiplications and 2 additions.

    What makes me even more suspicious is that I have a K7-500 too and I have done some tests with a heavily optimized FFT (fftw) and I get a performance around 400 mflops. There's just no way a JVM can be 220% faster than that. So my comclusion is "with poor code and poor optimization, Java can be faster than C".

    I don't want to take position of the whole Java vs C speed, but what I'm saying is that at least his FFT test is flawed.

    1. Re:It's all about optimization by GooberToo · · Score: 3

      You do a wonderful job of highlighting why it hard to get meaningful benchmarks for applications when presented using different languages. Some languages work well with certain constructs, as such, can optimize a specific implementation rather well. Likewise, the same construct, my not be able to be optimized at all in another language.
      A good example of this is Perl programmers moving to Python. If you do things in Python the "Perl way", typically, it performs rather poorly. Likewise, if you do it the Python way, it performs on par with Perl.
      This highlights the fact that no optimizer can replace a good programmer with good design skills. It does, perhaps, highlight that perhaps you can get reasonable results with less skilled programmers using Java than you might get with C, or especially C++.

    2. Re:It's all about optimization by drew · · Score: 1

      your comment reminds me of a quote i found on this page (discussing duff's device) that said:

      "A second poster tried the test, but botched the implementation, proving only that with diligence it is possible to make anything run slowly."

      --
      If I don't put anything here, will anyone recognize me anymore?
  142. Re:This article is not supposed to be ... by pivo · · Score: 1

    Let's get a full qunatification of the speed differences between C and assembly, then we'll talk. Meanwhile, asm rules.

  143. C Compiler comparison by Idaho · · Score: 1
    The results bring up some more interesting questions: In what circumstances is GCC faster then MSVC, and why?

    Has anyone looked at this subject? It may bring up interesting results: even in this test GCC did generally better then MSVC, and MSVC is available on 1 platform only (Windows), while GCC is available on many.

    --
    Every expression is true, for a given value of 'true'
    1. Re:C Compiler comparison by Glenn+R-P · · Score: 1

      The results bring up some more interesting questions: In what circumstances is GCC faster then MSVC, and why?

      On a Pentium II/MMX, gcc 2.7.2.1 (fairly old now) generates a faster-running zlib (compression library) than MSVC++6.0 Standard Edition. I don't know how the Professional version fares, but I presume it would be a lot faster.

    2. Re:C Compiler comparison by be-fan · · Score: 2

      It would be a great deal faster since Visual C++ 6.0 Standard doesn't do any optimization.

      --
      A deep unwavering belief is a sure sign you're missing something...
  144. Re:Too good to be true by mbaker · · Score: 1

    The latest JDK is only in beta for either Solaris or Linux, which hardly constitutes "Java 2 v1.3" as being available.
    Plus, this is Java's mantra; "Write once, run anywhere."

    Java applications, in general, will start off being memory hogs. This is just allocating memory for the VM, for use with the application when needed. This of course is only part of Java's memory footprint, in any sizeable application.

    Even non-graphical Java applications can be slow. For instance, take a look at Sun's own Java compiler for JDK. Compare that to Jikes ;-)

    C and C++ interface programming is not defined by one paradigm, so it doesn't belong in your statement regarding slow graphical Java applications. You can use any number of design patterns, for any number of toolkits, so it's an inappropriate blanket to group it with AWT.
    Anyway, If you were to use MVC with C, would you somehow consider the interface faster?

    Using the MVC paradigm will not make a Swing application faster. Generally speaking, it means using more classes. This means larger bytecode, and more memory consumption. Of course you can clump more or less all of the interfaces into one class, but this isn't really following the MVC paradigm. If anything, it defeats the purpose.

    Swing also has the disadvantage (over normal AWT) of having its widgets implemented in Java. This is why Swing applications feel much more sluggish to even AWT applications. No matter of paradigm can help that.

    This, of course, doesn't even cover the tons of drawing problems Swing has.

    That said, Swing certainly has a good API; the only interface API I like more is GTK--'s.

  145. LPC by Rei · · Score: 1

    Ok, go out and write a program in java.
    Then, go out and write the program in LPC.

    Now, tell me which one has a better object oriented design philosophy.

    If I had to rate how well a language was designed to be object oriented, I'd rate them as follows (on a 1 to 10 scale):

    C: 0
    C++: 2
    Java:3
    LPC: 10

    Too bad lpc isn't generalized to be used for any task. I wish someone'd write extensions for the language.

    In case you want to know what I mean by how smooth objects work in LPC, I'll put it this way. In lpc, for example, you can do a switch statement on an object (or a string, or any other variable for that matter). Objects can be referenced in many different ways, from simply running functions on the filename of the object in question, to using find_object to find objects matching certain critera to filtering through all objects currently loaded in memory. (this is neglecting the simple way, of just storing it in a variable when you create it - this is assuming what you're writing knows nothing about the object). Everything just interfaces so smoothly in lpc... grr, I miss it : P

    - Rei

    --
    Hey, guys, I'm just pleased as punch to report that it's a fleet of a hundred Vogon Battle Destroyers!
  146. my problem with this comparison by Rei · · Score: 1

    My main problem with this comparison is the fact that its quite apparent that this person is attempting to distort results. For example, they try to make it look like some C and Java compilers are running several orders of magnitude faster than the others, but if you look at the scale on the side of the graph you can see that they're all running fairly close to each other in speed (it doesn't start at zero). This is a commonly used distortion tactic by people trying to push something. Memory issues aren't addressed, nor is load time, two of the biggest issues. Then, the person pushes a statistic that java code is developed 2 to 4 times faster than C code. From my experience with college projects this is just *not true*. This is a statistic, assumedly pushed by Sun, to get companies to make their programmers use java. Compare the file size of a java program vs. the size of a c program, and the first issue (amount of "stuff" you have to write to make the compiler content, since it refuses to typecast even the most simple of things (if I do "if (someint) { do_stuff(); }, it should compile, dern it! ;) ).

    Not only amount of typing should matter, of course. You need to look at debugging time. Java doesn't debug for you. I haven't found the language to be less prone to any kind of bug except memory leaks, but it eats up so much memory on its own it might as well have them. As for its multiplatform aspect, it doesn't even work the same with different JVMs, let alone different platforms.

    So, I cast my vote against java here. The only thing I found it did better than C is object oriented programming, and yet its implementation of that is still quite poor. If sun writes another programming language, I'm not going to touch it with a 10 foot pole, and use a language written by people who know and care what they're doing, not just trying to hype something.

    - Rei

    --
    Hey, guys, I'm just pleased as punch to report that it's a fleet of a hundred Vogon Battle Destroyers!
  147. Re:Java is a FAD. by NulDevice · · Score: 1
    Java under LInux != Java under MacOS != Java under Windows != java under Solaris.

    While this is true, it's not supposed to be. By design it's supposed to be write-once, run-anywhere. It's just stupid vendors who try and subvert this idea. Java under Linux and under Solaris are essentially the same...I've personally never had any issues between the two. Windows has it's own special problems, thank you M$.

    on the Mac, Java can take three forms, Apple JVM, Microsoft explorer JVM, or Netscape JVM

    This is the problem. It shouldn't be like this at all. A JVM should be a JVM, regardless. Maybe some performance differences, but Sun's and Apple's and Netscape's should all be in line. This pisses me off to no end. Corporate short-sightedness is ruining an otherwise wonderful concept.

    Microsoft's fux0ring of the JVM is to be expected. But I don't know what Apple or Netscape's excuse is.


    ----

    --

    ----
    "I used to listen to Null Device before they sold out."

  148. What memory allocation? by bored · · Score: 1

    Has anyone looked at the code? I looked at some of his C code. Its in the directory with the makefile life.c, fib.c and fft.c

    Take a look at life.c and draw your own conclusions.. For example

    init0 = (int*)calloc(max_x,sizeof(int));
    init1 = (int*)calloc(max_x,sizeof(int));
    init2 = (int*)calloc(max_x,sizeof(int));
    for (x=0; x&lt max_x; x++) {
    init2[x] = 0;
    init1[x] = 0;
    init0[x] = 0;
    }

    I could at least double the speed of his code in about 15 minutes. I didn't look at his java code but I suspect there aren't nearly as many dumb things in it.

    I might have just blown the whole thing off if it weren't for the fact that he claims MSVC with full optimization is slower than GCC in 'braindead' mode for a couple of tests. I've seen code GCC generates with -O, it makes me laugh.

  149. Who cares FFT unoptimal (re: headline misleading) by GringoGoiano · · Score: 1


    Perhaps the FFT algorithm used in the benchmark's C version isn't hand-optimized. The hand-optimization works because it relies on deep knowledge of the FFT structure that no optimizer can hope to grasp. I THINK THIS IS BESIDE THE POINT.

    The person who wrote the benchmark just needed some compute-intensive algorithm, and a simple FFT does OK, and is a perfect stand-in for general floating-point/array-using algorithms. A lot of other code will look (from an optimizer's point of view) similar to the simple FFT, and so we might generalize C vs. Java comparison to general computational algos.

  150. Re:Too good to be true by Jackrabbit · · Score: 2

    Sorry about the mention of C/C++ when I was talking about coding paradigms for GUIs. I'm not a C/C++ coder by trade, so I'll gladly rescind my inclusion of them in my statement.

    You actually make my point quite well without this, however.

    Swing is built from the ground up on the MVC paradigm. If you do not use this paradigm when coding a Swing GUI, you'll effectively "disable" much of the work and code that has gone into Swing. No wonder people think it's a memory hog -- they're turning off half of its features.

    Swing, when coded under an MVC architecture, operates quite smoothly and quickly. For those not "in the know" on MVC, let me give an example from my own experience:

    In the old days of the AWT, if you wanted to display a list of data, the data was an integral part of the list widget. If you wanted to change the data that was displayed in the list, you would perform an operation on the list widget itself. Similarly, if you wanted the same data displayed in a table, you would need to replicate the data and insert it into your table.

    In Swing, you use the model/view/controller architecture (MVC) to separate content from display. Actually that just accounts for model and view. The controller refers to the interaction between the data and the display. This control is typically bundled together with the view (display widget), but can be separated out rather easily.

    The benefit of the MVC paradigm becomes readily apparent when you take one of the examples I used above. If you want to display the same data in a list and in a table, you don't need to replicate the data. You set the model for both of the GUI widgets to the same source. When you want to change this data, you simply change the source (the model) and both of the GUI widgets are automatically updated with the change (all Swing GUI widgets have listeners on their models that watch for changes).

    With a subtle change in your coding model/paradigm, you can acheive _huge_ benefits in both coding time and performance by simply operating within the parameters that Swing was built on.

    In regards to your question of using MVC with C, it would have to depend on the libraries that I was using in C. If the libraries that I was using were built to use MVC, then yes, I would consider this a better idea. If not, then no, I wouldn't use MVC. The use of MVC is really up to the individual's coding style, much like OOP in general. However, if you don't want to code using MVC, then don't choose a tool that is based on it.

    If you don't like OOP, then you really don't want to program in Java. Similarly, if you don't like MVC, then you really don't want to code in Swing.

    --------------------------

    --
    In the immortal words of Socrates, "I drank what?!?"
  151. mod_perl still slower than servlets by mikemulvaney · · Score: 1

    mod_perl is much better than standard cgi, but it doesn't even touch servlets.

    First, mod_perl doesn't eliminate the startup time. Each time a new httpd is forked to handle requests, the script must be recompiled. Is there some way around this?

    More importantly, servlets answer all the requests from one instance of the servlet. This makes it extremely easy to reuse database connections, share information between requests, track sessions within the servlet, etc. Java servlets are much more powerful than mod_perl for that reason alone.

    Mike

  152. Benchmarks by bogado · · Score: 1


    I am not here to question this benchmark, but have any one notices that this result shows how easy is to fake a result? Each of the compilers have at least one that it goes well, so let's say that I want to make a benchmark that says that gcc is the best. What I do is to do this study and then publish a lot of data or create a lot of tests that are similar to first (and maybe taking other areas in witch the gcc is good from the other graphs).

    Then I publish the resulting benchmark, but don't mention the firt batery of tests or how I choosed witch test I would use.

    This is also true for statistics, statistics can be used to prove/unprove almost anything. Did you know that you have 50% of chance of not dying? Yes this is true for only half of the people that ever borned had actualy died.

    --
    "take the red pill and you stay in wonderland and I'll show you how deep the rabitt hole goes"

    --
    []'s Victor Bogado da Silva Lins

    ^[:wq

    1. Re:Benchmarks by ChrisRijk · · Score: 2
      It's even worse than that - some tests show one on at top at the start, and someone else on top at the end... Very easy for press release writers to selectively choose what to show.

      This is why most 'real' benchmarks are actually a suite of tests, and the final result is just an average.

  153. J2SE 1.3 is better, but J2SE 1.4 might be sweet by ChrisRijk · · Score: 2
    1.2 was slow. (from what I hear, this is basically because a load of develoeprs went to Sun and said "we can't live without X,Y,Z,etc" and doing all that slowed things down a lot). 1.3 managed to recover from this - ie back to 1.1 levels.

    From what I hear, there's a big wodge of effort going into improving graphics performance for 1.4, and it's already well underway. Of course, it'll be at least a year away, *sigh*

    The embedded Java market seems to be taking off though...

  154. Re:metadata by lordpixel · · Score: 2

    Certianly the meta data for each class is huge, often bigger than the code itself. Still both Sun and (believe it or not) Apple are putting in work designed to only load the parts of JAR files that are actually used, I believe (though this is vague and from memory) by memory mapping the file and providing a good index so classes are loaded on demand. (some of this may already be in Java 1.3). The other strategy is to enable the sharing of meta data more effectively, or so I'm told, but I'm not sure what it meant by that... Smart people *are* working on the memory overhead. Sun is claiming up to 40% reduction in memory for the new HotSpot in JDK 1.3, but by all accounts 5%..20% is the common range. Still a 20% memory saving is very good.
    Lord Pixel - The cat who walks through walls

    --

    Lord Pixel - The cat who walks through walls
    A little bigger on the inside than out

  155. Re:How Java Floating Point Hurts Everyone Everywhe by ChrisRijk · · Score: 2

    I'll check it out fully sometime, but some things are definately out of date. (the authors also seem to have a flair for the dramatic) I haven't done a great deal of FP work in Java, but I'm quite happy with the results.

  156. Visual C++ Test is a bit unusual. by be-fan · · Score: 2

    The poor showing of Visual C++ was very surprising, given that Visual is held to be one of the fastest x86 compilers. The fastest x86 compiler at the moment is Intel's own x86 compiler and it would have been interesting to see how it would fare on the benchmark. I have done performance tests between Visual and Intel's on graphics apps on a PII, and Visual's is rarely more than 5-10% behind Intel's. A future extension to this could be to test this code with Intel's compiler since it is downloadable on the web (full but time limited) and easily pluggable into Visual. I suspect that the weakness of the Visual complier may have something to do with Microsoft not optimizing as much of a non intel CPU and the recent K7 optimizations gcc has gotten.

    --
    A deep unwavering belief is a sure sign you're missing something...
  157. Message from the author by ChrisRijk · · Score: 4
    Hi, I actually posted this to Slashdot last night... and it's still sitting in the pending queue, heh.

    Another post I sent in last night which quickly got rejected was this:

    • Although Sun released Java 2 Standard Edition 1.3 for Windows a few weeks ago, until now there hasn't even been a beta from Sun for either Linux or Solaris, until tonight.
    • J2S E 1.3 for Linux Beta (for x86) which also includes HotSpot Server. This was with the help of the Blackdown guys, though the credits are in a somewhat obscure place. J 2SE 1.3 for Solaris Beta SPARC and x86 (includes HotSpot Server) was also announced today. In the future, releases for all platforms will be at the same time.

    Unfortunately, that release came a little too late for me to do much about, though I have quickly tested the Solaris x86 (on the same hardware as the Windows tests), and the rests are pretty much identical, though Solaris was a bit faster. (but then, I was running without the desktop running which does help).

    Also coming a bit too late was results from IBM's Windows 1.2.2 JDK, which I found a bit surprising - it did worse on some tests, and better on others, though I didn't have much time to test things.

    Thanks for the replies... kinda makes it all worth it - it took me about 100 hours over 4 weeks to do this. (took up a lot of my evenings)

    I better re-install Linux sometime so I can test on it again... (my last install stopped working for unknown reasons)

    It'll probably be some time before I update the article - first I want to finish off my MAJC article, which really is too damn big. (22,000 words... ouch).

  158. Re:Java is a FAD. by Betcour · · Score: 1

    I don't think so - Pascal is fully capable of dealing with very large projects. I think the Mac apps used to be coded in Pascal...

  159. Re:How Java Floating Point Hurts Everyone Everywhe by GodSpiral · · Score: 1

    Java 2 added some accurate cross platform math classes to address these issues.

  160. Re:Too good to be true by mbaker · · Score: 1

    You really don't need to replicate data, when it's stored in a widget, in those archaic and poorly designed systems that do that ;-)
    You could just as easily query the widget, and then store changes back to it. This is somewhat similar, in effect, to doing this by event.

    What you'll conserve in memory, you'll lose in execution speed, since you need to use several function calls to retrieve information.
    Alternatively you could cache model data, and update on hearing of a model being changed, but then you don't conserve memory.

    I honestly think Java's MVC memory consumption problems are mostly to do with the class overhead involved, and its interpreted nature.

    As for the C MVC question, it was a bit rhetorical. A pure non-caching MVC system would be slower than a statically designed interface and model in one big clump. This is simply a matter of function call overhead and the like.

    This, however, really doesn't matter in my opinion. The benefits are clear; ease of extensibility and portability. Proper object oriented C++ will be slower than procedural C, at a specialized task, but the development time difference is clearly in favor of C++ or object oriented C.

    Swing's slowness goes beyond MVC, though. Certainly the class and function overhead is part of it, but ony a part. No amount of "proper" MVC coding will remove the unfortunate overheads. A faster VM would certainly help, and perhaps better algorithms in their painting and event dispatch schemes.

  161. A good tool can do anything by bug1 · · Score: 1

    I use nail clippers to undo the hex-screws on the serial ports/ video card etc. Its not the right tool for the job, but its a pain in the arse and downright inconvenient to use the correct tool all the time, any blunt instrumment works as a hammer.

    Java is elegent to program in, but its not easy for the end user, programmers are expected to understand what goes on under the hood of a computer, end users arent. Java and all these other languages that supposedly save programming time and just a cop out, programmers waste time learning multiple redundent languages.

    Java is and always will be a cripled language that places limitations on what applications it is suited too. Java will never be a general purpose languange without proper hardware access.

    Java will never be free, sun is just a microsoft wannabe, they are just dangling the carrot infront of our faces and watching us stretch. Does anyone really think sun is commited to open source ?

    As an alternative to learning a new language for every programming task you undertake it would be much more efficient to learn one language and master it, if you know c well you can do anything with it, c places no limitations on what you can do.

    Yea, i wish c really understood what a string is, but its easier to adapt and overcome c's inconveniences than it is to try and avoid them.

    I used to be a java fan, but have turned my back on it for the above reasons.

  162. Not entirely controlled by Sun... by SuperKendall · · Score: 2

    Many people think Java is controlled by Sun. However, that is not entirely the case - for just about any area of Java you care to name, there are mailing lists and discussion forums where they discuss developments of various API's, and they really listen!

    I know, I subscribed to the Java2D mailing list for a long time before they released the API. They asked the list many questions, and listened to everyone. Sometimes they shot ideas down if they thought they just were not a good idea (support for pallete cycling was one example here), but at least they listened to complaints about the way the API was going and did make changes based on input. One member even went so far as to code up the whole propsed Java2D API so people could try it out in practice and make comments.

    Similarily, programmers have the opportuninty to voice thier opinion in code which is released under the SCSL (Sun Community Source Licence). Is it really "Open Source"? No. But then again, it does give you the opportunity to fix things and talk to the developers about how things are in Java in the clearest way possible - through code. Think of it as "free speech" where only one person showed up to hear you talk.

    It is still true that Java is under Suns' control,
    but never before (that I know of) has a company had a product with as much outside review and commentary in development.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  163. Swing performance by Anonymous Coward · · Score: 1
    I actually did projects with swing that were huge! I have several performance comments:
    1. AWT was a mistake, Swing came late into Java and thus suffers in performance. It takes time to mature.
    2. Swing in JDK 1.2 was slow. JDK 1.3 is actually good since they focused on speed and stability.
    3. Swing is fast since it can embed a large amount of components without degrading speed. However buttons menu's etc... Don't feel fast, this is a persived sense of speed derived from the responsiveness of the GUI which needs fine tuning in Swing. It is being addressed (and was partially in 1.3). This still allows Large and very complex GUI's to be constructed in Java (such as JBuilder)
  164. Why I HATE Java by Anonymous Coward · · Score: 1

    At work we used an oracle database with a charater based frontend in a Terminal Emulator on a Pentium 133 MHz and everyone was happy with it. Now we have a Pentium III 700 MHz with a JAVA based frontend and everything is at least 5 times slower ... That's why I HATE JAVE

  165. Re:Java is a FAD. by cbr372 · · Score: 1

    Gah. Short sighted posts like this infuriate me.

    It's an echo of what happened years ago: "Real Programmers don't use structured languages like C. Real Programmers use FORTRAN. If you can't do it in FORTRAN, do it in Assembly, if you can't do it in Assembly, it isn't worth doing. C is a cute toy language, but just no good for real world applications. The UNIX hackers who use it aren't sure wheter the print command is 'printf' or 'cout' this week, how is it ever going to manage to survive in the real world ??"

    Yeh. C forever. I don't know wheter or not Java will be the next-wave language, but saying that "C will never be replaced because there's nothing better" is just kind of moronic.

    --
    Cedric Balthazar Rotherwood
    Sun Certified Programmer for the Java Platform +
    System Admin. for Solaris
  166. Volano tests a chat server by ChrisRijk · · Score: 2

    If you're actually running a simple chat server, then the results are okay, but Volano doesn't actually test Java optimisations very well as it spends most of it's time in pre-compiled static code, including the OS kernel.

  167. Optimal FFT was not the point by ChrisRijk · · Score: 2
    I actually spent about 5 hours trying to find a nice FFT in C that I could easily convert to Java. In the end I found an FFT routine written in Java (though the author ported it from a C routine) and converted it to C. However, I was more interested in testing the compiler/optimiser and generic language differences than trying to come up with a really good FFT.

    Btw, when you say "There are some things a C compiler can't optimized because of aliasing", do you literally mean it would be impossible for any (legal/correct) C compiler?

    If you have a nice FFT that can easily to 'converted' to another language, I'll be happy to try it out...

  168. Re:These number are worthless... (unless you read by damm0 · · Score: 1

    That's fine and all, but I think the point of the original poster is that since you don't know how fast the baseline is, then you don't know how fast any of the others are. Sure they are 10% faster, but faster than what? If it means that it takes 10 seconds to do one round of the Game of Life with GCC, and then HotSpot does *two* rounds in ten seconds, then sure it is 100% faster, but who cares! It is still unacceptable!

  169. Re:Java is a FAD. by HerringFlavoredFowl · · Score: 1

    the language is irrelevant...

    what is relevant is using the tool that will best get the results you want for the shortest design cycle / lowwest development cost / highest spec compatibility.

    Borland's (InPrise) C/C-- Compiler is written in OOP Pascal (product name : Delphi). Actually the Borland OOP Pascal / Java objects models are almost identical. You want native Java code try Delphi (loose32) / Kylix (happy penguin and loose32 with qt ). Different language, same model..., faster (?) code.

    TastesLikeHerringFlavoredChicken

    --
    TastesLikeHerringFlavoredChicken
  170. Purpose built processors Re:Wrong... by WolfWithoutAClause · · Score: 1
    'On traditional processors: probably, but what about the MAJC processor (see article) or Crusoe?'

    Purpose built processors don't usually help. Sure they start off fast, but unless you have a huge development budget (and Intel has a huge budget!) you quickly get outdeveloped and then you are slower.

    I love the crusoe tech though. Because it's smaller it might help keep development costs down.

    --

    -WolfWithoutAClause

    "Gravity is only a theory, not a fact!"
  171. Locking and reference counts in Java = Slow? by chafey · · Score: 1
    Since java reference counts objects, I always assumed it has to protect the count with a mutex for thread safety. Can anyone confirm this? If this is true, Java will never beat a well designed C/C++ application because of the locking overhead.

    Doing tests on numeric calculations is useless, because a JIT can generate the same code that the C/C++ application is using. I would like to see tests where the application had many threads, the computer had multiple processors and objects were continually being created/destroyed. I am pretty sure that Java would be 50% of the speed of a C/C++ application in this kind of test (which is certainly more real world than "life"). Chris Hafey

  172. Re:Java is a FAD. by fuzzcat · · Score: 1

    I can't say that Java is going to be the next big language, but I can certainly say that its design philosophy is excellent. In a world where operating systems want to make their APIs so convoluted and complex that no one would want to port them to another platform, Java is turning the tables. The idea behind Java is that if I choose I can write software for Windows and Linux and MacOS and any other machine that's running a JVM.

    Granted, I know that Java isn't quite there yet. I personally experienced the pain of moving some of my Java programs that I had written under Windows and moving them to Linux, my new OS. And honestly Java seems to take a performance hit by compiling to byte codes and doing run-time optimization.

    The strength of this article is that it points out (with some tentative evidence) that the performance hit doesn't seem to be nearly as bad as we (or at least I) thought. Perhaps the author is right. Maybe the problem isn't because of byte code compilation. Maybe it lies in the relative newness of Java as a language/platform.

    Someday C will be superceded by another language. That language may or may not be Java. Honestly I'll probably keep programming in C, but I'll definitely keep an eye on Java as it matures.

    --
    "The further I get from the things that I care about, the less I care about how much further away I get." -Robert Smith