Slashdot Mirror


Linux Number Crunching: Languages and Tools

ChaoticCoyote writes " You've covered some of my past forays into benchmarking, so I thought Slashdot might be interested in Linux Number Crunching: Benchmarking Compilers and Languages for ia32. I wrote the article while trying to decide between competing technologies. No one benchmark (or set of benchmarks) provides an absolute answer -- but information helps make reasonable decisions. Among the topics covered: C++, Java, Fortran 95, gcc, gcj, Intel compilers, SMP, double-precision math, and hyperthreading."

318 comments

  1. 0th post by Anonymous Coward · · Score: 3, Funny

    At least if you're developing in C....

    1. Re:0th post by Anonymous Coward · · Score: 0

      Oh this 1983?

      Oh no wait it's FRIGGEN 2003 and only stubborn old farts whos brain is too spent to learn anything new is still using C...

      (ya i know C is nice for developing kernels but that's it)

    2. Re:0th post by Anonymous Coward · · Score: 0

      This.. This was funny.

      Awesome first post.

      Incredible.

    3. Re:0th post by Anonymous Coward · · Score: 0

      Translation: I don't know C and probably don't know any other language very well either.

  2. Octave by sql*kitten · · Score: 5, Interesting

    Interesting numbers. Have you considered benchmarking Octave or rlab also? (Or is there a native MATLAB for Linus now?)

    1. Re:Octave by StandardDeviant · · Score: 2

      Well, I don't know if there is a swedish localization for MATLAB for Linus' usage, but I know for a fact there is a native binary for Linux (I worked as a junior admin at my college's math department for a while back in '99). :-)

    2. Re:Octave by bezza · · Score: 2, Informative

      I have been using native MATLAB binaries for Linux for a while now...and unfortunately they are still much slower than the windows versions (both in number crunching and interface).

      --
      WARNING: This sig does not contain a joke
    3. Re:Octave by joib · · Score: 2


      is there a native MATLAB for Linus now?


      Matlab has been available for Linux since 1995.

    4. Re:Octave by Anonymous Coward · · Score: 0

      He's Finnish, you insensitive clod.

    5. Re:Octave by Anonymous Coward · · Score: 0

      Yep. And he's part of the 5% minority of Finland that has Swedish as their native tongue. Finland was a Swedish possession for a long time (700 years?).

  3. He didn't include K. by Jayson · · Score: 5, Interesting
    K is a high-performance array language. It is based on APL and Lisp. It really shines when crunching obscene amounts of data. This seems like something that would be perfect for the language. The proof of K's speed lies in KDB, a database written entirely in K. On TPC benchmarks is spanks Oracle and other leading databases (including some amazing scaling across processors: simple table scans with 2.5 billion rows take 1 second and multi-dimensional aggregations take 10-20 seconds).

    There is a quick and dirty intro to K over at Kuro5hin.

    Some more links for more inforation:
    Kernigan's benchmark test
    more examples
    Kx: the people who make K and KDB

    1. Re:He didn't include K. by Anonymous Coward · · Score: 1, Insightful

      Well, not to knock K (I know nothing about it), but the timing for database operations will almost always be based on algorithm design, almost never on compiler efficiency. Of course, certain languages make trying out different algorithms easier than others. Maybe K's good at that.

    2. Re:He didn't include K. by sql*kitten · · Score: 3, Interesting

      The proof of K's speed lies in KDB, a database written entirely in K.

      It looks like an interesting product - I'll definitely take a closer look once it goes MT and 64-bit. Seems a little strange to me that it wasn't built like that from the ground up, since it seems to rely so heavily on clever data structures and virtual memory caching. (Altho' I do note that the slave processes share memory, which is the way Oracle does it if you don't want MT).

      Also, I'm unconvinced the inverse design will work well on sparse data. In every deal there are usually plenty of unused fields on the ticket, unless you fully normalize. It works well enough with rows, you just place all the nullable columns after the non-nullable, and Oracle will simply skip over them to the next-row marker in physical storage. Inverse tables will be fast for simple aggregates, not so sure how well they would perform for complicated multi-table joins and groups with many predicates.

    3. Re:He didn't include K. by master_p · · Score: 1

      Do you think that the K language is right for big projects ? The article at kuro5hin says that K can even do GUIs easily. But in my opinion, K is not very readable. I mean, just take a look at this piece of code and tell me if after one year you remember what it does:

      / options, cf. "one factor option model ...", Black, Derman, Toy
      / typical c program is many pages. difficult to write. and slower.
      bdt:{[p;v] bn:{.5*+':0,x,0} / binomial step function
      l:(-1+%%':p)*_exp v*(2*!:'x+1)-x:1_!#p / generate approximate lattice
      l:{x:bn x;x%1+y*(+/x%1+y*)?z}\[,*p;l;1_ p] / fit wtd-discount exactly
      (*l){x%bn y}':l} / wtd-disc to forward
      bdt[*\3#%1.1;.1]
    4. Re:He didn't include K. by DGolden · · Score: 5, Insightful

      You should consider the readability of the language for someone WHO KNOWS THE LANGUAGE, dammit.

      I don't go round claiming japanese or arabic is unreadable - I just don't know the language.

      The analogy extends further - it is possible to construct almost unreadable drivel in natural languages, and it is possible to construct almost unreadable drivel even in python.

      However normal code written in python, forth, common lisp, or even, god forbid, c++ or perl is readable to someone who knows the language.

      Now, some programming languages are closer to english in appearance than others. However, for long-term use, that doesn't matter so much - it's just a barrier to entry for lazy people.

      I don't happen to know K. I do know APL, though - APL didn't look like K, since it had its own non-ASCII symbol set. I do find it difficult to read the relatively new asciified line-noise APL-derived languages. But that's because I haven't bothered to learn 'em! I do suspect they would be harder to learn than APL, since the ASCII symbols are already overloaded with so many other meanings already - but once I'd learned them, I would expect that problem to fade - just like I'm not confused that "gift" in German means "poison" in english.

      Actually, now that Unicode is widely supported, I would love to see a resurgence in APLs that use APL symbols, since they're much clearer to me - but so many people have been using the ASCIIfied APLs for so long now that that may never happen.

      --
      Choice of masters is not freedom.
    5. Re:He didn't include K. by Anonymous Coward · · Score: 0

      He doesn't consider Common Lisp either. A Common Lisp native-compiler (and most CL implementations apart from clisp-hs are) can be competitive with a c compiler or fortran compiler, provided you make sure to declare your types and use arrays of floats and not lists (duh).

    6. Re:He didn't include K. by master_p · · Score: 2, Insightful

      Now, some programming languages are closer to english in appearance than others. However, for long-term use, that doesn't matter so much - it's just a barrier to entry for lazy people.

      I don't think so. Using symbols for expressions is not the same as using English, especially if one is developing in more than one language.

      You should also consider other facts:

      the introduction of new members in the development team, especially if the new members don't know the language

      maintenance and service after installation; it may not be the original developer (who was so efficient in K) that maintains the project

      readability; after long coding hours, ',' is easily mistaken for '.', for example; and with so many symbols packed together in such tiny space, the problem only gets worse.

      learning curve; much higher than a language based on English.

      relevance to documentation/pseudocode; for example, it is much easier to make someone understand that the developed code follows the pseudocode defined in a project's specifications when the code is as close as possible to the English language than when the code is a bunch of symbols thrown together.

      Although Python/Lisp/C++/whatever are readable, this is because they are based on English. The more a language is based on English, the better it is for big project development. That's why every coding style says "use readable variable names"...If things were as you claim, we all be programming in assembly or with 0 or 1s; after all, how hard to make a mistake with 2 symbols only :-) ?

      Don't forget that Hypercard has been claimed as one of the best programming environments because of its ability to program almost in English.

      The attitude "symbols are ok, as long as I understand them" shows that you are ignorant of the issues of real development (with managers, deadlines, multiple and heterogenous environments, different coders, testers, bug reports and bug databases, etc).

      Finally, the obfuscated C code contents would not exist if code readability did not play an important role!!!

    7. Re:He didn't include K. by Ark42 · · Score: 1

      K looks even worse then M (Cache') for a DB language.
      Its almost as if somebody just `cat /dev/urandom > example.k`

    8. Re:He didn't include K. by bezza · · Score: 1
      I have never seen K before, but that code looks fairly simple...what makes it hard to read is the unfamiliarity of the array notation...take out the array notation and you have a fairly simple readable formula.

      The comment mentions that it is easier than C...I wouldn't even want to think about writing all this matrix stuff in C...my stomach will turn upside down...

      I think I should lie down now.

      --
      WARNING: This sig does not contain a joke
    9. Re:He didn't include K. by DGolden · · Score: 3, Insightful

      Firstly, I would like to echo the sentiment in kfg's reply to your post.

      Secondly, all html formatting seems to have stopped working- dunno why, so I apologise for the poor formatting of this post.

      Thirdly:

      *** Now, some programming languages are closer to english in appearance than others. However, for long-term use, that doesn't matter so much - it's just a barrier to entry for lazy people.
      ***

      *** I don't think so. Using symbols for expressions is not the same as using English, especially if one is developing in more than one language.
      ***

      O.K. I may have been oversimplifiing - but: ENGLISH IS SYMBOLS TOO. Using English is exactly the same as using symbols - since using english, or any language, *is* using symbols. That's how humans abstract. In written english you have letters, composed into compund symbols (aside: these compund symbols, "words", are often treated as primitve symbols by fast readers, whose symbol-recognition wetware seems to recognise them in one swoop.)

      Now, one could argue "then why not use familiar symbols" - but I find using familiar symbols just because they're familiar to be a bit silly and often dangerously misleading. Think of the emotive symbols "theft" or "piracy" applied to "violation of copyright law", in reality a quite different concept. Or "=" used for both assignment and equality testing (arrgh!!!!), neither of which correspond to mathematics-=, which is a statement of equality.

      ***You should also consider other facts:
      ***

      ***the introduction of new members in the development team, especially if the new members don't know the language
      ***

      It is often better to just budget for bringing the new member up to speed in the language. Or just decide to only hire "speakers" of the language in question. You'll have to bring the new member up to speed on all the little pecularities of your codebase anyway, a much harder task for the new member than merely learning another new computer language.

      ***maintenance and service after installation; it may not be the original developer (who was so efficient in K) that maintains the project
      ***

      No, but one would hire or train someone capable of maintaining it. Here's usually where the strong arguments for using COBOL or Java come in - "what if one can't hire a K developer in 3 years?", and so on. But learning a new language should be VERY EASY for anyone who calls himself a "programmer" - the hard part will be understanding the code, not the language.

      ***readability; after long coding hours, ',' is easily mistaken for '.', for example; and with so many symbols packed together in such tiny space, the problem only gets worse.
      ***

      Yes, that is true - but, interestingly, the number of lines of code written by a programmer in a day stays roughly constant - regardless of language used - so the more verbose the language, the less your programmer is doing. And non-ASCII APLs, for example, have much easier to distinguish symbols than #\, and #\. :-)

      ***learning curve; much higher than a language based on English.
      ***

      Somewhat higher.

      Note that I consider "A language based on english" very different to a language in which symbols^Wkeywords happen to correspond somewhat to english words. There are very few programming languages based on english, in which the grammatical structure of the language corresponds closely to english. Many programming languages, however, have keywords based (loosely - printf ??? like "print" followed by a stifled sneeze...) on english words - but the symbols are strung together in ways that are very different to english, and have their own meanings in that language that are typically very different to their english meanings. You can english-open an english-door, but you can mainly only unix-open a unix-file. I won't mention "ontological commitments" right now.

      Once you know what "printf" does, you manipulate it as a whole in a c program, you don't spell it out each time you write it "p-r-i-n-t-f" spells "print". A Chinese person can write in C quite easily without knowing much English - once he knows what the symbol "printf" does in the context of C, he doesn't *need* to know that there is an english word "print" or that "f" is the first letter of the english word "file".

      So english-like symbols can indeed help in the discovery phase, when you are trying to guess what a symbol does - but so could spanish-like. Or chinese-like. RTFTM (Read-the-fucking-translated-manual) can help here - as a programmer you are manipulating symbols when you are writing a programs, and one of the things programmers spend most of their timing doing is looking up definitions of the meanings of symbols in a particular context - if the definition is in french, and you're french, you can use the symbol, even if the symbol doesn't look french.

      ***relevance to documentation/pseudocode; for example, it is much easier to make someone understand that the developed code follows the pseudocode defined in a project's specifications when the code is as close as possible to the English language than when the code is a bunch of symbols thrown together.
      ***

      Not if the documentation or pseudocode is in any language other than english. Note that I am European, so I am probably more used to a multilingual environment than you if you are American.

      ***Although Python/Lisp/C++/whatever are readable, this is because they are based on English. The more a language is based on English, the better it is for big project development.
      ***

      I would disagree e.g. Lisp is SO not based on english. The symbols defined by the language spec are. The "sentence structure" is almost completely alien.

      ***
      That's why every coding style says "use readable variable names"...***

      Yes - but readability depends on the reader. And I'd prefer "use meaningful variable names". So english variable names make sense on a big project, since chances are your reader speaks english. But would you suggest using "BEGIN" and "END" instead of "{" and "}" on the same project ???

      *** If things were as you claim, we all be programming in assembly or with 0 or 1s; after all, how hard to make a mistake with 2 symbols only :-) ?
      ***

      Not at all - you misrepresent me. That would be antithetical to forming abstractions via new symbols. (aside: don't forget, most stuff is in fact written in "portable assembler" like languages like C - most good assemblers allow macros and therefore the beginnings of higher-level languages -.e.g Amiga m68k macro assembler .i header includer files had a near 1:1 mapping to the Amiga C .h header include files, including macros for structs and so on.)

      ***Don't forget that Hypercard has been claimed as one of the best programming environments because of its ability to program almost in English.
      ***

      (a) Hypercard was claimed as one of the best programming environments for "non-programmers".
      (b) Hypercard was one of those few languages where the grammatical structure of the language, not just the keywords, are english-like.

      ***The attitude "symbols are ok, as long as I understand them" shows that you are ignorant of the issues of real development (with managers, deadlines, multiple and heterogenous environments, different coders, testers, bug reports and bug databases, etc).
      ***

      I assure you, that not my attitude. I am a professional developer and encounter all of the above issues on a daily basis). English-like symbols do indeed help when trying to understand a system. They can also mislead - a variable called "applecount" that holds a count of "all oranges, pears and apples since last tuesday" are very annoying, for example.

      My attitude is "symbols are ok, so long as the intended readership (including the computer :-) ) understands them". I include English-like symbols in that.

      ***Finally, the obfuscated C code contents would not exist if code readability did not play an important role!!!
      ***

      True. To make the point in my previous comment more concrete: But have you ever seen legalese or a patent document? They're supposed to be in english - all legalese looks obfuscated because they're trying to fit a precise layer on top of an imprecise natural language, and patents are deliberately obfuscated as a matter of course.

      --
      Choice of masters is not freedom.
    10. Re:He didn't include K. by osu-neko · · Score: 1
      This being /., I must engage in pointless nit-picking... :)

      he doesn't *need* to know that there is an english word "print" or that "f" is the first letter of the english word "file"

      Actually, the 'f' in "printf" is the first letter of the word "formatted". The first 'f' in "fprintf" does stand for "file", though...

      --
      "Convictions are more dangerous enemies of truth than lies."
    11. Re:He didn't include K. by Jayson · · Score: 2, Informative
      Actually, I have never bothered to look at that code before (from the readme, I think), but I can tell very quickly what it does.

      K is directly translatable to English (and there is a program that does it). It does this because each symbol is given a short English name (sometimes two). All K is parsed form right to left, so there is no baroque precedence rules (3*2+1 is 9 not 7).

      Taking from the code sample:

      v*(2*!:'x+1)-x:1_!#p
      This is read as:
      v times quantity 2 times enumerate each x plus one end, minus x, where x gets 1 drop enumerate count p
      Break down the right side, what x is, a list from 1 to one less the length of the list p (i.e., if p was 5 elements long, x would be a list form 1 to 4). Now the part in the parenthesis is a list, where each list element is another list, but of numbers from 0 to 2*(x[i]+1) by 2s. So the first element of this list is a list with just 2 in it. The next list element is a list of 2,4, etc... Well, then you multiple all these values by v.

      This follows in Dr. Iverson's tradition of executable notation (see the J website for more information). What you are writing is a formula to manipulate data. It only took me a couple weeks to get used to the notation. After that my roommate and I were to speak across the room to each other in K.

      It really is all just a matter of getting used to things.

    12. Re:He didn't include K. by DGolden · · Score: 1

      And I can use printf without even knowing what the f stands for! :-)

      (Asctually, I did, but it had momentarily slipped my mind for some reason and it's a while since I had to write C.)

      --
      Choice of masters is not freedom.
    13. Re:He didn't include K. by t · · Score: 1
      there is no baroque precedence rules (3*2+1 is 9 not 7)
      You have got to be kidding. Standard mathematics cannot be considered baroque precedence. At point this, word order changing, like would be it.
    14. Re:He didn't include K. by master_p · · Score: 1

      O.K. I may have been oversimplifiing - but: ENGLISH IS SYMBOLS TOO. Using English is exactly the same as using symbols - since using english, or any language, *is* using symbols. That's how humans abstract. In written english you have letters, composed into compund symbols (aside: these compund symbols, "words", are often treated as primitve symbols by fast readers, whose symbol-recognition wetware seems to recognise them in one swoop.)

      Now, one could argue "then why not use familiar symbols" - but I find using familiar symbols just because they're familiar to be a bit silly and often dangerously misleading. Think of the emotive symbols "theft" or "piracy" applied to "violation of copyright law", in reality a quite different concept. Or "=" used for both assignment and equality testing (arrgh!!!!), neither of which correspond to mathematics-=, which is a statement of equality.

      Yeah, everything is a symbol if you think like that. Maybe we should start programming with images. They are symbols, aren't they ?

      In reality, a programming language is just like any spoken language. Have you ever wondered why people talk with words with more than a few letters and not with short sounds ? after all, a language with 2-letter words and 26 letters is capable of producing enough words to cover most (if not all) of everyday activities. But this is not the case: you don't hear "aq ? ac er ax" but instead you hear "hello ? how are you today ?" with some words having more than 2 letters!!!

      It is often better to just budget for bringing the new member up to speed in the language. Or just decide to only hire "speakers" of the language in question. You'll have to bring the new member up to speed on all the little pecularities of your codebase anyway, a much harder task for the new member than merely learning another new computer language.

      Yes, but the easiest to learn a language is, the easiest it is to find people to hire. No one is willing to learn K, but most are willing to learn Java and Visual Basic. And this clearly affects the budget of a project.

      But learning a new language should be VERY EASY for anyone who calls himself a "programmer" - the hard part will be understanding the code, not the language

      Although I generally agree with this statement, having the language be a mess of symbols hardly eases the burden of understanding the code.

      Yes, that is true - but, interestingly, the number of lines of code written by a programmer in a day stays roughly constant - regardless of language used - so the more verbose the language, the less your programmer is doing. And non-ASCII APLs, for example, have much easier to distinguish symbols than #\, and #\. :-)

      The LOC is insignificant in the long term. What matters is the quality of code. It is not significant if a programmer codes 10000 or 1000 lines of code in a day, as long as the 10000 lines of code are not easily maintainable. The cost of the project will rise in the future when the same (or another) programmer is called to modify it.

      By the way, your statement is self-contradicting: if the lines of code a programmer writes remains constant through out a day, regardless of the language, then why not use a language which is close to english as possible ?

      Note that I consider "A language based on english" very different to a language in which symbols^Wkeywords happen to correspond somewhat to english words. There are very few programming languages based on english, in which the grammatical structure of the language corresponds closely to english. Many programming languages, however, have keywords based (loosely - printf ??? like "print" followed by a stifled sneeze...) on english words - but the symbols are strung together in ways that are very different to english, and have their own meanings in that language that are typically very different to their english meanings. You can english-open an english-door, but you can mainly only unix-open a unix-file. I won't mention "ontological commitments" right now.

      But humans have the ability to extract the meaning of a word based on context. "Open door" and "open file" is a good convention, made by humans for humans. But "@#$ 35, 22" is not.

    15. Re:He didn't include K. by DGolden · · Score: 1

      Sigh.

      People are programming with images, all the time. "visual" editors for GUI forms even make a big deal about it.

      I just don't get your word-length argument. "hello" is a compound symbol, manipulated as a unit. More often used symbols tend to become shorter. That's why people say "hi" now. So if programming languages are just like spoken languages, we should see shorter and shorter symbols being used for common problems in that language. Oh wait, we DO see that. And in APL-like languages, mathematical operations on large multidimensional arrays are most common.

      ***Yes, but the easiest to learn a language is, the easiest it is to find people to hire. No one is willing to learn K, but most are willing to learn Java and Visual Basic. And this clearly affects the budget of a project.
      ***

      When hiring, it is best to hire people who are willing to learn. And if you're hiring criterion is "the cheapest person who is cheapest because he's too lazy to learn anything new" then welcome to project-failure land. I've seen it happen before, no doubt it will happen again and again as inexperienced managers make that mistake.

      "No one is willing to learn K" - obviously they are. We've got examples right here on this message board. And if one K coder can do the work of 20 VB monkeys (or more likely, do something that's impossible to do efficently in VB without dropping into COM objects written in C++) then using K could affect the budget positively.

      If the lines of code remain constant - why on earth would you use english??? - kfg's post demonstrates that english is more verbose, not less, than mathematical notation, for example, so for certain domains, mathematical notations makes far more sense.

      I agree that having the code be a mess of symbols doesn't help understanding the code - I get that feeling when present with a load of COBOL or VB code - lots of big huge english-like symbols meaning that I can only see a few of them at a time on screen, all relating to bits that are off-screen, and the symbols are often not properly encapsulated or abstracted, owing to, e.g. VB's singularly crappy function/subroutine stuff. Means I have to maintain more state in my brain, and while I am very intelligent (modest, too), I am also somewhat lazy, and don't like doing that, it slows me down. It's a "can't see the forest for the trees" effect.

      ***But humans have the ability to extract the meaning of a word based on context. "Open door" and "open file" is a good convention, made by humans for humans. But "@#$ 35, 22" is not.
      ***

      Of course they do, but that can lead to MAJOR misapprehensions. Unlearning is harder than learning, too, so those misapprehensions can be hard to shift, so in effect, it's a false "easy learning" effect - and context-sensitive stuff is more work (the ascii-line-noise example also illustrates this - because all those symbols are already overloaded with lots of meanings)

      I've already said I prefer the APL-symbol APLs to the ASCII-art ones.

      And who do you think K was made for? Martians? Not much of a market there. :-)

      Maybe it was made for people who simply aren't exactly like you. People are different. Some people may even like the fact that APL-like languages make it easy to use vectorised operations. They may come from VB and realise how much error-prone make-work all those loops were, and PREFER K.

      Would you suggest that musical notation, another language, would be better expressed as reams of english text??? It would make it easier for novices to play simple tunes on a piano. But would you hire that novice as a concert pianist?

      --
      Choice of masters is not freedom.
    16. Re:He didn't include K. by e-Motion · · Score: 1

      Yes, that is true - but, interestingly, the number of lines of code written by a programmer in a day stays roughly constant - regardless of language used - so the more verbose the language, the less your programmer is doing.

      The verbosity of the language has little or nothing to do with programmer productivity; it's the libraries that make the difference. Java, for example, tends to be very verbose (mostly because of methodNamesThatGoOnForever), but its large library makes it very easy to write useful applications. I think that your conclusion should read: so the more code that your programmer has to write because it is not already covered by libraries that are readily available to him/her, the less your programmer is doing.

  4. Mirror by elnerdoricardo · · Score: 3, Informative
    Here, I put up a temporary mirror in case this site melts...

    Coyote Gulch Mirror

    Be gentle! I'm sure my server is meltable, too! ;)

    --
    IN SOVIET RUSSIA, sig changes you!
    1. Re:Mirror by elnerdoricardo · · Score: 0, Offtopic
      Who was the moderator that modded this as "overrated"?

      Step forward, and explain!

      I'm HIGHLY curious as to your explanations... for far too long we've all watched page after page and server after server implode and prevent all of us from taking a look at the site.

      I attempt to do something nice for the community, hosting the site myself temporarily in the hopes that more people will get a chance to see it, and I get modded as OVERRATED?

      No wonder this place is going down the toilet, with attitudes like that!

      Am I being a karma whore? Frickin' eh, I am.

      I'll just forget it, next time!

      --
      IN SOVIET RUSSIA, sig changes you!
    2. Re:Mirror by EnglishTim · · Score: 1, Redundant

      For some reason the parent post was moderated down.

      Here's the post again:

      > Mirror (Score:0)
      > by elnerdoricardo (637672) on Thu 02 Jan 09:26AM (#4997447)
      >
      > Here, I put up a temporary mirror in case this site melts...
      >
      > Coyote Gulch Mirror
      >
      > Be gentle! I'm sure my server is meltable, too! ;)

      I just tested it, and it appears to be goatse.cx free.

    3. Re:Mirror by EvilBudMan · · Score: 1

      I tested it, and it is not. I wish I still had MOD points. Someonehas made a couple of mistakes for sure.

  5. uhh..... by Anonymous Coward · · Score: 0

    wow, this makes about as much sense as this article from earlier today :-/

  6. Good. by neksys · · Score: 4, Interesting
    No one benchmark (or set of benchmarks) provides an absolute answer -- but information helps make reasonable decisions

    Ah ha! Someone who understands what benchmarks are for and how to use them - it sometimes seems like the corporate world uses numbers from benchmarks only when they prove their claims. Of course, that's the difference between open source and the business world - open source (ideally) looks at every benchmark result and asks "now how can we get all of these numbers better than the competition?" while more traditional businesses ask, "Which of these numbers make our product look the best?". *shrug* its just nice to see benchmarks used properly, is all.

  7. Very true by Jayson · · Score: 2

    KDB performs as well as it does because of this. It inverts the tables and store them by columns instead of rows. The K language goes along with that principle and has special meta-operators and operators for dealing with large amounts of data of the same type.

    The language is interpreted, too.

    1. Re:Very true by homb · · Score: 5, Interesting

      Yes, but indeed if you're really looking to benchmark only, comparing a row-based database engine with a column-based one is like comparing an apple to an orange. Both are fruits, both give you calories, but they're quite different.

      Now as we're going off-topic from the original submission, one could benchmark KDB with Sybase IQ Multiplex. Here you're talking about 2 column-based db engines. In my testing, KDB is indeed up to an order of magnitude (10x) faster than Sybase IQ which is itself 2 orders of magnitude (100x) faster than row-based database engines.

      However, as the article in the post says, benchmarks don't give the whole story.

      Apart from the usual learning curve issues and available management tools (which KDB sadly lacks compared to Sybase IQ), there is one fundamental difference between the 2 db engines (and Oracle, DB2, Sybase ASE, etc...):

      KDB is single-process, and does not pool memory. I'm not saying this is bad, but it makes for very interesting architectural issues when designing a system. For example, if you're going to use KDB, you're better off with the fastest possible single-CPU system. The best platform for KDB is probably the fastest Intel P4 Xeon, dual-processor, and as much RAM as possible on the machine. One processor will be used exclusively for KDB, the other for the OS. To grow, you'll implement a farm of those.

      On the other hand, the other major DB engines generally perform much better in multi-CPU systems such as 16-way Sun servers. They pool the memory and use all the CPUs you'll give them. This makes for a more expensive single system, but an easier implementation if your application is larger than what a single dual Intel box can provide. In such a case, KDB will need one write engine and multiple read engines, significant storage pooling issues, etc...

      Anyway, one last point regarding column-based database engines: they are certainly amazing for reporting and most read commands. Where they lose to row-based engines is in inserts, and in selects that return data from a large number of columns.
      In the former case, you trick KDB and Sybase IQ into performing batch inserts (where the loading of columns will only be "wasted" once per batch). In the latter case, you're going to be hurt with KDB and Sybase IQ whatever you do, as they'll have to load in memory all the columns out of which you need the data.

      Bottom line:

      If you need OLTP (lots of inserts/updates) and aren't worried about extreme speeds, go for Oracle, Sybase ASE, DB2, etc...

      If you need fast reporting with very quick time to market, go for Sybase IQ Multiplex.

      If you need the absolute ultimate in reporting speed and have the time and resource to apply to it, go for KDB.

  8. Intel C++ by jsse · · Score: 2, Interesting

    I always find Intel C++ shines in all benchmarks. I wondered if anyone has ever tried to compile linux out of it? I know it might hurt your ideology but just for the fun of it. :)

    1. Re:Intel C++ by Anonymous Coward · · Score: 3, Informative

      Intel have released a separate version of their C++ compiler for Linux, which they claim has good GNU C/C++ compatibility http://www.intel.com/software/products/compilers/c lin/. They say it can be used to build the Linux kernel with few modifications.

    2. Re:Intel C++ by 0x0d0a · · Score: 3, Informative

      It doesn't work. Linux uses gcc extensions. Plus, the number of compiler bugs Linux exposes means that running it under icc would probably involve fixing a bunch of icc bugs.

      And you'd probably have to fix about a zillion Linux bugs...

    3. Re:Intel C++ by master_p · · Score: 1

      For me, the GCC vs ICC battle is all about Pentium 4 optimizations; the link in the posted article says that GCC is almost as fast as the Intel compiler on P3, but not as fast on P4. Maybe it is so because Intel knows its processor better than anyone else ? (rhetorical question).

    4. Re:Intel C++ by Anonymous Coward · · Score: 0

      Gcc isn't really good at optimizing on any intel processor above the original Pentium. The newest 3.x series are a little bit better but still not that good.

    5. Re:Intel C++ by master_p · · Score: 1

      "Isn't really good" is not the same as "almost as good". GCC is not bad, is almost as good as ICC, but not that good.

    6. Re:Intel C++ by axxackall · · Score: 2
      Each time some people forget that Linux is not only for Intel platform - many users use Linux on Mac/IBM /Amiga PPC, on Sun Sparcs and on other hardware platforms.

      Intel C++ is only for x86, therefore it's for Linux/x86, not for Linux in general. Therefore, Intel C++ should not be used by developers who write the code for other linux users (for Linux in general). GCC must be used instead.

      --

      Less is more !
    7. Re:Intel C++ by bbqBrain · · Score: 1

      I think the intent would be for an x86 Linux user to build a hella fast kernel. Another post off the parent claims it doesn't work, though.

      --

      One of the reasons that I became a lawyer was to avoid ever having to hire one. -SPYvSPY
  9. SPEC-FP for different compilers? by billstewart · · Score: 3, Informative
    The SPEC benchmarks are the descendants of the late-80s SPECmark benchmarking projects that did performance comparisons across a wide variety of machines and architectures, using code derived from real applications rather than purely synthetic little benchmarks like Dhrystone. Their benchmark suites were roughly 10 programs, with weightings on each program's results and scaling to compare with some popular architectures. They now have a variety of different benchmarks, covering a range of types of applications, including floating point. The benchmarks have tended to be used by hardware manufacturers, so they'll usually have just one result for a given machine, with the options obviously tweaked for maximum performance, but the details are provided and sometimes there'll be tests using different compilers (e.g. because it's a compiler maker doing the test.)

    The benchmark programs aren't free - this is a non-profit industry association that charges money to cover its costs, but there are a number of universities that are members or associates which may be able to do testing that could explore some of the compiler differences; poke around their website to see who's reported what kinds of results.

    --

    Bill Stewart
    New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
  10. Numbers of some Interest. Conclusions a yawn. by CresentCityRon · · Score: 2

    Its nice that the writer went to all the trouble to work on this and share it.

    His conclusions are not very revealing. Anyone doing Java programming will quickly discover how slow it is esp. in regards to floating point. You don't need a benchmark for that.

    That C++ performed as well as Fortran on the author's examples is interesting to me. Is the C++ implementations getting better or is the Fortan complier gone soft?

    His reasons for staying with Fortran made me chuckle. Those are the same answers programmers gave back in 1983 when I asked them why they didn't convert after learning the new fangled languages C and Lisp. (Well new for me anyway at the time.) When it is right it is right. I guess Fortran is still alright.

  11. Java performance by karevoll · · Score: 1

    This is everything but an troll... but:

    As the article clearly shows, Java is lagging behind in speed, as it as since it first was released from Sun (remember the pre-1.3 days? if you do, you know that Java 1.3.1 and 1.4.x is a lot quicker today than it was back then)..

    But then again, Java was never meant for big number-chrunching-applications was it? The way I see Java things, Java is designed to work on an end-user-level, thus speed is not (always) that critical. (Although implementing the wrong kind of algorithms (read: brute force) is just wrong anyway..)

    What lacks in the article are languages that are designed specifically for the tasks he wants done...

    Just my .02$ worth :-) Happy new year everyone!

    1. Re:Java performance by LinuxGeek · · Score: 2

      Hmmm.. On WinXP with J2SDK1.4.1, almabench ran in 80.13 seconds on a 1.4GHz AMD TBird. I'll have to boot back into Linux to compare jdk speed. That compares nicely to the P-IV 2.8GHz numbers for java.

      --

      Kindness is the language which the deaf can hear and the blind can see. - Mark Twain
    2. Re:Java performance by Anonymous Coward · · Score: 0

      Java is designed to work on an end-user-level,

      Since most application servers are written in Java thats a rather incorrect view. Java does poorly on "end-user-level". Have you ever seen a desktop Java app using Java's Swing? Slowwwww.

      At last I heard Java uses software, not hardware, to emulate floating point due to some platforms not being compliant with the IEEE 754 standard.

  12. Java is slow? by nsample · · Score: 5, Interesting


    I'm hardly a Java junky, but I've spent a lot of time recently with the language and I've heard a lot of complaints from my peers about Java being slow. Most of the time, just like this author, they're wrong! Java isn't slow, but sometimes you do have to program more thoughtfully to make Java fast.


    First things first, though. No one would ever claim that JDK 1.4 is the ultimate Java speed demon. Even the "HotSpot" in server mode is going to be slow if your code isn't written well. But the author fails to do any profiling, and fails to give anyone even a hint as to why Java doesn't perform well. But I shouldn't get on him about his coding, or lack of profiling... neither issue is the reason his test showed Java to be slow.


    The real problem: Firs, I'll cut him some slack for not profiling. However, I won't cut him any slack for using an interpreter instead of a JIT compiler. Java's been shown time and time again to be as fast as FORTRAN/C++ when using a good compiler, rather than an interpreter. *sigh* When will the madness end? A 0.07 second query to Google should explain that one to even a novice. Java IS fast. Interpreted byte-code is slow. Java != interpreted byte code; Java is a language.


    Anyway, here's a link to a weak, biased, and not so rigorous argument backing up that statement. But, it's an easy read for Java newbies, so I'll risk posting it anyway: Java is Fast for Dummies(tm)

    1. Re:Java is slow? by Anonymous Coward · · Score: 0

      I bet using JNI to call the C libraries instead of Math.atan2(), etc. would help, too... at least then the comparisons would be fair!

    2. Re:Java is slow? by Anonymous Coward · · Score: 1, Informative

      Java is marketed as having several strengths, among which:

      1 write once, run everywhere
      2 short time to implementation, and easy to maintain, low cost

      Your proposal is to optimize the app. While this works, it goes against 1: the optimisation works for one platform, but in general will just be overhead another. When you write to run on a specific platform, that is not a problem.

      It also goes against 2. Taking more time costs money. Implementing more clever takes more education of the programmer: costs money. More educated programmers have higher salaries.

      So, basically what you are saying is that either java is slow to run, or it is just as slow to develop as any other language.

    3. Re:Java is slow? by fobef · · Score: 2, Informative

      What do you mean by "using an interpreter"? He used Sun's run time, even with the -server switch, which does some for java quite serious optimizations. The real disadvantage java has (in terms of performance, it is an advantage otherwise) isn't the IEEE requirements, but rather the extensive use of runtime binding of classes. In C code, the compiler can inline pretty much anything for you, and get long runs of instructions to schedule as it likes. The other big performance disadvantage compared to C++ is that in C++ you can often have complete control over how arrays are laid out in memory, and test different ways to see which ones work best with your cache hierarchy. In Java you just 'new' it and then you have no control over it. I often hear that Java is about half the speed of C++, but my own tests put it more in the 10% to 20% range. Maybe half is true for poorly optimized C++ code vs poorly optimized Java code, but for well optimized C++ vs well optimized java the difference seems closer to five times. Which is fine to me most of the time, so I generally use Java.

    4. Re:Java is slow? by nsample · · Score: 3, Interesting


      Btw, I am dating myself with the griping about JIT versus purely interpreted and all that, but there is something important here! I decided that my first post was decidedly unclear, and that I should actually profile the dang that and get some real numbers.


      The almabench program spends a lot of time in library routines that the author has no control over, and aren't always written the same way that they are in FORTRAN/C/C++. For instance, almabench makes 5,844,000 calls to java.lang.Math.asin(D), which then calls java.lang.StrictMath.asin(D) 5,844,000 times. The same is true of the 11,688,000 calls to atan2()... they're also passed along to StrictMath (only abs() is called as many times as atan2()). The beauty of writing java code is *not* knowing that these sorts of things are going on, no? For best *performance*, however, we have to work a little harder.


      I really enjoyed the following paper on using some OO programming-style optimizations coupled with a smart runtime to get almost identical FORTRAN and Java performance for linpack: linpack9.


      A look there will validate the other comment about why OO designs can unecessarily kill performance and why the study's author should have used a JIT with identical libraries for math functions rather than Math.X(). Comparing otherwise is like comparing apples and oranges, or even Apples(r) and BillG.

    5. Re:Java is slow? by Anonymous Coward · · Score: 1, Interesting
      As a Java junky I have to place some questions:
      1. Why wasn't the java code compiled with -O ?
        You can partially optimize code by compiling it with that option.

      2. What was the VM used to do the benchmarks ?
        Client or Server Hotspot ? These VM's optimize code differently and can in some situations interpret code. If you really want to make a good benchmark with an hotspot like JIT compiler, you must run your code a couple of times before you start timinig things because the optimizer is profiling-based. BTW, IBM's VM is very good.

      3. The time was calculated with the "time" unix command ?
        If so, you are adding the boot time of the VM to the benchmark. I don't know if your application runs on a multi-thread or multi-process server, but if it is a multithread server, you're biasing this test a lot, if it is process based, you're not using Java as it should.

      I wouldn't be surprised if Java performance was slower than Fortran or C, but, after implementing a 3D texture rendering in Java (in 98) and seeing it running pretty fast (on Pentium 200 machines), I think this benchmarks are in need of further investigation.
    6. Re:Java is slow? by AG · · Score: 5, Informative

      gcj really is within 10% of g++ on this benchmark, unfortunately he built the gcj program without the all important -ffast-math option (and -funroll-loops). This is a huge penalty for gcj - more than 2x slower without.

      I sent him a note and hopefully he's update his page.

    7. Re:Java is slow? by X · · Score: 4, Insightful

      The -server option actually will imposive significant overhead for this benchmark. The -server option is not going to do any of it's significant optimisations without a TON of work.

      All your statements about C++ having an advantage over Java in terms of memory management are silly of course, since the Java runtime performs these exact kind of optimisations with Java programs. Because the decision is made at runtime rather than compile time it is actually possible for the Java runtime to make better optimisations than the C++ compiler/developer (who's decisions all have to be made a priori). I'm not saying this means Java always wins, because it most certainly does not, but I'm just saying that the "disadvantage" you are talking about is actually a misunderstanding of the conceptual differences between these two models.

      --
      sigs are a waste of space
    8. Re:Java is slow? by X · · Score: 4, Interesting

      For the record, I actually worked with the JPL evaluating Java's floating point performance. This was in the JDK 1.3 era, when HotSpot was still new. They had initially ported a highly optimised C library to Java and found the performance about in line with what this guy got (4-10x slower... actually it was an order of magnitude worse than this until they used the JIT ;-). The Java code showed many of the same performance errors that this guy's code has, as is common when you just do a line-by-line translation to Java, rather than rewriting the code from scratch. I did rewrite the code base, and managed to get the performance within the 10%-30% range. Using JDK 1.4 I'd have a few other tricks available to me which would probably get it even closer (maybe even faster).

      --
      sigs are a waste of space
    9. Re:Java is slow? by fobef · · Score: 2, Interesting

      This is interesting, but I'm still very sceptical.

      First of all, the possibility to align data to suit the cache is very very real and not silly. Of course it might not make a difference if you're memory bandwidth bound or whatever else is limiting performance, but for critical working sets close to the cache size it can, and most likely will, make tremendous difference.

      The advantage that Fortran has over C++, except for lots of well tested libraries, is the fact that pointers cannot interfere with each other. For example, writing to memory through pointer PA cannot affect a read from pointer PB, so the compiler can rearrange the read and write in any order. This thing alone made fortran faster than C++ on most math benchmarks.

      There now is a restrict keyword in C++ that does exactly the same thing, but what does java have? Nothing like that ofcourse, and IMHO it shouldn't. Because java is a language that makes for bug free software with good-enough performance.

      I have only written two performance critical programs both in java and c++, so my numbers are anecdotal evidence at best, but c++'s victory was devastating both times. And they where no line-by-line conversions, no unneccesary news etc. Of course they where a far cry from the "loop one million times and make a double precision fdiv" of the article linked in the original post in this thread where they found out that java and c++ was about equal. But then, so was the code you wrote, which makes it interesting.

      Is this thing you ported freely available somewhere?

      Also, how do you know that the -server switch hindered performance? It was better than -client, right? I assume it performs its optimizations when loading the class, and the only disadvantage compared to -client would be when inlined, runtime-bound methods have to be un-inlined because of a new class being new'ed in the place of an old object with different class (did that make sense?:-) So is this assumption wrong, or do you know that this is in fact happening in this benchmark?

    10. Re:Java is slow? by Anonymous Coward · · Score: 0

      Your point being? Sure, you can write a large part of your code in C or fortran and then link that into java as a library (as your linpack example does), but that doesn't show that java is fast. In fact I'd say it highlights perfectly that it is slow - it needs to have critical subsystems rewritten in fast languages in order to succeed!

    11. Re:Java is slow? by Anonymous Coward · · Score: 0

      Oh, get off it. Java is bloody awefully slow. When using java it is as if the last 10 years of CPU development didn't happen - today's software, on machines running at a whopping 33MHz.

      From your vehement defence I guess java is the only computer language you speak. Instead of wasting your time trying to convince others of its speed, why not invest in learning a few others? That way you can pick the right language for the job, which is much better than being emberassed after defending java for computationally intensive code...

    12. Re:Java is slow? by X · · Score: 3, Interesting

      Okay, first of all, the Java VM is fully capable of doing cache friendly memory management... in fact it can actually discover things about the cache's behavior at run time that are not likely to be known a priori by the compiler/programmer. So it's actually quite reasonable for a Java VM to excel in this regard.

      The instruction reordering issues you're talking about tends to only factor in when you have vector-processing CPU's. The limited vector-processing on the CPU's being tested is not enough to break the compiler's back, so it's not surprising Fortran is performing similarly to C++.

      Sorry, but my code isn't available elsewhere. However, I point out a few things this guy got wrong in another post.

      The difference between -client vs. -server is actually probably the opposite of what you are imagining. -client actually performs more optimisations at class load time, but fewer optimisations overall. This is in recognition of the fact that client programs tend to run for shorter periods of times.

      The -server switch actually REDUCES the number of optimizations performed when loading a class. Instead, it adds extensive profiling to all code execution, and then the runtime will gradually optimise frequently executed code based on analysis of how it executes. The optimisations are introduced gradually, almost on an "as needed" type basis. This approach allows the JVM to perform optimisations which simply aren't practical for a compiler to do, because the compiler doesn't have access to the profiling information gathered at runtime. When faced without a JIT, many programmers effectively do peep-hole optimisations of this nature by hand, but they ultimately can't predict what future runtime environments are like, nor can they effectively perform global optimisations on large programs. Of course, there are other differences between -server and -client, but this is by far the most important one.

      --
      sigs are a waste of space
    13. Re:Java is slow? by fobef · · Score: 1

      Cache friendly managment:
      It might be possible, but no VM does it yet. Why? Because they havn't seen any gain would be my guess.

      Instruction order issues are again very important, I don't know why you bother mixing in vector processing cpus, I assume we're talkning about x86. Most of the optimizations in IBMs JVM seem to be because of them gradually increasing the number of instructions that they can reorder .

      http://www-106.ibm.com/developerworks/ibm/librar y/ j-berry/sidebar.html
      (you might have to remove spaces from the URL if copying & pasting it)

      The difference between -client vs. -server is actually the opposite of what YOU are imagining. The client version (also called the hot spot version) starts by interpreting byte code, and then later compiles the hot spots. Not that it matters much here because the bechmark took a couple of minutes to run.

      Strange that the -server version couldn't determine what optimizations where bad for performance (according to you) from all that runtime information it must have gathered during those minutes.

    14. Re:Java is slow? by Trinition · · Score: 2
      For instance, almabench makes 5,844,000 calls to java.lang.Math.asin(D), which then calls java.lang.StrictMath.asin(D) 5,844,000 times. The same is true of the 11,688,000 calls to atan2()... they're also passed along to StrictMath (only abs() is called as many times as atan2()). The beauty of writing java code is *not* knowing that these sorts of things are going on, no? For best *performance*, however, we have to work a little harder

      Are you crazy?!. You think Java is supposed to let you get away with NOT knowing how your code works and interacts with the code it relies upon?

      Java, like any other language, needs to be scrutinized for performance problems. If you profiled and found that you code called java.lang.Math.asin, which in turn called java.lang.StrictMath.asin, then you should've re-written your code to use the second method directly. If it was in a third party piece of code, then you should've severely questioned the authors, and yoruself for using it. If it was in a benchmark,t hen you have to ask yorself if this benchmark is a good benchmark to use.

      I've encountered this myself several times. For instance, Ineeded to parse a big file based on lines and pipes (|). I figured it'd be easiest (i.e. fastest for me to get the code done) to just use java.util.StringTokenizer. When it turned out to be far too slow for what I needed, I profiled it. It turns out StringTokenizer is optimized to separate Strings into tokens when there are several possible tokens to separate on. In my case,once I rea da line, I just needed one delimitter. Hand-writing my own tokenizer for handling the special case of just one character provided far supoerior results and is in use today.

    15. Re:Java is slow? by X · · Score: 2

      Actually, some VM do cache friendly management. All of the VM's take care of basic byte-alignment issues.

      The instruction ordering for which you need explicit declaration of read/write barriers for are large matrix math operations, and even then it only matters if you've got huge amounts of data parallelism from a vector processor. Everything2 has a better description than I can write. All of the modern JVM's currently do basic instruction reordering just like C++ compilers, and it's enough to keep the execution units in modern CPU's pretty busy. Things like the "restrict" keyword aren't going to help much with that.

      As for "-client vs. -server". This is really basic Java stuff. Check out Sun's own docs on the matter. Where to start. *BOTH* VM's are HotSpot VM's. Both behave the way you describe the client. The difference is that the client VM does less profiling of the code and performs fewer optimisations (actually, there are many more differences, but this is what's relevant to what you said). The benchmark taking a "couple of minutes" to run is not enough for the -server VM to really shine. It's designed for programs that at least run for hours.

      Finally, it's actually NOT the number of minutes that the code runs that really determines what optimisations are good/bad for performance. It's the number of times the same code is run. And while some of the code is undoubtedly getting optimised, it is not enough for it to get all the optimisations, and it is certainly not enough for the optimisations to outweigh the penalty for profiling that was incurred during the earlier execution.

      --
      sigs are a waste of space
    16. Re:Java is slow? by fobef · · Score: 1

      Instruction ordering: I'm not necessarily talking about read/write barriers but basic instruction scheduling, longer instruction sequences really help here. (Execution units in modern CPUs aren't very busy at all but I really don't wanna get in to a discussion about that too.) -client v. -server Ok, I thought only -client was called HotSpot, because java --help says that -hotspot is the same as -client. Lets end this discussion because neither one will convince the other. I still havn't seen a real world situation when java has come close to c++, and you say you have. While I don't doubt that, I doubt that the c version was very well optimized. Have a good day

    17. Re:Java is slow? by X · · Score: 2

      Sorry, to clarify, I understand that execution units in modern CPU's aren't very busy. However, this is for the most part not due to deficiencies in the expressiveness of programming languages/compilers. In general, most computer programmers have a fairly linear flow, and even if you wrote the code in assembler by hand you'd be hard pressed to keep the execution units busy all the time.

      The original poster was specifically talking about read/write barriers. Fortran has special features which allow the compiler to make some very impressive assumptions about read/write dependancies. These features allow for much more powerful instruction reordering than the kind of stuff you are talking about. Indeed, as he said, these optimisations aren't possible in C/C++ either without the use of the restrict keyword. As I said, the stuff you are talking about is entirely possible to do in a JIT, and is in fact being done in all the major JVM's.

      --
      sigs are a waste of space
    18. Re:Java is slow? by Andreas+Rueckert · · Score: 1

      I've started working on a Java chess program and found Java surprisingly fast so far. Even without much optimizations (no time yet). My bigger problem is graphics part so far (animation + repaint nightmares at the moment :-( ).

    19. Re:Java is slow? by Anonymous Coward · · Score: 0

      When using java it is as if the last 10 years of CPU development didn't happen

      Funny, I remember people saying the same thing about C and C++. FORTRAN and ASM, baby!

      The fact is that in many (perhaps the majority) of the things people use computers for, programmer productivity and program reliability is FAR more important than absolute speed.

      Oh, and for the record, I know Java, Perl, C, C++, LISP, APL, ML, FORTRAN, BASIC, and assembly langaguages for at least 5 or 6 processors.

    20. Re:Java is slow? by MillionthMonkey · · Score: 2

      > I bet using JNI to call the C libraries instead of Math.atan2(), etc. would help, too... at least then the comparisons would be fair!

      Bad idea.

      Math.atan2() calls StrictMath.atan2() which uses JNI to get to a native C method that is available on each platform's JVM implementation. You can roll your own native MyMath.atan2() with JNI yourself, but this only saves you the overhead of a static nonvirtual function call in the Java layer (both methods are static and final) while preserving the much larger JNI overhead. And now you need to distribute a native lib for each platform. You'd get the same (very minor) boost by calling the StrictMath method directly. And why not, if you've determined that's what Math.atan2() does?

      The source for java.* classes are usually only one right click away in any good IDE, so you can see instantly if something stupid is happening. (Except for the string concatenation "+" operator. When people talk about "careful programming in Java" they usually mean not relying on + with Strings. That's the biggest sinkhole that people walk into. Use StringBuffers instead and your code will in general be much faster.)

      If your app is slow, run a profiler. Math.sin() is likely to be a bottleneck only for the simplest applications (i.e. silly benchmark programs). If you do find that Math.sin() or whatever is slowing your program down, build a cribsheet of sine values at the start and then use that to avoid the repeated JNI overhead (and the native code's trig calculation itself) which is really where your time is being spent. Even C programmers know this trick.

    21. Re:Java is slow? by DeepRedux · · Score: 1

      The StrictMath functions in Java are designed to always return quite accurate results. The result from the atan2 function must be within 2 ulps (units in the last place) of the correctly rounded result and the results must be semi-monotonic.

      Most other languages make no promises as to the accuracy of the intrinsic functions. This allows the use of the x86 hardware instructions for sin and cos that can return as little as one bit of accuracy (in extreme cases).

      Java tends to be biased toward safety rather than speed. Bounds checking is another example. In my opinion, there is a lot to be said for slowly getting the right answer rather than quickly getting the wrong answer.

    22. Re:Java is slow? by Anonymous Coward · · Score: 0

      Bah, setting up a JNI call would take longer than the calculation in pure Java!

  13. Compiler for AMD processors? by kghougaard · · Score: 2, Interesting
    The article deals with Pentium systems. Is there an AMD optimized compiler out there also?

    Can anyone suggest a good compiler for floting point number crunching on Athlon based systems? (For Linux, and preferably free or not too expensive)

    --
    He, who dies with the most toys, wins
    1. Re:Compiler for AMD processors? by guybarr · · Score: 2

      try intel's compiler ... it's rumored to get better results than gcc on AMD's machines as well.

      you can do a 30-days free evaluation, IIRC, so my advice would be:
      devellop using gcc/g++, then when you need to go to production, evaluate intel's compiler and see if it's good enough for your needs.

      --
      Working for necessity's mother.
    2. Re:Compiler for AMD processors? by Anonymous Coward · · Score: 1, Interesting

      And beyond the 30 day evaluation you can still use it for open source development and personal use. With a small fix to libtool and libc it can even compile a fully functional and fast version of KDE 3.1 now.

  14. Gcc still not as fast as icc by Goodbyte · · Score: 1

    I was surpries by the big difference between the gcc and icc compiler. Sure gcc ain't vectorizing, but there were huge improvements in gcc-3.x, which promised up to 30% faster code if I remember correctly.

    Back in gcc-2.95 many optimazions were hard to implement due to portability, but those issues must have been resolved by now. Right?

  15. dubious by guybarr · · Score: 2

    He benchmarked gcc 3.2.1 and did not benchmark gcc 2.95.x . This in itself makes me doubt his work, especially if his C/C++ code is just C code "in disguise".

    Plus, parallelization should not have been a part of such a benchmark.
    Parallelization for a cluster _or_ a supercomputer has many issues
    that have nothing to do with compiler/language performance, and has much to do with IPC, memory and cache hit/misses, and other pains, who provide many people with PHDs and careers. For a good reason.

    I know he says it himself, but if you admit your results should not be taken seriously, don't publish them.

    Object-oriented programming adds very little to the core functionality of a number-crunching application -- and performance is adversely affected by the overhead entailed in objects, exception handling, and other object-oriented facilities.

    this means the man does not choose the right tool for the job. I agree that exception handling should not be used with numerical code, asserts work just fine. But objects and higher-level abstractions should very much be used in the 90% of the code which takes 10% of the runtime but still, say, >80% of development time ...

    And don't let me get started on templates, which really made my work much easier when used properly.

    And in many cases, function-oriented code exceeds the clarity of corresponding object-oriented code

    as for function-oriented code supposedly exceeding clarity of OO code, I find this remark, Ahem, embarrassing. If your OO code looks less clear than functional code, you have quite a problem. It means you do not use abstractions to ease design, reduce code-redundancy and reduce module interdependancies.

    It means, in short, that you are going through the motions, but do not think on what you do.

    --
    Working for necessity's mother.
    1. Re:dubious by Anonymous Coward · · Score: 0

      I hate it when some washed up old bastard puts C++ on his resume. Then you hire his fucking ass and all he does is code god damn C and call it C++. Then you have to fucking fire his ass. Sorry gramps, sure you have experience but if you can't use your tools properly hit the road ok jack.

    2. Re:dubious by joib · · Score: 2


      He benchmarked gcc 3.2.1 and did not benchmark gcc 2.95.x...


      Why should he have benchmarked gcc 2.95? What critical information would that provide? Other reports seem to indicate that compared to gcc 3.2, 2.95 is slightly slower, especially with processor-specific optimizations, and it has poor support for C99 and C++98. Nothing new or especially interresting here.


      Plus, parallelization should not have been a part of such a benchmark.
      Parallelization for a cluster _or_ a supercomputer has many issues...


      He didn't claim to test parallalization for supercomputers, he just tested to see if the automatic parallelization and openmp directives helped with the intel compiler on the p4 hyperthreading cpu. Automatic parallelization has a lot to do with the compilers ability to analyze the structure of the code and determine which parts can be run in parallel and which parts cannot. And as you can see from the results, in this case at least, there was little benefit from it.


      OO blah blah..


      I agree with you that OO is beneficial (for real life projects). OTOH, if you look at his benchmark code it's just a few pages. For a code which is that small there is probably little benefit from OO. And thus the c++ and java versions use no OO features, rightly so IMHO.

    3. Re:dubious by Harald74 · · Score: 1
      First you say:

      I know he says it himself, but if you admit your results should not be taken seriously, don't publish them.


      And then your .sig says:
      better err and be corrected than staying a silent fool.


      Isn't this just what the author does?

      Otherwise, I quite agree with your post.

      PS: Please use a divider between your message and the signature. Less confusion that way.
      --
      A)bort, R)etry or S)elf-destruct?
    4. Re:dubious by podperson · · Score: 1

      as for function-oriented code supposedly exceeding clarity of OO code, I find this remark, Ahem, embarrassing

      How is, for example:

      app.showurl("www.slashdot.org");

      clearer than:

      showurl("www.slashdot.org");

      ?

      Sometimes OO isn't the answer.

    5. Re:dubious by guybarr · · Score: 1

      Isn't this just what the author does?

      No, since the original author knew he was in the wrong ...

      PS: Please use a divider between your message and the signature. Less confusion that way.

      thanks, did it.
      (there's an option to add a signature dash to comments, BTW)

      --
      Working for necessity's mother.
    6. Re:dubious by Anonymous Coward · · Score: 0

      My God, you are an idiot.

    7. Re:dubious by JoeBuck · · Score: 2

      You agree that the author must benchmark gcc 2.95.x instead of or in addition to gcc 3.2.1 to be taken seriously? WHY? He'll get slightly slower numbers with gcc 2.95.x, but so?

    8. Re:dubious by Anonymous Coward · · Score: 0

      Sounds like the person doing the hiring is incompetent, then.

      Not to put too fine a point on it, that would be you, Sparky.

  16. JIT? by EnglishTim · · Score: 4, Informative

    The article claims that he *is* using a Just-In-Time compiler. What makes you think otherwise?

    1. Re:JIT? by Renegade+Lisp · · Score: 1

      Furthermore, gcj is a native compiler that uses the existing gcc backends. It exhibits the same (even slightly worse) performance as the Sun JDK. The fact that none of the obvious optimizations, e.g. turning off bounds-checking, provided any noticeable improvement, looks extremely odd, though.

    2. Re:JIT? by Mansing · · Score: 2

      This statement from the author indicates he doesn't understand the JVM versus a JIT:

      "Perhaps Java's Just-in-Time compiler could be enhanced to perform processor-specific run-time optimizations; on the other hand, doing so would require different JVMs (Java Virtual Machines) for different architectures, or a single bloated JVM with run-time architecture detection."

      The Java compiler produces byte-code, and the JVM interprets the byte-codes. A JIT *is* platform specific, and tied to a specific OS and hardware architecture. That's why I think the author was not using a JIT.

    3. Re:JIT? by Fjord · · Score: 1

      I read that part to mean different ia32 architectures (Pentium III, Pentium IV, Itanium, Athlon, and Opteron are examples listed). While these are all compatible on one level, they each have their own ways to optimize towards.

      --
      -no broken link
    4. Re:JIT? by Anonymous Coward · · Score: 0

      From the use of -client and -server options, it's clear the author is using Hotspot, which is not really a JIT in the conventional sense.

      JITs such as Symantec's, Microsoft's, and IBM's (pre 1.3), compile the classes/methods at class loading, or first emthod call time.

      Hotspot does NOT do this. Hotspot is a mixed-mode engine. It exmaines call tree, and does runtime profiling to find the "hotspots" in the code. It then runs in an idle priority thread a bakcground compile of the hotspot, doing full optimizations such as method inlining, loop unrolling, etc.

      Hotspot works on the idea that 80-90% of the time is spent in 10-20% of the code. It also assumes you won't be maxing out the CPU for all time, since the compilation occurs in the background it would be starved in this benchmark case.

      Quickly running the benchmark under Windows using Sun's 1.4.1, resulted in 80sec runtimes on an Athlon 1.3G, but with JView (MS's 1.1.4 JVM) results in 55secs. Which is a significant savings even though MS's VM at least theoretically is using full IEEE mode (This restriction was lifted in Java 1.2). (For comparison the C++ code compiled using VisualC++ 6 resulted in a 30second runtime.)

  17. Re:Numbers of some Interest. Conclusions a yawn. by Anonymous Coward · · Score: 0

    A very large part of clsoing the gap should be attributed to C++. It's a younger language, which means it's development is progressing faster. Both C++ and Fortran are probably approaching the theoretical maximum speed asymptotically, with a few years lead for Fortran. A extensive resource can be found here

  18. too far off topic, but... by Jayson · · Score: 1
    I was only trying to impress the point of operating of bulk data and how it related to the test this person performed with C, Java, etc...

    Concerning what you have to say about OLTP processing, you might want to read Dennis Sasha's High Volume Transaction Processing paper. You are right on, as far as the architecture is concerned. There is a entire different set of concerns with KDB, but there are always tradeoff. This is too far offtopic to really go into any detail, though.

    It is interesting to see somebody else with as KDB experience. Not a common system (but we can hope it grows in the future).

  19. What is it with windows-using losers by Anonymous Coward · · Score: 0

    and Benchmarking?

    Benchmarking on a platform that is as widely diverse as linux is pretty much useless. The odds are that *NOBODY* is running a system that is configured like the one the "benchmark tests" are running on so that the results are pretty much meaningless.

    1. Re:What is it with windows-using losers by InfiniteWisdom · · Score: 2, Interesting

      With numerical code there will be little difference regardless of which version of Linux your use or if you use Windows for that matter

    2. Re:What is it with windows-using losers by Anonymous Coward · · Score: 0

      >With numerical code there will be little difference regardless of
      which version of Linux your use or if you use Windows for that matter
      >
      >
      A self-serving myth. Benchmarks depend on the programing language in which they were coded with, and *NO* programing language performs the same way on different platforms. C code on Linux and C code on Windows don't perform the same and you are fool and a liar if you claim they do. Any speed compaisions bettween the two is meaningless.

  20. IBM java runtime and different platform. by Anonymous Coward · · Score: 2, Informative

    Here are some results from an AMD system and the IBM java runtime:

    Athlon XP 1600
    -mcpu=athlon-xp
    -O3
    -mmmx
    -m3dnow

    IBM java - build 1.4.0, J2RE 1.4.0 IBM build cxia32140-20020917a
    58.8 seconds
    58.9

    Sun java - build 1.4.1_01-b01 Client VM
    94.2
    94.1

    Sun java - build 1.4.1_01-b01 Server VM
    82.1
    81.6

    gcj - version 3.2
    82
    82.1

    gcc - version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
    31.4
    31.3
    26.6 -ffast-math
    26.6 -ffast-math
    26.4 -ffast-math -funroll-loops
    26.4 -ffast-math -funroll-loops

  21. gcj results incorrect - 2x worse than truth by AG · · Score: 4, Insightful

    Compiling his benchmark with -ffast-math and -funroll-loops more than doubles the performance of the gcj built benchmark on my P3.

    This brings it within spitting distance of g++.

    1. Re:gcj results incorrect - 2x worse than truth by EmagGeek · · Score: 2

      -ffast-math gives up IEEE compliance and some accuracy for speed.... which is probably why most folks don't use it for real applications..

    2. Re:gcj results incorrect - 2x worse than truth by JoeBuck · · Score: 2

      -ffast-math is not suitable for numerical computation in most cases (applications with big matrices, like weather forcasting, physics simulations and the like). It's OK in most cases for digital signal processing applications. But for the application area the author is considering, it's bogus to tell him to use -ffast-math.

      -funroll-loops is another matter.

  22. He didn't include python by more · · Score: 5, Interesting
    Results on My P4 1.5 GHz, RedHat 8.0, gcc 3.2

    time python -O almabench.py user: 22m19.354s

    gcc -ffast-math -O3 almabench.cpp -lm time ./a.out user: 0m50.348s

    C++ is only 27 times faster than Python for planetary simulations.

    Almabench.py is my own conversion from the cpp source. I will send it to the author for possible addition to the benchmark.

    --

    -- Imperial units must die --

    1. Re:He didn't include python by fredan · · Score: 1

      My machine is an Athlon 900 with gcc 3.2.1
      bash-2.05a$ time ./almabench

      real 0m42.203s
      user 0m42.160s
      sys 0m0.040s

      with the following CFLAGS:
      -march=athlon -O3 -mmmx -m3dnow -fomit-frame-pointer -ffast-math -funroll-loops

    2. Re:He didn't include python by thunderbug · · Score: 1

      How does it do under Psyco? Could you post your code? I'd like to try psyco on it.

  23. Picking nits with that Java article by MichaelCrawford · · Score: 2
    The article compares loading graphics in BMP format for C++ vs. GIF or JPG format for Java.

    It doesn't seem to acknowledge the widespread availability of file format libraries that are suitable for use with C++, such as libjpeg from the Independent Jpeg Group.

    It also repeats the commonly stated claim that Java is free from memory leaks. Nothing could be further from the truth. While it is possible to carefully write a Java program that doesn't leak, I don't think it's any easier than making a leakproof C++ program.

    How does Java leak memory? Simple. Just hold references to memory you don't need anymore. Holding a reference to any node in a DOM Tree will prevent the entire tree from being garbage collected. That's an easy way to leak tens of megabytes.

    Garbage collection is no substitute for responsible memory management.

    It also says that in C++, you have to implement graphics calls by coding to the native API of the OS. It says in Java, you have a portable way to do that.

    But that's just bullshit. The article makes no mention of cross-platform application frameworks, a number of which were around before Java was ever dreamed off. If you use ZooLib, for example, to code in C++, you can do everything you want with graphics with no need for platform-specific code. There's lots of other cross-platform frameworks, such as wxWindows and Mozilla, even GTK+.

    --
    Request your free CD of my piano music.
    1. Re:Picking nits with that Java article by X · · Score: 3, Interesting

      There is no question that you can have a memory leak in a Java program. However, Java does remove a number of potential ways to create a memory leak that do occur in C++ (heck, 90% of C++ programs I see will leak heap memory if you have exceptions). Anyone who claims that "While it is possible to carefully write a Java program that doesn't leak, I don't think it's any easier than making a leakproof C++ program" either hasn't written a lot of C++, or hasn't written a lot of Java. ;-)

      --
      sigs are a waste of space
  24. Fortran compilers and Linux by EmagGeek · · Score: 4, Interesting
    Here is a more in-depth comparison of Fortran 90 compilers for linux. They compared Intel, NAG, Lahey, and a couple of other compilers. Here is a comparison of Fortran 77 compilers from the same folks. GNU g77 is actually the slowest of them all, and I've actually confirmed that it is the slowest of a group consisting of DEC/Win32, Lahey/Linux, and g77. I've always dreamed of the day that open source developers would throw some real brainweight at a really well optimized Fortran compiler for linux, but it looks like I'll just have to keep dreaming. Lahey is only $199 or so, but they place some HORRIBLE licensing restrictions on the binaries that are created with their compiler. The DEC/Win32 compiler is also really nice, but since I'm not in school anymore, I'm not licensed to use it, and even if I _wanted_ to whore myself out to Micro$oft, I couldn't afford to.

    Just to put some things into perspective, here are some numerical results. These were obtained on my dual-athlon 1.4GHz w/ 1GB of RAM. The task was to compute the TE and TM surface currents induced on a circular cylinder 10 wavelengths in circumferece and having a relative permittivity equal to 4-j2. The program simultaneously solves the perfect electric conducting case. The surface was discretized into 60 cells using 120 unknowns (way overkill, but just to prove the point) using the Integral Equation Asymptotic Phase method.

    g77 Compiler (-O2 -malign-double -funroll-loops): 24.11s
    Lahey Compiler (equivalent paramters): 16.45s

    As you can see, there's really no comparison, except that the lahey-created binary uses about 10% more RAM than does the one created with g77. This is just a summary comparison as I did not go into measuring the difference in the error of the two results compared to a reference solution. I'm assuming that both solutions are about the same with regard to accuracy.

    1. Re:Fortran compilers and Linux by Anonymous Coward · · Score: 0

      Note that Polyhedron used the 0.5.26 g77 - the
      one that was distributed as part of GCC 3.0.

      If they really ran the benchmarks on the 17th
      of December it's not clear to me why they didn't
      use GCC/g77 3.2.1 (released 21st of November).

      Toon Moene

    2. Re:Fortran compilers and Linux by Anonymous Coward · · Score: 0

      I think I saw somewhere a comment by Richard Stallman where he denouced Fortran and vowed never to write anything in it when he began the GCC project. So perhaps it is not a surprise that Fortran is not the favourite language of the GCC project.

    3. Re:Fortran compilers and Linux by rillian · · Score: 2

      I've always dreamed of the day that open source developers would throw some real brainweight at a really well optimized Fortran compiler for linux, but it looks like I'll just have to keep dreaming.

      There actually is a project writing a G95 front-end for gcc. It's moving along slowly, and could certainly use contributors.

    4. Re:Fortran compilers and Linux by EmagGeek · · Score: 1

      This sounds like a nice idea, but it's not the same as developing a _well-optimized_ compiler. Don't get me wrong, if I were legally able to do so, I would love to contribute to something like this (however, I can't because I can't (and won't) assign the work to them - it ain't "free" if someone owns it). But, writing a compiler for a different language won't make it optimize F77 any better. :)

      I do plan on testing their binaries, however, and seeing if I can at least help that way..

    5. Re:Fortran compilers and Linux by esonik · · Score: 2

      Actually I would be interested in a program that can simulate an electron gun (steady state, no dynamics required but space charge effects are an issue). Is there any free software that can do this ? It would be nice if we could optimize our e-beam heating, however I can not spend money on this, because it's not a central part of our experiment and it already kind of works.

    6. Re:Fortran compilers and Linux by Anonymous Coward · · Score: 0

      I'll add a few details about how G95 is coming along, as this is more-or-less on topic.

      G95 has two parts: the frontend, which parses the source code and passes it to the GCC back-end, and the runtime library.

      The frontend is humming along well, the integration into GCC asides, it is almost finished, and even if the web-page is not exactly verbose about it, it can be used as a syntax checker on everybody's Fortran codes. It interprets the standard rather strictly, so if it tells you that your program, which compiles so well with X and Y's compilers, has a syntax error, I'd guess it has. But it still needs testing, so go ahead run it on your codes, and report the problems you are seeing.

      The frontend can also be compiled together with GCC. G95 then produces binaries for a large number of programs. But the runtime library is unfinished, so you will only be able to link and run a rather small subset of fortran programs, even though the compiler itself is more or less ready.

      So what's up with the library, you ask? The trouble is: there are already three of them,
      but none finished, and only one is on a server waiting to be downloaded. This one only covers the parts needed for testing code generation in simple programs, and thus is fairly restricted in scope. The development model for the library is a big point of discussion on the g95 mailing list (IMO the problem seems to be that Andy Vaught, who initiated G95, doesn't want more parts of his personal project G95 to fall into someone else's hands, as has happened with the backend interface, which is being developed by Paul Brook). One of these alternative runtime libraries now has opened a project on sourceforge, but there's no code yet: here. I do hope, they'll put something out soon as I can't wait to run some real code doing file I/O through G95.

      If you want a working G95, help getting those libraries out there. I can hardly wait myself.

  25. weighted? by SHEENmaster · · Score: 2

    So how much will the beowulf project have to pay for parrallel tasking to rank over serial tasking in the tests!?

    This is a joke, not libel. Beowulf is too poor to bribe.

    --
    You can't judge a book by the way it wears its hair.
  26. Yawn. by Anonymous Coward · · Score: 0

    Any benchmark without blood and guts and/or explosions cannot be taken seriously.

  27. I've written a lot of both by MichaelCrawford · · Score: 3, Informative
    I prefer programming in C++ because I find it easier to just take responsibility for my memory.

    Using reference counting is one big help. And knowing how to write exception safe code is another. Yes, it's a difficult subject, but it is something you can learn.

    It may be easier to write leak-free Java than C++, but I suspect that because many Java programmers blithely assume their code can't leak, there may well be more leaky Java programs than C++ ones.

    I used to work at a web shop where we used the Enhydra Java application server. Enhydra is pretty well written, but the applications that the company originally developed for it were pretty sad. As a result they had to restart their servlet process every few hours because the JVM ran out of memory!

    --
    Request your free CD of my piano music.
    1. Re:I've written a lot of both by X · · Score: 1

      Hey, I'm not claiming which one is worse for programming in general. The point is that the pervious poster's claim that it's just as easy to avoid creating memory leaks in C++ as it is in Java is ludicrous, as both you and another poster have acknowledged.

      In general, you'd be amazed how few leaks do tend to exist in Java programs, even written by relatively junior programmers. In particular, it's a lot easier to write/use libraries or frameworks without creating memory leaks. Sure you can find specific projects where you have a disaster on your hands, but I've actually been on a lot of J2EE projects, and less than 10% of them have exhibited the kind of problem you are talking about, as compared to the 80% of CORBA projects I've been involved with.

      --
      sigs are a waste of space
    2. Re:I've written a lot of both by sql*kitten · · Score: 2

      I prefer programming in C++ because I find it easier to just take responsibility for my memory.

      auto_ptr is your friend :-)

  28. IBM JDK 1.3.1 by MarkoNo5 · · Score: 3, Informative

    When I run my QR decomposition "benchmark", IBM's virtual machine always comes out about 20% faster than Sun's. It would still be a lot slower than C++ or Fortran, but the gap should be smaller. On top of that, IBM's license does not require you to accept a license which says the VM may install any software on your machine and that you automatically accept the license of that new software. See http://hal.trinhall.cam.ac.uk/~nrs27/java_eula.htm l for all the fun.

  29. He had me going there for a while by MacroRex · · Score: 1, Funny

    I enjoy working with Swing

    And I almost took this guy seriously ;)

    Nah seriously, a great article with many insightful points. We need more of these and less those thinly veiled advertisements for blinkenlights.

  30. slashdot benchmark by muyuubyou · · Score: 1

    I don't want to sound offensive, but this stuff mostly shows how low has the threshold become to make it to slashdot.
    IMHO this has to be one of the poorer tests I've seen. It's between nowhere & nowhere, maybe because of the chosen code.


    1 Only 2 machines, so unrelated you can't conclude anything out of that. Hmmm maybe a client-server example, but number-crunching is nothing you can consider a client-server typical application.

    2 too few languages/compilers. Yes, you can use Java for number-crunching, but then you can consider a whole lot more. Moreover, that results for gcj are extremely different from what I got.

    3 Running Linux on almost any platform, this test lacks depth. If you focus in "linux" and "number crunching", then choosing only "x86" is going a bit too far regardless being that the most used platform.


    To me, this is more an anecdote than "an interesting read" that should be broadcasted at slashdot.

    1. Re:slashdot benchmark by Anonymous Coward · · Score: 0

      3 Running Linux on almost any platform, this test lacks depth. If you focus in "linux" and "number crunching", then choosing only "x86" is going a bit too far regardless being that the most used platform.

      and Intel only. No AMD, no transmeta, no C3. In the hardware side, this tests shows nothing interesting comparatively. The guy could have worked deeper in the Pentium 4 alone and maybe something interesting would arise

    2. Re:slashdot benchmark by Anonymous Coward · · Score: 0

      He compared a number of languages that are commonly used for real-life projects within a single (ok, *two* single ;-) ) platforms. When you are writing a computationally intensive application the platform is usually a given, as is the OS, but the language and compiler can usually be chosen freely. This page supports the decision process.

      The only criticism I have is that I'd like to see some more languages (Perl) and compilers (gnu/fortran, M$ visual C++).

      Some of his conclusions are actually fairly interesting:

      1. C++ or fortran really doesn't matter, as long as you choose the right compiler (Intels).

      2. If you need a lot of performance in a computationally intensive C++ application, better use Intels compiler.

      I work with C++. I write computationally intensive applications. I meet people who use fortran and talk down to me because I use such an 'inappropriate' language (C++) for the work I do. And I'll be sure to print that page and put it on the whiteboard when I get back to the office ;-)

    3. Re:slashdot benchmark by ChaoticCoyote · · Score: 2

      My biggest surprise review was the excellent performance of the C++ code. In the past, C++ compilers introduced overhead -- even in code that isn't object-oriented.

    4. Re:slashdot benchmark by Anonymous Coward · · Score: 0

      I don't want to sound offensive but your comment is one of the poorer that I've seen on slashdot: the usual rant without going into sufficient detail to actually make any sense.

      1) the test was not a benchmark of machines, It was merely by chance that it was done on two machines. This was supposed to be a COMPILER-BENCHMARK FOR NUMBER-CRUNCHING, what has client-server to do with that ? You don't seriously refer to the "client" and "server" flags as client-server example ?

      2) You say one should consider more languages...which ones ? If you think you have a valid argument make it clear to everyone, give an example. Just saying "a whole lot more" doesn't help anybody. You say, you got different results for gcj. What where your results ? Do you have an idea why they are different ? (Different from what, do you get different relative performance of compilers or do you get different absolute performance on a different machine?) Just saying you got different results doesn't help anybody.

      3) When the objective is to do number crunching on x86-Linux, then why is focusing on that going too far, especially if the x86 platform is the most used anyway ? Again, please reread the title of the article: "Linux Number Crunching,
      Benchmarking Compilers and Languages for ia32".

  31. Sun's Wireless toolkit by FyRE666 · · Score: 3, Interesting

    Anyone who's spent any time working with Sun's Wireless Toolkit to develop for mobile devices will have witnessed pretty serious memory leakage firsthand. I know I do! After starting an emulator 10-20 times to test code it's using so much RAM that it's necessary to kill and restart the Toolkit to get anything like reasonable performance back again!

    I'll agree that Java makes memory management much simpler, (I've spent a lot of time hacking x86 assembler, Pascal, C and C++ over the years) but bad programming can lead to leaks just as well. You tend to discover leaks pretty quickly with a mobile phone that has only 200K of RAM to play with though ;-)

  32. Java is really, really slow by 0x0d0a · · Score: 5, Insightful

    ...I've heard a lot of complaints from my peers about Java being slow.

    Allow me to join the chorus.

    Java isn't slow, but sometimes you do have to program more thoughtfully to make Java fast.

    No. Java *can* be made less mind-bogglingly slow by avoiding certain things...preallocating a pool of objects and using primitive types (like int) whenever possible helps. The way the language is designed makes it *easy* to be mind-bogglingly slow. That doesn't mean that going out of your way to avoid these things makes Java fast. It makes it only "slow".

    Java is Fast for Dummies

    Ah, yes. A link tellings how Java isn't *really* that slow on "javaworld.com". I took a skim.

    The first two pages say basically "Java isn't that slow". They then start rambling about various features that make Java a good language.

    They claim that Java programs load faster than native programs. (The article was written, BTW, in Feb '98, to give an idea of how full of BS they are). This is stupid. JVM startup and load time *dwarfs* application link time. Write "hello world" in C++ and in Java.

    First, they laud the small executable size of Java as being a performance boost based on binary format. Everything I've read points the *other* way...Java *is* fairly compact, but can contain data that isn't nicely aligned along host boundaries.

    Second, what they're talking about, if it's even accurate these days, which I doubt, has a lot to do with the lousiness of the Windows runtime linker. This isn't really an issue for Linux.

    Third, while insinuating that minimizing code size provides a performance boost, they talk about how great it is that Java lets you use *built in* libraries, whereas C++ progams need to *bundle* libraries. What? That's stupid. They're shifting the libraries around, but it sure as hell isn't decreasing total amount of data that needs to get loaded.

    Fourth, this gem: Finally, Java contains special libraries that support images and sound files in compressed formats, such as Joint Photographic Expert Group (JPEG) and Graphics Interchange Format (GIF) for images, and Adaptive m -law encoded (AU) for audio. In contrast, the only natively supported formats in Windows NT are uncompressed: bitmap (BMP) for images and wave (WAV) for audio. Compression can reduce the size of images by an order of magnitude and audio files by a factor of three. Additional class libraries are available if you want to add support for other graphics and sound formats.

    They're billing this as *improving* performance? Yeah, I'd love to have my app blow CPU time decompressing a JPEG image instead of reading a slightly larger BMP image if I'm trying to minimize load time. Oh, and have it load all the JPEG loading code, too.

    They then proceed to ramble about selective loading, and try to imply that Java's runtime linking is faster than C++'s.

    They *then* show off smaller binary sizes by embedding a BMP in the C++ binary and a GIF in the Java binary. Impressive.

    They then claim that claims of poor Java performance are based on non-JIT implementations. This neatly lets them avoid actually citing numbers. Sure, I'll agree that Java went from "Performance Hideous" to "Performance Bad". Everyone uses JIT these days, and damned if Java isn't *still* slow.

    They then try to talk about how JIT allows code to be optimized just like C++. Wow. Yup, JIT sure is known for impressive optimization, isn't it?

    They then use the most artificial, contrived benchmarks I've ever seen (which conveniently avoid almost all of the Java pitfalls...they don't need to do array access, they're trivial to implement without heap allocation...)

    They finish up talking about how C++ RTTI performance sucks compared to Java (ignoring the fact that Java hits RTTI code *far* more often than C++ does, like every time it yanks something out of a generic container class).

    Finally, they finish up by talking about a bunch of random Java features that they think are great, like garbage collection "First, your programs are virtually immune to memory leaks." Hope you don't use hash tables, buddy.

    Next, they talk about how a JVM can defrag memory. I'm going to have to just crack up at that. This isn't a performance boost unless you're using a language that *hideously* fragments memory and eats memory like a *beast* (granted, Java is the best candidate I know of). Runtime memory defragmentation went out of fashion with the classic Mac OS...it's pretty much a bad idea as long as you have a hard drive available. VM systems are pretty damn good these days...if you're trying to maximize performance, there are almost always better things to be doing than blowing cycles and bandwidth defragging memory. There's a reason we don't do it any more.

    Basically, my conclusion is that "Java is Fast for Dummies" is primarily aimed at, well, dummies.

    1. Re:Java is really, really slow by 0x0d0a · · Score: 4, Insightful

      Oh, and a follow-up to my previous post. These clowns spent a long time talking about how people can "ignore JIT overhead" because it's almost completely insignificant "most of the time". Fine. Then they spend 80% of the article talking about *binary load time*, which is essentially only an issue under the *exact* same conditions that the JIT is -- once for a single chunk of code. If they're pimping launch time, they sure as hell shouldn't be ignoring JIT time.

    2. Re:Java is really, really slow by X · · Score: 1

      I'll leave most of your stuff aside, because I do agree that a lot of silly things are said about Java's performance.

      However, your comment that memory fragmentation is not a problem is a major misnomer. For starters, it assumes you have virtual memory, which is pretty hard to come by on embedded systems. Secondly, it assumes that you have an unlimited amount of virtual memory (because that's how much you'd need to avoid fragmentation problems for programs that run for an unlimited amount of time). Finally, it ignores the fact that fragmentation causes additional stress on the virtual memory subsystem which becomes a peformance issues essentially the first time you have to swap a page out to disk.

      --
      sigs are a waste of space
    3. Re:Java is really, really slow by Trinition · · Score: 2
      Here's some the "better" parts of Java:
      • Rapid Development: because there is a huge core set of standard APIs, as compared to C++, any programmer can sit down with an expansive toolkit when writing a new app. This saves a lot of time by not having to reimplement those tools, or find 3rd party tools. Even if you have a set of 3rd party C++ libraries you like to work with, there is no guarantee that every 3rd party C++ library is going to work on every OS (I once worked in a shop compiling their code to 6 UNOIX platforms and NT -- what a pain!)
      • HotSpot: As someone else pointed out, HotSpot will improve things at runtime, where you have a lot more information available to you, instead of just compile-time. The author of the article used HotSpot Server which is made to optimize under very different circumstances (for example, extremely long runtimes).
      • Secure Software: By this, I mean avoiding things like buffer overruns. When you check your array bounds before accessing an array, you can be sure you won't overflow the array. Of course, it is slower. But even HotSpot optimizes a lot of this way (so I've heard, but I don't know exactly how). Sure, you *could* do this in any other language, but opbivously people don't. They get arrogant and assume that they'll never have bad data and just read to the end of a stream. Voila, you've just created a potential exploit!
      • Everything Else: One of the big factors remaining is just HOW you write code in Java. As someoneelse pointed out, there are a ton of Objects in Java, (almost) every function is virtual, everything is linked dynamically, etc. These things slow Java down, btu also make it more uniform which makes it easier (faster) to learn, in my opinion. If you made every function in your C++ classes virtual, used RTTI and Strings to do runtime linking, etc. your C++ programs would be slower too!
    4. Re:Java is really, really slow by 0x0d0a · · Score: 3, Insightful

      Okay, for embedded systems there might be some argument. I actually considered consoles, but decided that no one in their right minds would be coding console games in Java. However, I suppose there are some embedded devices that run Java (don't some cell phones, IIRC), so I guess that isn't totally out of line.

      However, I stand by my claim that (at least on non-embedded systems) runtime memory defragmentation is pretty silly for general purpose stuff.

      1) Computers don't sit there and block on I/O any more. The world isn't Windows 95 anymore, and when something is paging, another app can be doing some processing. The cost of hitting the disk is far less significant.

      2) The bottleneck for current desktop systems is generally not CPU cycles, but memory bandwidth. Memory defragmentation eats bandwidth like there's no tomorrow.

    5. Re:Java is really, really slow by 0x0d0a · · Score: 5, Interesting

      Here's some the "better" parts of Java:

      Don't get me wrong. Java's fine for certain applications. For lightweight networking stuff, I think it's almost unparalleled. It's also pretty good for prototyping C++ stuff. It's good for lightweight tasks that break down logically into threads -- Java has nice threading support.

      My beef is that Java is not, despite its supporters' loud claims (which have been going on for years), remotely performance-competitive with C.

      The language simply has some foundational performance limitations in it. It was designed that way, and tweaking implementations cannot get around that.

      I agree that there are some nice things about Java.

      Rapid Development

      Damn straight. Java is a great prototyping language.

      Hotspot

      Not bad, but not that incredible, either. The benchmarks I've seen haven't shown HotSpot to be incredible, and besides, competitors like C (gcc) have branch-profiling code of their own.

      Secure Software

      True. There are some improvements. But buffer overflows are less and less common in C (due to *excellent* libraries like glib), and have been fixed in other languages without anywhere near the performance hit of Java (like Ocaml).

      One of the big factors remaining is just HOW you write code in Java.

      It may be a personal thing, but I have a deep dislike of languages where you have to modify your regular coding style to get decent performance at a given point. It used to be BASICs...you'd use some nasty trick and you could actually get decent performance out of the thing. Then MATLAB. *God* I hate vectorizing operations. I expect that a MATLAB guru simply does this in his sleep, but I find it incredibly frusterating to totally rethink code in an any areas where performance matters.

      These things slow Java down, btu also make it more uniform which makes it easier (faster) to

      A fair number of the uniformity improvements in Java could have come from simply tweaking syntax (int[50] x instead of int x[50], for example).

      I'm all for modern language features...I just think that doing anything that implies a necessary performance hit is a bad idea. If someone wants a given feature, they can slap it on top. I can make C++ have a virtual function, but I can't make Java run quickly.

      If you made every function in your C++ classes virtual, used RTTI and Strings to do runtime linking, etc. your C++ programs would be slower too!

      Ya, but Stroustroup went to a lot of work to ensure that you only "pay for what you use".

      So, I'm not out to bash Java as a usable language. It has some major pluses. However, specifically in the performance arena, Java definitely has issues.

    6. Re:Java is really, really slow by X · · Score: 3, Informative

      Okay, first of all, for embedded systems this is actually very important. For any embedded system that has to run for years, one of the key issues is that it absolutely must use a heap manager that avoids long-term fragmentation (or have a static heap... but that's another story). Java happens to have a prepackaged solution for this. This, plus small executable size due to the use of byte codes is one of the reasons Java is used for embedded projects.

      Actually, the cost of hitting the disk is typically the most important impact on system peformance once you have an app who's working set can't fit into available RAM. That's because access for swapped virtual memory is orders of magnitude slower than virtual memory that in RAM. As you said, most systems today are not CPU limited, but rather memory limited, so switching to another app which also needs to access virtual memory is actually going to make things worse (just try running two programs who's working sets are larger than available RAM and you'll get the idea).

      As for memory defragging eating bandwidth like there's no tomorrow, that's only half of the picture. Good GC systems aren't constantly defragging memory at top speed, so the penality is frequently invisible. Smart systems GC when there is available CPU time and memory bandwidth (check out BEA's JVM for example). More importantly, by defragging intelligently you actually increase the chances that sequential memory accesses will hit the various memory cache's on the system (it's really nice when the cache lines are all filled with actual related data instead of unrelated fragments with gaps).

      The thing to keep in mind is that the people who write GC systems (or at least the good ones) aren't stupid about how they use memory. They spend a lot of time very carefully analysing memory management issues and put their findings into their system. As a result, most GC systems are better at doing memory management than your average programmer (although there are always special problems where a particular GC will perform particularly poorly).

      --
      sigs are a waste of space
    7. Re:Java is really, really slow by Ehud · · Score: 1

      Also, if your heap isn't fragmented, you can make heap allocation nearly as fast as stack allocation.

    8. Re:Java is really, really slow by Caoch93 · · Score: 1

      I think that you forgot one feature of Java that, to me, is probably it's most powerful and most overlooked feature: dynamic class loading. The dynamic loading power of Java is, in my experience, worlds beyond that offered by C and C++ because of the fact that you can load a class for execution through so many very different means and can, as a programmer, remain unconcerned about things like the OS of the system from which you receive the class. Classes can be very easily procured from remote systems and boostrapped into the code right away with a level of transparency that I just haven't seen from C and C++.

      Yes, C and C++ have dynamic loading capabilities. I've used them, and I'm aware of them. What I'm saying is that I don't find them as flexible or simple as the Java loading mechanisms and, most importantly, it's very difficult for multiple machines with widely different OSes to use the same remote piece of executable code with that level of transparency. Yes, I know that CORBA helps get around this, but I can't say I find CORBA very elegant.

      To me, the promise of Java is evident in its uses in making relatively lightweight and secure networking infrastructure. The power of easy remote class loading is what gives projects like Jini the means they need to make physical network location nearly irrelevant in distributed computing.

    9. Re:Java is really, really slow by Anonymous Coward · · Score: 0

      Two things:

      "They're billing this as *improving* performance? Yeah, I'd love to have my app blow CPU time decompressing a JPEG image instead of reading a slightly larger BMP image if I'm trying to minimize load time. Oh, and have it load all the JPEG loading code, too."

      This is completely wrong. I recently had a discussion with a friend of mine who has worked several years in the game game industry.I asked about image formats and their pros and cons, I was surprised to find that one of the big reasons for using compressed images (yes, JPEG) is the load time improvement. This is because the CPU is a whole heck of a lot faster than the hard drive. ("...slightly larger..." is a huge understatement by the way, especially with JPEG).

      Secondly, although my experience with Java has shown that it is slower. This statement is about the Sun JRE, NOT, the language itself. And more importantly, I know personally of a company that developed a web product in Java because they were able to make it faster than other options (PHP for example).

      Some of this was attributed to the fact that with normal CGI a thread must be spawned for every requeste and then killed. If this thread's life is very short and requests happen often, then the overhead of the spawn/kill becomes significant. The Java Tomcat server and corresponding servlets were able to avoid this OS overhead.

    10. Re:Java is really, really slow by 0x0d0a · · Score: 2

      The problem is that it's still kind of nasty, because Java makes it very easy to have an inner loop with heap allocation occurring.

      It still isn't free. Not sure how much extra overhead a VM requires to to stack allocation -- in native code, it's just a register change, but I suppose that a JVM might have to do a stack-heap collision check.

      The heap...you have to probably select the right size data chunk from a bin, find a free chunk (granted, if this isn't fragmented, it isn't *awful*), make some changes to mark the thing as no longer free, update references used to try to locate the next free chunk quickly, register the thing with the GC. Since this is Java, you're also locating a constructor, checking to see whether memory should be defragged and potentially defragging memory. It's also a lot more likely to span a wide range of memory that wasn't previously touched, which means causing cache misses if the architecture running the JVM has a cache.

      That being said, ya, it can run faster if you don't have massive heap fragmentation -- which doesn't necessarily occur, even if you aren't defragmenting things, especially if you have a clever internal allocation strategy.

    11. Re:Java is really, really slow by Anonymous Coward · · Score: 0

      > there is no guarantee that every 3rd party C++
      > library is going to work on every OS

      and there are differences between the Solaris VM, the Linux VM, the Windows VM...

      > easier (faster) to learn

      Doesn't make it better or faster.

      > If you made every function in your C++ classes
      > virtual, used RTTI and Strings to do runtime
      > linking, etc. your C++ programs would be slower
      > too!

      But still orders of magnitude faster than Java.

    12. Re:Java is really, really slow by Anonymous Coward · · Score: 0

      Of course compressed images loads faster than uncompressed ones. But don't let facts get in the way of a C++ zealot.

      Java sucks, but C++ sucks more.

    13. Re:Java is really, really slow by kinga · · Score: 1

      The problem is that it's still kind of nasty, because Java makes it very easy to have an inner loop with heap allocation occurring.

      If those objects exist only within the scope of the (tight) loop then collection (but not allocation) is free, since they are allocated in the young generation eden space (in JVM 1.3+) and don't survive long enough to get copied into a survivor space.

      you have to probably select the right size data chunk from a bin, find a free chunk (granted, if this isn't fragmented, it isn't *awful*)

      Only in the old generation, and then only if it uses mark-sweep. In the case you give above, the objects are in eden, which means allocation is from a (per-thread) linear buffer, i.e. you just bump a pointer to allocate an object.

      checking to see whether memory should be defragged and potentially defragging memory

      Defragging is implicit in the young generation since you're doing copying collection between eden/semi-spaces. It's also implicit in old generation mark-compact collection, since you're compacting the space when you sweep for free objects. There is no defragging in old generations that use mark-sweep, but at least coalescing is free since you sweep the heap linearly (i.e. in address order, so finding adjacent free blocks is essentially free).

  33. lahey by Anonymous Coward · · Score: 0

    (never heard of them before, interesting). The basic version of their compiler (probably suitable for most student use?) is 249. There is an upsell version (looks like mainly a bunch of add-on or upgraded libs/tools like a gui constructor) for 695. Out of curiosity, what were the licensing restrictions you found objectionable? A cursury inspection of the site didn't reveal the licensing terms on the current product lineup (other than to mention that educational purchases can't legally be used to make commercial binaries, no big suprise there). thanks for the informative post, btw. :)

    1. Re:lahey by EmagGeek · · Score: 1

      Basically, they have a _very_ loose definition of a multiprocessor machine, and binaries cannot be run on computers or computer clusters containing more than 4 CPUs aggregate. Unfortunatley, their definition of a multiprocessor machine is so vague that it would include a distributed computing platform, such as the type that is used at distributed.net.

      Since one of my main areas of research is distributed computing for the solution of electromagnetic problems, this precludes me from using their compiler. Imagine if I started something like d.net for electromagnetics, and 4 million people signed up, by their licensing terms I would have to buy 4 million licenses at $249 a pop.

      I know what you're going to say: "Oh that can't possibly be what they meant," and I'll concede that you're probably right, but according to my attorney, that's what the document says, so that's that.

  34. and benchmarks between hardwares? by Anonymous Coward · · Score: 0

    Many tiny, old, quick cores of i486 doing MultiThreading (MT) is better than P4 for quick boot, for older intensive applications, ...

    P4 has XX millions of transistors, the same to build multicores of i486 doing MultiThreading ...

    There are benchmarks between softwares but there are benchmarks between hardwares

    The tip: parallelism of tasks & transistors (i486-MT) vs queue of tasks & transistors (P4-HT)

    JCPM (copyright)

  35. Lies, damn lies, and people who don't know... by X · · Score: 1, Flamebait

    ...what they are doing.

    It's pretty clear this guy is not a Java programmer, or at least has limited knowledge of how to write efficient, well-designed programs in Java. Amazingly, that's actually not relevant. To get to the bottom line skip to the bottom of this post.

    For starters, he's using 2-dimensional arrays, so of course Java is going to be slower. 2-dimensional arrays in C++ are actually 1-dimensional arrays with some syntactic sugar thrown in. In Java they are arrays of arrays (really akin to using vectors of pointers to vectors). Experienced Java programmers (and for that matter good C++ programmers) will use a Matrix class to both clean up the code structure and to provide a much more optimised 1-dimensional array structure for manipulations of the Matrix.

    His benchmark doesn't have a warm-up run, and doesn't run nearly long enough to cause HotSpot to optimise the code thoroughly. Sure, this is fair if what you're measuring is how well the Java VM can execute a relatively short-run program (quick answer: not very well at all), but it is no indication of the kind of performance that Java can achieve.

    The code essentially is not written like a standard Java program (and indeed, is a pretty evil C program if you ask me). I mean, any method with 30+ local variables is suspect in my book (particularly amusing is that some of them appear to be never used). As such, it doesn't play very well against the JVM's optimiser, which is oriented towards Java code with much different structure.

    His TEST_LENGTH loop is long enough that he's potentially better off catching an array out of bounds exception than constantly checking the index.

    This doesn't affect Java performance, but it's just silly to have a while(true) loop and then have a break on an if at the end of a block is just silly (it might trigger some optimization for a specific, broken C optimizer, but it's just silly to have that on a standard benchmark).

    But ultimately this all doesn't matter. Why? Because the bottom line is this benchmark makes heavy uses of standard runtime functions (the trig and square root function). This means that large portions of this code are essentially out of the realm of the compiler, and in the hands of the runtime library. Doing stuff like this I can get widely different results just be linking in different floating point libraries. So, while he highlights the *compilers*, in fact what this is really stressing is the quality of the floating point libraries of the particular runtimes he's chosen. As such, it provides no insight in to the relative merits of using different compilers or languages. At worst, this might be misleading even for the specific application he has in mind. At best it suggests how a few different math libraries perform. The conclusions this guy draws from this are just rediculous.

    --
    sigs are a waste of space
    1. Re:Lies, damn lies, and people who don't know... by Anonymous Coward · · Score: 0

      You forget to mention the garbage collector and as you migh know, The dustman always rings twice ;-)

      When using objects (arrays) within a loop, at the end of every loop, they will be marked for garbage collection. At the beginning of the loop, new objects get created. So he's not only benchmarking the runtime library instead of the compiler, he's also benchmarking his own garbage.

    2. Re:Lies, damn lies, and people who don't know... by X · · Score: 1

      He actually mentions that he has fixed this bug in his article, so I left it out. Plus, I didn't find any place in the Java code where he was allocating new arrays inside the loops (my guess is the code I got was after he fixed this).

      --
      sigs are a waste of space
    3. Re:Lies, damn lies, and people who don't know... by more · · Score: 1
      The C++ code look stupid, so it is quite fair that the java code is stupid, too. Most code written looks stupid, especially code written by physicists (I have been rewriting and redesigned research code written by different world-class physicists for the last 10 years professionally). IMHO, the benchmark looks quite close the code that could be created by a physicists. They don't necessarily care a damn about the carbage collection. They just want the job done and write it down as simple and concreate as possible. Of course, real physicist don't natively write in java, they use matlab, fortran, and C++ (with code looking almost exactly like it was still fortran).

      I ported the code to python without making any changes in its structure, even though it is most definately not the optimal python way. IMHO, it is the fairest way to compare the language. Keep the source as close to original as possible. No language or compiler specific optimizations anywhere. What comes to that break statement, it is a braindead idea and most definately not "optimal" code for a broken c++ compiler. But again, it could have been written by an expert physicist in real life.

      This benchmark is valid for analyzing cpu speed (and the 1-level cache inside the cpu). However, it fails in measuring memory system speed which is probably the most important factor to modern scientific computations. I believe, that when larger memory operations are done, the speed advance of c++ becomes even greater.

      P.S. I have written a chess program in C++, java and python, so I know the basics of optimization in each language.

      --

      -- Imperial units must die --

    4. Re:Lies, damn lies, and people who don't know... by toriver · · Score: 2
      For starters, he's using 2-dimensional arrays, so of course Java is going to be slower. 2-dimensional arrays in C++ are actually 1-dimensional arrays with some syntactic sugar thrown in.

      Also, the arrays are initiated element by element since Java doesn't have a "data segment". If he measures time outside the program from start to finish he will get VM startup time etc. in addition to that.

      As such, it doesn't play very well against the JVM's optimiser, which is oriented towards Java code with much different structure.

      Well, at least the "meat" of the code is in methods which are called often enough that some optimizations can be thrown in. There is also a curious absence of the "strictfp" keyword that might improve things.

      Now, if he had taken System.currentTimeMillis() before the loop and after and computed the difference, a more relevant number would emerge...

    5. Re:Lies, damn lies, and people who don't know... by X · · Score: 1

      I agree with your analysis of the C++ code. However, I disagree with your notion that porting line is a valid test of the relative CPU-bound performance of these languages. The program is invariably written as per the preferences of the original language, particularly with some pretty massive assumptions about what is most optimal. Using two-dimensional arrays instead of a Matrix class which is internally a 1-dimensional array is a very good example of this.

      --
      sigs are a waste of space
    6. Re:Lies, damn lies, and people who don't know... by ChaoticCoyote · · Score: 2

      Considering that I make a rather healthy living from Java development, I must be getting something right. ;) And I've written at least one successful book on Java development, Java Algorithms (JDK 1.1-based and a bit old now). Ignore the J++ book I wrote for Microsoft; it was butchered by political concerns in Redmond.

      For my clients, I create Swing-based GUI apps that have no numerical code whatsoever; the current one's running about 50K lines at the moment. Performance on such applications is database-bound, so Java's performance is a non-issue.

      Almabench was not a standard Java program; it is a translation directly from the Fortran, and, as such, it has a few inconsistencies with the usual Java style. Here's the Catch-22: Had I customized the code to be very "Java-like", people would have complained that I was comparing apples and organges -- yet when I keep the code consistent across languages, people such as yourself argue that I should be more language-specific.

      It's a good thing I put on my asbetstos underware this morning. I hadn't expected this to hit /.'s front page....

      Given that numerical code often uses intrinsic functions like sin and atan2, testing those functions is quite valid, given the inability to chose my floating-point library under Java (byond changing the entire VM).

    7. Re:Lies, damn lies, and people who don't know... by X · · Score: 2

      Seriously, if you know Java, you had to know that the stuff you were writing is Java was semantically different (and significantly so) in many ways from the Fortran and C++ code (in terms of what the program was telling the language to do). You also had to know that the way you were benchmarking the code was going to get anywhere near an accurate measurement of Java's overall thoroughput for executing this problem. Knowing that, how can you really feel that this is a reasonable performance assessment of Java?

      I agree it's a Catch-22 problem. You will be criticised no matter what you do.

      That being said, I'm not sure that you can effectively measure the performance characteristics of a language if you apply idioms to it from another language. It merely measures one language's ability to effectively execute another's runtime model. While this is an interesting measurement in and of itself, it is not an effective measurement as to whether a given language can solve the original problem in an efficient manner.

      How's this for a solution: write the program in Java with a focus on the Java execution model, then translate it back in to Fortran. Now you'll have a version in both languages of both programs. This would make you pretty much safe in both camps.

      I agree that the trig tests are valid for testing the performance of a given VM, but they aren't a valid reflection of the language. From a language perspective, there is no reason why Java's sin and atan2 functions can't execute as quickly as their Fortran equivalents. For that matter the same is true of C++ (and as you rightly suspect, the Fortran and C++ code that *is* using the same floating point library gets very similar results).

      --
      sigs are a waste of space
    8. Re:Lies, damn lies, and people who don't know... by Anonymous Coward · · Score: 0

      strictfp does not help, since it enforces intermediate calculations to adhere to standards, which is not optimal on the intel architecture.
      strictfp actually makes the code a factor of 2 slower (I just tested that).

    9. Re:Lies, damn lies, and people who don't know... by toriver · · Score: 2

      Thanks for the strictfp warning, I removed that and timed the outermost loop. On my P4 2.8 GHz running Windows XP Pro that yielded:

      C:\temp>C:\usr\java\j2sdk1.4.1_01\bin\java.exe -cp . -client almabench
      Time: 51.953

      C:\temp>C:\usr\java\j2sdk1.4.1_01\bin\java.exe -cp . -server almabench
      Time: 68.079

      I guess it would have been even better on Linux. :-)

  36. Some java results by LadyLucky · · Score: 2
    I thought I would try out a few results on my machine, and got some interesting results. I would encourage other people to do the same. I have used his java code, unmodified, save for a System.out.println the time taken.

    My computer is a 900MHz Athlon, 256Mb RAM, running WinXP. Using J2SDK 1.4.1_01.

    javac -g:none -O *.java

    java -server almabench
    Took a total of 107555ms

    jview almabench
    Took a total of 51073ms

    Compare this with 76 seconds on his 2.8 GHz machine. JView (that's Microsoft's VM) was able to run in 51 seconds.

    The two things of note:

    • My results are significantly faster than his.
    • Jview ran at twice the pace of Sun's latest offering. Euch.

    Unfortunatly I have no c compiler on this machine to run them, that would be really interesting.

    --
    dominionrd.blogspot.com - Restaurants on
    1. Re:Some java results by X · · Score: 1

      That's really not surprising, his benchmark actually penalizes the -server version of Sun's VM compared to a conventional VM. Try using -server, running the benchmark 20,000 times in one process, and benchmark the 20,001st run in the same process. Then the -server option will definitely kick JView all over the place. Also, IBM's VM will probably compare pretty well in this benchmark, not to mention VM's specifically targetted to floating point operations.

      --
      sigs are a waste of space
    2. Re:Some java results by ChaoticCoyote · · Score: 2

      Just because Java is a great tool doesn't mean it is the best tool for every job.

      I only included the -server option because people would've bitched if I hadn't. I'm well-aware that the server JVM is optimized for persistent processes.

      Everyone wants me to include the IBM JDK, so I'll do that later today.

    3. Re:Some java results by X · · Score: 2

      Hey, I'd be the first to admit that for the job you're doing in this benchmark Java is a poor tool for the task, and that there are plenty of other tasks for which it is ill suited for.

      However, the conclusions you draw from this are that Java is a poor tool for a much broader set of applications and circumstances than your benchmark accurately measures.

      Certainly, lots of floating point calculations are highly persistent, and take *days* to execute. In many cases, even if they don't take days to execute, the same code is executed with different datasets. These are the kind of problems for with the Sun's Java VM is capable of approaching Fortran and C++ performance. It's known that the optimisations which are applied in these circumstances can improve execution speed by several times. Based on that it's totaly unreasonable to use your benchmark to draw conclusions about Java's overall abilities in high-performance settings.

      Your test also times everything including load time for the program. Because you don't isolate out just the floating-point calculations of the code, you don't have adequate controls on the other variables in the execution of your program.

      You conclude that Java does not take advantage of processor specific optimisations (it actually does have processor specific optimisations). I don't see how this conclusion could be based on your tests, particularly since the Sun JVM demonstrated significantly more of a performance improvement on the Pentium IV box than gcc or gcj were able to show (indeed they were even better than the performance improvements with the "default" builds with the Intel compilers).

      The infamous "lies, damn lies, and benchmarks" (paraphrasing a bit) is not so much about the benchmarks themselves, but how they tend to be used innappropriately to make generalisations well beyond what they accurately demonstrate.

      --
      sigs are a waste of space
    4. Re:Some java results by ChaoticCoyote · · Score: 2

      You incorrectly assert:

      ...the conclusions you draw from this are that Java is a poor tool for a much broader set of applications and circumstances than your benchmark accurately measures.

      If you read the conclusion in my article, you'll see the following paragraph:

      This benchmark does not imply that Java is useless, or that Fortran is the world's best programming language, or that compiled languages are superior in all cases to byte-code interpreters. I would no more write a sophisticated graphical application in Fortran than I would analyze physics experiments in Java. Java is a terrific tool for building user interfaces; I enjoy working with Swing, and am in the midst of developing a large vertical-market database application in Java. Be that as it may, I'm exploring number crunching in this article, not buttons and mouse movements.
    5. Re:Some java results by X · · Score: 2

      It's exactly the claims about number crunching which I'm saying are overly broad given the limitations of your benchmark.

      Perhaps I've completely misread your conclusions. I thought you said that Java was a poor tool for doing number crunching, specifically floating-point number crunching. If I misread that then I apologise and I'll have to reread, and you can skip the rest of this paragraph. ;-) Your benchmark is much more limited than a accurate assesment of raw floating-point number crunching capability. Indeed, I have first hand experience that suggests for some types of floating point problems the performance differences between the languages are far less significant than indicated by your benchmark. Perhaps the best one could say is, "direct ports of short-run, trigonmetric, floating intensive Fortran applications will not run efficently with Java". That's a lot of qualifiers.

      Certainly you say your benchmark demonstrates that Java's (and in fact it's the Sun VM's optimizations, not Java's, but that's a semantic issue) "run-time optimisations" don't do much for floating point math. Yet, as we've already discussed, and as you knew full well, your benchmark does not exploit these optimisations (otherwise -server should produce a better score than -client).

      --
      sigs are a waste of space
  37. Development time vs. run time by Harald74 · · Score: 2, Interesting
    In the article the author writes:

    Object-oriented programming adds very little to the core functionality of a number-crunching application -- and performance is adversely affected by the overhead entailed in objects, exception handling, and other object-oriented facilities.


    Using object orientation in C++ adds a very small overhead (in the vicinity of 10% if you're using virtual functions). Now I understand that the article was mostly concerned with benchmarking the languages, and I applaud the writer for specifiying that benchmarking is no "silver bullet". But I really want to stress:

    Somebody has to develop and maintain the freaking program too!

    Object orientation helps anything but the most trivial of applications to acvhieve better modularity and reuseability. Anyway your program is going to spend most of its time in development, not running, so anything that can help that process along is going to be a big help to your project. Please check out the benefits of the SW industries "best practices" and apply them to your project.

    You will save days and months of development time, during which you can run your finished program to your heart's content.

    --
    A)bort, R)etry or S)elf-destruct?
    1. Re:Development time vs. run time by ChaoticCoyote · · Score: 4, Insightful

      Using Object-Oriented constructs is no guarantee that a program is maintainable or even readable. I have seen some horrifying OOP code in my life, written by people so enamoured of syntax that they drown theircode in it.

      In numerical applications, and extra 10% can be the difference between success and failure. I'm corresponding with a fellow who works in meteorology; his company uses commodity boxes to compete with government-funded monopolies. For him, the ability to gain 10% is crucial.

      I am all in favor of object-oriented programming -- but my philosophy matches that of Bjarne Stroustrup, who refers to his language as a having "multiple paradigms." Use OO when it makes sense -- but use the right tool for the task at hand. C++ does not force you to use OOP when it doesn't make sense.

      Many numerical applications make mroe sense when using short variable names (that match formulas in texts) and a function-based approach (again, matching mathematical idiom).

    2. Re:Development time vs. run time by budGibson · · Score: 2
      Anyway your program is going to spend most of its time in development, not running, so anything that can help that process along is going to be a big help to your project.


      This is true, but in production use, code performance is critical. If you can cut execution time by a factor of two or more for any given hardware configuration, it can mean the difference between feasible and infeasible. For instance collaborative filtering on the web.

      A lot of optimizations in numerical computing languages involve removing OO features (e.g., matlab). Numerical computing seems to focus on vectorization (re-representing all problems in terms of vectors), a sort of one-size-fits-all data representation, that can than be used in highly optimized algorithms. At the end of the day, one has to wonder about the usefulness of the OO paradigm for heavy duty numerical computing.
    3. Re:Development time vs. run time by Harald74 · · Score: 1
      Using Object-Oriented constructs is no guarantee that a program is maintainable or even readable. I have seen some horrifying OOP code in my life, written by people so enamoured of syntax that they drown theircode in it.

      Of course, but then again functional code also becomes horrible if the programmer doesn't know what (s)he's doing.
      Use OO when it makes sense -- but use the right tool for the task at hand.

      I tend to think that all projects over 1000 LOC and that has to be worked on by more than one person is a good candidate for at least consider using OOD/OOP. But I expect that any person or team who knows one paradigm well is going to produce superiour code using that paradigm. Re-training also takes time. What I'm saying is that OO will pay off in the end.
      --
      A)bort, R)etry or S)elf-destruct?
    4. Re:Development time vs. run time by spiro_killglance · · Score: 2

      OO definitely helps modularity, and even splitting
      responsiblity between programmers, and help
      maintainity. But reuseability, not
      really, unless your writing nice well abstracted
      library functions, your pretty soon find that all
      the little extra features needed in the code for
      one project just won't fit with all the little
      extra features in the other project, and so you
      some end up to reusability by good old cut and paste.

    5. Re:Development time vs. run time by Caoch93 · · Score: 1
      I am all in favor of object-oriented programming -- but my philosophy matches that of Bjarne Stroustrup, who refers to his language as a having "multiple paradigms." Use OO when it makes sense -- but use the right tool for the task at hand. C++ does not force you to use OOP when it doesn't make sense.

      This is entirely a personal matter and I might even get labelled "flamebait" for this, but I really have to say...I've spent plenty of time working with C, C++, and Java. The end result is that I'd rather write in C or Java. C has the honesty of being strongly procedural, and if you wish to use some OO ideas where it makes sense, you can build up some limited OO constructs. Java is strongly OO, and if I don't like some of the limitations that come with Java (such as the floating point performance hit), I can link in C code with JNI. I'm fine with that. Each of these two approaches lets you build the tools you need when you need them.

      But C++? I can't stand the C++ way of doing things. What a mess. Stroustroup is right that it makes sense to use the best tool for the task at hand, but Stroustroup et al have taken that metaphor to a fault in all of the waywards "features" of C++. Unlike building OO ideas in C or linking procedural code with a strong OO language (like one can do with JNI), C++ throws a giant jumble of so-called "tools" at the programmer and lets him choose whichever attitude s/he wants.

      Why do I get annoyed at this? Simple. In the two cases I like, you're free to use whatever tools you like, but those tools must ultimately be expressed in terms of the overall principles of the language at hand. No C coder looking at an "object" in C can ignore the fact that it's just a collection of pointers. No Java coder can ignore the fact the native method is still in the context of a Java object. At the same time, though, these people can also go along with these ideas easily because everything has been expressed in the simple, pre-existing ideas of the language. A pseudo-OO method call in C is just working with a function pointer...a native method in Java is still a Java method.

      The problem is...C++, to me, lacks this overall paradigm, other than maybe "anything goes...no kidding". The language constructs in C++ just provide programmers with tools that defeat the idea of working within a paradigm at all. The result that I keep seeing is an endless parade of poorly bolted-on code from program maintainers before me. Friend functions parade through endlessly, turning the code into a pile of well-convoluted spaghetti.

      And I think what it boils down to is that many of C++'s features were designed by highly competent computer scientists who thought that they'd like to have certain pet features they liked a whole lot, so they just implemented them in C++. Afterthought upon afterthought has taken the "toolbox" model and left things the way they are. And I still hear cries from people for more new features in the language.

      The toolbox model is great, but the argument behind the toolbox metaphor needs some more thought. Unlike the box of tools in your garage, the choice of which "tool" you use in C++ (or any other language) actually changes the project you're working on. You cannot freely throw different solutions at something interchanagbly as a result, and if you do, your project can find itself going the way of the Tower of Babel.

      This isn't to say that I don't think C++ can be used for good things...what I am saying, though, is that, by making multiple paradigms available in the same project, it's easy to become buried under idiosyncracies that result from people picking whatever paradigm they want when they want it...and that a common paradigm that many programmers select is "whatever I want, whenever I want it."

      Personally, I would love to have a language as strongly and strictly OO as Java that could deliver native-code performance. I have not, as yet, seen one that really wowed me, though.

      Slap on an effective means of remote code download and execution without concern for the remote system's OS or architecture, and I'd be the first convert in line, too.

    6. Re:Development time vs. run time by ChaoticCoyote · · Score: 2
      The end result is that I'd rather write in C or Java. C has the honesty of being strongly procedural, and if you wish to use some OO ideas where it makes sense, you can build up some limited OO constructs. Java is strongly OO, and if I don't like some of the limitations that come with Java (such as the floating point performance hit), I can link in C code with JNI. I'm fine with that. Each of these two approaches lets you build the tools you need when you need them.

      Your comment matches one of the core points of my article. To quote from the article:

      For a long time, I strongly advocated changing Java to support numerical work. In recent months, I've decided that I was mistaken. We already have several good general-purpose programming languages; programmers would best be served by the refinement of existing tools for their featured environments. Rather than create a vast gray-area of similar languages, we need tools for creating powerful and focused solutions.

      Another of your comments:

      C++, to me, lacks this overall paradigm, other than maybe "anything goes...no kidding".

      I carry a Swiss Army knife with me everywhere (I saw too many episodes of MacGuyver, I think). It's a pretty good tool for most things, and it can do an awful lot, but it isn't as strong or useful as task-specific objects. The little scissors don't compare well to "real" scissors for serious paper-cutting; the saw works, but a chainsaw is better; the can opener functions but makes my hand shurt. None of the knife's tools are optimal -- but it's easier to carry one small red knife than it is for me to laod down with optimized gadgets.

      Of course, building a house with a Swiss Army Knife is somewhat insane as well. (At least one guy did this, but I can't find a web reference at the moment).

      In the end, it all comes down to a judgment call, which is likely to be different for different people.

    7. Re:Development time vs. run time by Caoch93 · · Score: 1
      Believe me when I say that, mostly, I do agree with your argument about languages that are well-targeted for certain goals. I think it's a useful idea. That said, though, I'd support changing Java to support numerical work. I believe that James Gosling supports this, too, and I recall that he's supposed to be working on a bunch of stuff for JDK 1.5 that would significantly improve number crunching. I read this all in a trade magazine some time ago now...maybe a year ago or so?

      To draw attention to your Swiss Army Knife metaphor...

      I carry a Swiss Army knife with me everywhere (I saw too many episodes of MacGuyver, I think). It's a pretty good tool for most things, and it can do an awful lot, but it isn't as strong or useful as task-specific objects. The little scissors don't compare well to "real" scissors for serious paper-cutting; the saw works, but a chainsaw is better; the can opener functions but makes my hand shurt. None of the knife's tools are optimal -- but it's easier to carry one small red knife than it is for me to laod down with optimized gadgets.

      First off, on a humorous note, I should mention that I used to carry a Swiss Army Knife with me, too, until I saw a friend of mine cut himself rather badly with one because his SAK didn't have a locking blade. I know some of them do have blade locks, but I've heard from other people that the locks don't really work and the knife blades slip anyway. Now, I carry with me a Spyderco, and while it doesn't have 20 tools with it, it also has a guarantee that the lock will not release unless the release button is pushed. I think there's something symbolic here...

      On a more serious note, though, when I gave up my SAK, I went through a process of asking myself how many times I used each tool on it and whether or not each tool used could be replaced easily. What I found out was that a knife, a keychain can opener, and a keychain bottle opener were all I really needed, anyway. I haven't missed the scissors, the leather punches, the saw, etc. Again, I think there's something symbolic there, too, that's applicable to this discussion.

      And now, to get a little more serious...again I'm not against the toolbox metaphor, but there's a difference between a true toolbox metaphor and the C++ take on having a kit of programming tools at your disposal. It boils down to this- if I use a socket wrench to tighten a nut, I can use anything that can grip the nut (crescent wrench, channel-locks, etc) to get it back off. That's because the use of the tool changes nothing. But C++ "tools" are facets of the language, and using one means changing the project and moving it along a specific paradigm. Once a path is taken...say...someone bolts non-OO code in with my OO code...it's hard to go back and do it the other way. This is the equivalent of making a nut that, once tightened with a socket wrench, cannot be messed with until someone changes the bolt. Your project isn't some stable thing you use "tools" on...your "tool" selection alters your project until you go back and rewrite your work. Rather than seeing the different language constructs as "tools", which I feel they are not, we should look at them as "parts" used in building. The question in picking which one shouldn't be "Is this the right tool for my immediate problem?" Instead, it should be "Is this going to contribute to a sensible enhancement, or will this cause the project to look like Frankenstein's monster?"

      As a result, I only apply the "tools" metaphor when there is a really good cause for indifference with respect to design. Perl is a language that I feel is built well around this metaphor, and since I hardly ever write anything I care about in Perl, I'm happy to apply it there...but I'm not going to do it with anything large, complex, or where there's personal investment.

    8. Re:Development time vs. run time by lamontg · · Score: 2

      The very problem with C++ is that it tries to have multiple paradigms. You use OO when you want to have large teams of people composed of people with a variety of skillsets and when you're not as concerned about overall performance. OO is for the 100,000-1,000,000 line kind of programs.

      For that kind of environment you want a language which is fully OO and lacks the flexibility of C++. You want garbage collection so that you don't have to waste time tracking down the memory leaks that your junior developers write. You want all functions to be virtual so that you don't have to waste time tracking down subtle errors there. What you're concerned about is Rapid Application Design which is something that Java was designed around and C++ was not.

      You can probably make C++ work this way. You can get the bohm gc and compile with virtual functions forced on (-fall-virtual in g++) and adopt other style guidelines to make it work. But at that point you might as well be using Java, particularly since you're never going to get C++ to read as cleanly as Java. Also doing this work to get C++ to act like Java sort of negates why you're trying to use RAD in the first place.

      Yes, I agree it makes sense to use the correct paradigm in the correct place, but I believe its generally better to use multiple languages to accomplish that. C++'s object-orientation is kind of an abortion. I can see how it might be good for scientific applications and computer games where you've got programming teams entirely composed of very smart people and you want OO and speed all in one package. For the rest of the world there is a much bigger issue than performance which is the ability to assemble a large team of people and rapidly produce a product that you can get to market faster than your competitors and with fewer bugs.

    9. Re:Development time vs. run time by Anonymous Coward · · Score: 0

      This argument is old. It has been presented numerous times over the past ten years, many times much more convincingly than appears here. If you want to strengthen your argument you probably shouldn't say things like "Java is strongly OO." You might also want to try being explicit about why C or Java is better than C++. Stroustrup actually has a faq on his home page which refutes most of the common criticisms applied to C++. You should be able to find this via google.
      PS:
      "I think...many of C++'s features were designed by highly competent computer scientists who thought that they'd like to have certain pet features they liked a whole lot, so they just implemented them in C++."
      -- C++, unlike Java, is a standard language(meaning that there exists an international standard for it.) It was designed by committee, and much of the design decisions are now public. So, if you would like to find out why certain features were added rather than relying on why you "think" they were added you can do this. The relevant works are listed in the C++ faq lite.

    10. Re:Development time vs. run time by Caoch93 · · Score: 1
      This argument is old. It has been presented numerous times over the past ten years, many times much more convincingly than appears here.

      Helloooo! A simple Slashdot opinion post is clearly not even intended to be on the same level as arguments with a bigger scope of time. You might also want to try being explicit about why C or Java is better than C++.

      I wasn't trying to say why C or Java is better than C++. I don't stoop to such vacant navel contemplation. I was making a statement of my own personal preference and giving a couple of general and personal reasons why.

      Stroustrup actually has a faq on his home page which refutes most of the common criticisms applied to C++. You should be able to find this via google.

      It would seem that Stroustrup's FAQ doesn't really refute many criticsms at all.

      The relevant works are listed in the C++ faq lite.

      Yep. For a fee.

  38. My Duron 1.1GHz must have a built-in Java VM ! by MarkoNo5 · · Score: 2, Interesting

    Using both Sun's and IBM's Java virtual machines I get the following results from 'time'.

    real 0m35.173s
    user 0m35.140s
    sys 0m0.030s

    The results vary from 35.130 to 35.160. When I run the c++ test with the following compiler options : -march=i686 -mcpu=i686 -O (somehow the mmx and sse option are rejected)

    real 0m43.467s
    user 0m41.790s
    sys 0m0.010s

    Can somebody explain this please ?

    1. Re:My Duron 1.1GHz must have a built-in Java VM ! by MarkoNo5 · · Score: 1

      That is -O3 of course, not -O.

  39. He DID use a JIT compiler by joss · · Score: 2

    > using an interpreter instead of a JIT compiler

    No, he wasnt.

    > Java's been shown time and time again to be as fast as FORTRAN/C++ when using a good compiler, rather than an interpreter. *sigh*

    No it hasn't, because it isn't.

    You can sigh all you like, it doesnt change a thing.

    You acknowledge your link is weak and biased, why not try posting a reasonable link, particuarly one which seems to show that java is as fast as fortran or C++ for anything meaningful.

    --
    http://rareformnewmedia.com/
  40. Re:fp by mvw · · Score: 3, Interesting

    Yes, indeed, what about fp (functional programming) and numerics? :)

    Funny thing is that the fp people have invested lots of brainpower into advanced functional programming techniques. Symbolic and logics math, yes I have seen software for it. But numerics?

    Is it possible that a functional language beats FORTRAN eg in eigenvector calculations?

    Regards,
    Marc

  41. doing IT buy the #'s, the 1st?, & last? good . by Anonymous Coward · · Score: 0

    so, if the "community" starts to wonder what all the tom shillerIE's about, they could just "move" the whole shooting match on over to: ...??? sourceforge?,,, uh,, no, let me think (you're right, that's a tough won for me, that's why we have you, to keep US on yOUR toes),,,,, osdn?, no.... how about ..........va.msn.net? ticker symbull: VAST?

    that's probably already taken.

    i get IT? do we smell sum plebytes getting roasted here?

  42. Only IBM's VM is fast by MarkoNo5 · · Score: 1

    I thought I still used Sun's VM as default, so that's why I thought it was just as fast as IBM1.3.1. When I explicitly select Sun1.4.1, the results are indeed _very_ poor.

    real 1m54.370s
    user 1m53.440s
    sys 0m0.040s

    For IBM 1.4.0 I get the following

    real 1m7.963s
    user 1m7.670s
    sys 0m0.010s

    I'm going to ask the IBM developer why 1.4 is so slow on their newsgroup. I hope they can fix the problem.

  43. Some interesting conclusions by njdj · · Score: 1, Flamebait

    1. Fortran is no faster than C++, given decent compilers (Intel C++).

    2. The g++ compiler is a pile of crap - it gave execution times more than double the times given by Intel C++. IMHO the difference is more than can reasonably be brushed off by saying that Intel know their own CPU better, or g++ has more features, or whatever the g++ fans will say. A difference as big as this means that - as an optimising compiler - g++ is broken.

    1. Re:Some interesting conclusions by JoeBuck · · Score: 2

      The author did a previous article comparing Intel and gcc C++ in detail. On average, Intel was about 15% better, not 2x.

      There are some tests where Intel is 2x better. That's useful data that will help the g++ folks improve.

      In any case, if you don't like g++, I'm sure that the authors will be happy to give you a full refund.

    2. Re:Some interesting conclusions by ChaoticCoyote · · Score: 2
      The g++ compiler is a pile of crap - it gave execution times more than double the times given by Intel C++. IMHO the difference is more than can reasonably be brushed off by saying that Intel know their own CPU better, or g++ has more features, or whatever the g++ fans will say. A difference as big as this means that - as an optimising compiler - g++ is broken.

      The statement above is a load of dingo's kidneys, to paraphrase Douglas Adams.

      Read my comparison of Intel and gcc for a broader view. No tool -- be it Fortran, or Java, or C++ -- can be accurately judged through the lens of a single test or review. Indeed, I have some applications where Intel performs poorly, due to a weak implementation of some STL classes. However, if I publish those results, I'll be beat up by the same nitwits who complain that a mathematical benchmark uses sin and cosine functions.

      I like the Intel compilers for most tasks -- but I am also a very strong supporter of the GNU gcc project, which produces a high-quality, portable compiler that is the true backbone of Free Software. Without gcc, there would be no Linux, or KDE, or Mono, or whatever else people find so fascinating. I may have my quibbles with gcc, but it is NOT a "pile of crap."

  44. Save us from java apologists by Anonymous Coward · · Score: 1, Insightful

    What is it with Java people that they are all up in arms when someone posts what we all already know? Java is *slow*. It is wonderful for certain types of applications, but it is *slow*.

    When I write an application, I want to write it in the most appropriate language, not just in the language I have a fetish for. If performance is important, you need to know how various languages perform. This page shows how java (the full system, ie. language, compiler, runtime, everyting) performs for a certain class of application, and it is performing badly.

    As for why it is performing badly, that does not matter at all. The mere fact that it is doing so makes it inappropriate for this type of application. And that is a valid conclusion in my book.

  45. Leaks in C++ by Antity · · Score: 3, Interesting

    (heck, 90% of C++ programs I see will leak heap memory if you have exceptions)

    In case any fellow beginning C++ programmer was wondering: This is because objects are only guaranteed to be destructed when an exception is thrown if and only if this exception is caught.

    So no matter what you're doing in your program, its main() should always look a bit like this to make sure every exception is caught:

    #include <stdexcept>
    #include <cstdlib>

    int
    main (int argc, char** argv) {
    int ret = EXIT_FAILURE;
    try {
    ret = do_something_in_my_code (argc, argv);
    } catch (const std::exception& e) {
    std::cerr << "Caught exception '" << e.what()
    << "' in main().\n";
    } catch (...) {
    std::cerr << "Caught unknown exception in main(). Sorry.\n";
    }
    return ret;
    }

    (Sorry, I can't seem to save indentation with /. HTML here)

    Please note that this way, you also always assure to have a valid shell return code (EXIT_SUCCESS from your function() would be the OK code).

    --
    42. Easy. What is 32 + 8 + 2?
    1. Re:Leaks in C++ by jhdsl · · Score: 1

      This is utter nonsense. Any decent OS releases all memory used by a program when that program exits.

      There is absolutely no point in catching all exceptions in main, it just shows the programmer ignorence of how memory handling in an OS works. Some exceptions are meant to not be catched when they occur, the shall crash the program. It is the exception variant of assert.

    2. Re:Leaks in C++ by X · · Score: 1

      Bzzt... You fail!

      This is actually a classic example of how people screw up exceptions in C++. Aside from a not using unknown() to handle errant exceptions, the bigger problem is the notion that try/catch blocks are how you avoid memory leaks in C++. Take a look at this old problem to give yourself an idea of some of the complexities with exceptions. While the problem does not create a resource leak (indeed, it effectively LOSES resources), it demonstrates how it can go wrong in the most surprising ways.

      While it is conceivable to get everything working right using try/catch blocks, you have to write a ton of insanely structured code, and it's very error prone.

      What you want to use is the "resource acquisition is initialization" idiom. Here's some info on it here. It's all about the stack and destructors man.

      --
      sigs are a waste of space
    3. Re: Leaks in C++ by Antity · · Score: 2

      This is utter nonsense. Any decent OS releases all memory used by a program when that program exits.

      This is utter nonsense. First, we're not only talking about memory here, the problem is all about freeing resources. Suppose your object acquired some resource on a remote host - maybe using RPC/UDP. When your program exits, no OS will free the object on the remote host and it will stay allocated until it times out. Bad.

      Second, if we're talking about freeing memory, you want to free it as soon as possible and not when the program ends.

      Then:

      it just shows the programmer ignorence of how memory handling in an OS works./

      No, this is how a PROGRAMMER should work. He shouldn't give a damn apple about how the underlying OS works.

      OS memory handling is irrelevant to the programmer.

      --
      42. Easy. What is 32 + 8 + 2?
    4. Re: Leaks in C++ by Antity · · Score: 1

      Many thanks; I had a look at the example (although this site is ill; the page keeps reloading all over and over again.. Turning JS off instead forwards to a page to turn JS on... same in Moz and IE. well).

      But I still not understand what's wrong with my example. AFAIK one should make sure that every exception possibly thrown should be catched because local objects' destructors won't be called if no catch is installed somewhere "above".

      I've never seen unknown() and'll go on looking for it (maybe some newer feature).

      Please note that I suggest that construct only once for main(). There's lots of things you really should not do using exceptions, but what's wrong with having a safety net in the root?

      You wouldn't happen to have a good online link to documentation about how to use standard exceptions correctly? I'm in templates ATM.

      --
      42. Easy. What is 32 + 8 + 2?
    5. Re: Leaks in C++ by X · · Score: 2

      Sorry, I misread your post. The problem you are talking about is real, but usually not an issue (because usually if you don't catch the exception the program exits, and all memory is recovered). I thought you were talking about a different problem.

      --
      sigs are a waste of space
    6. Re: Leaks in C++ by renoX · · Score: 2

      About your first point, you're right that in some case it matters, but those case are quite rare.

      How often do you use distributed application?
      Me never: so the clean solution is really rarely needed.

      About your second point: Second, if we're talking about freeing memory, you want to free it as soon as possible and not when the program ends.

      Uh? He is talking about freeing memory upon a fatal exception: the memory will be freed soon!
      Except in embeded case, it won't matter much.

      > He[a programer] shouldn't give a damn apple about how the underlying OS works.
      Uh?
      You're living in an ivory tower?
      Of course a programer has to make some asumptions about how the underlying OS work!
      The fewer asumption, the better I agree, but this particular asumption [OS frees memory of dead programs] is quite natural.
      Otherwise your OS would really by fragile as any "bad application" could easily crash the OS by using all the memory..

    7. Re: Leaks in C++ by Antity · · Score: 2

      Of course a programer has to make some asumptions about how the underlying OS work! The fewer asumption, the better I agree, but this particular asumption [OS frees memory of dead programs] is quite natural.

      No. Even in plain old C, memory management (and tracking, and freeing) is done by the runtime library if the programmer is not capable of doing it, not by the OS.

      If the OS provides a way to free memory that slips the RTL's organization (memory lists corrupted by badly programmed code), then that's a nice safety net to have, but never something to rely on from a programmer's point of view.

      We don't even need to start talking about portability here.

      --
      42. Easy. What is 32 + 8 + 2?
    8. Re: Leaks in C++ by jhdsl · · Score: 1

      Well, he responded to "I see will leak heap memory ..." so we are indeed talking of memory only.

      Second, releasing memory by exiting a program is magnitudes faster that doing it by running destructors. So when you say it is faster to run destructors, you are plain wrong.

  46. BTW C++ sucks by muyuubyou · · Score: 1

    C is much better. As an OO lang. , C++ is pure crap. I have plenty of experience with it and the only reason I use it is the code base and employers asking for it (strong reasons :) )

    Just a side note.

  47. This guy just doesn't get Java by X · · Score: 2

    He complains about the Java compilers complete lack of optimisation flags (duh... making optimisations to platform independant byte code is pretty useless, and generally counter productive... it's all done by the JRE, which actually has a number of flags for tweaking things, and there are many JRE's to choose from). He talks about how the JIT doesn't perform processor specific optimisations (it does in fact perform many processor specific optimisations, unfortunately his benchmark is written in such a way that none of them will get used). He talks about there being no interest in high-performance Java (the Java Grande group would beg to differ). Best of all, he keeps calling Java an interpretted language... even though he used gcj as part of his own benchmarks... Sigh.

    Worst of all he uses gcj without trying out TowerJ, which is a much more established Java-binary compiler. Sigh.

    --
    sigs are a waste of space
  48. Re:Like some cheese with your WHINE!? by X · · Score: 1

    Believe it or not, I'm not a Java "ZEALOT". Indeed, at my current place of employ I don't write any Java, and I have written more C++ code than Java in general. I would write similar content about other interpreted languages (Self, LISP, APL, Smalltalk, etc.) had the original article referenced them in a similar manner. These kinds of silly, mindless comments come up all the time, and they show a total lack of knowledge about how to benchmark systems, and more importantly a lack of knowledge about the systems they are benchmarking.

    --
    sigs are a waste of space
  49. Comments by the Author by ChaoticCoyote · · Score: 5, Informative

    Almost *ALL* of my email is related to Java. I'll be adding the IBM JDK and older versions of the Sun JDK later today, as per reader request.

    I'm making minor updates to the article as the day passes. I appreciate comments from everyone; once I'm through with my e-mail, I'll respond to these Slashdot comments.

    Additional benchmarks will be added to the article with time; I'm putting together a single-precision ("float") benchamrk, for example.

  50. People who don't know by Raedwald · · Score: 4, Insightful
    The C++ code does not use any object-oriented or exception-handling features of C++; essentially, this is a C program with minor C++ convenience features

    God, it feels like I've spent most of my professional life arguing with Fortran programmers. These people are ignorant, but arrogant. They think that because they have a Phd in Engineering (or Physics, or whatever) and can produce a syntactically-correct Fortran program, they know how to program, and can ignore advice backed up by thirty years of software engineering research and experience. Bizarrely, what little knowledge they have is about 35 years out of date, even for those in their twenties. They live in a ghetto.

    As anyone with even the slightest real computing knowledge knows, what gives you performance is the algorithm chosen, not the implementation. Therefore, what matters is how easy it is to implement a good algorithm. Which means, how easy it is to write a program that implements a difficult to understand algorithm (because an inobvious algorithm-- of course, there are some exceptions). Which means that support for modern programming techniques that help you produce easy to understand programs is important for producing high performance programs. You know, things like the following that are absent from the still widely used Fortran-77:

    • Requiring all variables are explicitly defined before use (accounts for one third of all coding errors in even carefully written Fortran progams). A requirement enforced by all other compiled languages now in common use.
    • Programmer-defined data structures (struct in C). Widely available elsewhere since the late 1960s.
    • Structured control structures (while, etc.). Old timers might be aware that that goto battles were fought and won in the rest of the world by about 1970.
    • Aggregation of subroutines into modules or packages. Widely available elsewhere since the mid 1970s.
    • Support for abstract data types. Widely available elsewhere since the early 1980s.
    • Support for polymorphism and inheritence (object orientation). Widely available elsewhere since the mid 1980s.

    So, comparing the performance of toy a Fortran program with its translation into C++ or Java shows nothing.

    What has happended is a second Software Engineering Crisis. The first 'Crisis was in the mainstream, data processing, part of the software industry. The introduction of more powerful computers resulted in large, complex programs that were failures because they were complicated (See The Mythical Man Month). Since then, we have developed software engineering techniques to deal with their problems, so now large programs can be much more complex (composed of many parts) without being excessively complicated (difficult to produce and understand). Since about twelve years ago, the increasing performance of computers means that number-crunching programs (e.g. CFD programs) don't merely process large amounts of data; they are also large and complicated in their own right. The Software Engineering Crisis has caught up with engineers and scientists. The sad thing is, many don't know it, or ignore the advice (and screamingly obvious signs) that it is here.

    --
    Ne mæg werig mod wyrde wiðstondan, ne se hreo hyge helpe gefremman.
    1. Re:People who don't know by white-mj · · Score: 1

      >

      Sheesh.

      Well *this* not-so-ignorant PhD physicist read enough of the article and code to know that the Fortran code was not the Fortran-77 the poster speaks of, but nice shiny Fortran 90.

      In light of the features of Fortran90, like
      implicit none, do while, modules and derived types, a few of the points the poster makes are at least a decade out of date.

      Norton et al. show how to achieve polymorphism in Fortran 90.
      http://www-hpc.jpl.nasa.gov/PEP/nortonc/RStop watch .pdf

      The Fortran 2000 draft has been out for some time
      http://www.ionet.net/~jwagener/j3/Fortran-20 0x.htm l
      and it is on its way to voting.
      http://www.nag.co.uk/sc22wg5/

    2. Re:People who don't know by Anonymous Coward · · Score: 0

      About the only intelligent comment here.

      Constant factor speed-ups are largely irrelevant -- it is the better algorithms that are important, and to do that you need no wasted time looking for memory leaks and other irrelevances.

    3. Re:People who don't know by Raedwald · · Score: 2
      In light of the features of Fortran90, like implicit none, do while, modules and derived types, a few of the points the poster makes are at least a decade out of date.

      These days, many Fortran programmers may well compile their code using a Fortran-90 compiler. But many still write mostly Fortran-77; they don't take advatage of the improvements (or only a few); indeed, they are in a frightening number of cases unaware of the advantages of the improvements.

      I've seen quite a bit of Fortran over the years, produced by people educated in England, the US, Canada, France, Germany, India, Iran, South Africa, Ireland, China, the former Yugoslavia (most parts), Scotland and Egypt. What is interesting is just how similar it all is, and how similar the attitudes of the people who wrote it are. Consider that it took about a dozen years for all the changes in Fortran-77 to percolate into the Fortran community. I think its interesting that such a subculture should exist, especially in an academic (or quasi academic) area where values such as expertise, innovation and technical skill might be expected to be influential. The very fact that you hang out on /. makes you exceptional. Perhaps your own particular area has a slightly different sub culture. Good for you!

      --
      Ne mæg werig mod wyrde wiðstondan, ne se hreo hyge helpe gefremman.
  51. I can only try... by ChaoticCoyote · · Score: 4, Informative

    ...the tools I have at hand. I have nothing against TowerJ, but can't test it if I don't own it. As for Java, I made note of a lack of flags, which is different from complaining. The -O flag is no longer supported by Sun's JDK according to the documentation.

    1. Re:I can only try... by X · · Score: 3, Informative

      Actually, you can test it even if you don't own it. They provide a free trial download right off their home page.

      The -O flag wasn't doing anything that improved performance on a JIT'd system, which is why it was removed. The problem is you're looking for optimisation flags in the wrong space. As long as the compiler is outputing byte codes any performance optimisations it might do are actually quite likely to make things worse. Admittedly, the SunVM doesn't have much in the way of floating point optimisation flags, but that is where performance optimisations kick in for JIT'd runtimes.

      --
      sigs are a waste of space
  52. Java is slow. PERIOD. by giel · · Score: 2

    As the author of the article states languages as Java and C++ contain a lot of functionality which has no additional use to the problems to be solved. I can imagine however some functional languages do.

    Object oriented languages do come with a lot of overhead eg. memory management and exception handling, where a language as Fortran is optimized for and has proven its power when it comes to complex calculations.

    As we all know should select the right language for the right job. Last year I've been working on an application which performs complicated flow calculations and presents the results through a web frontend. The easiest and (IMHO best) solution was to use three languages: Java, C and Fortran.

    • Frontend Java (servlet), sending requests to a deamon (running on an another machine).
    • Deamon C, receives requests, calls a Fortran function (which it was linked to) and returns the result.
    • Calculations Fortran, for calculation precision and because the calculation libraries existed and were certified.
    Ah, I forgot to mention it uses SQL to gather data from Oracle.

    Seemed a reasonable solution to me. Offcourse I could have used Perl, assembler and Lisp too and Prolog to solve queries, or Word97 macro's combined with Occam (which is very good at parallel computing) or whatever.

    Sometimes discussions about Java start to look like discussions about religion. Bad. Scares the hell out of me.

    --
    giel.y contains 2 shift/reduce conflicts
  53. Re:fp by tigersha · · Score: 3, Interesting

    Yes, look on Google for the language SISAL. That apparently beats Fortran.

    Sisal was developed at Los Alamos IIRC and those dudes have some of the fastest supercomputers in the world so they should know.

    The thing with FL's is not to use a lazy language, but a stract one (SISAL being a good example) should be able to be optimized quite heavily.

    --
    The dangers of excessive individualism are nothing compared to the oppressiveness of excessive collectivism
  54. Excellent site! by AssFace · · Score: 1

    I wasn't familliar with that site nor that author before but I love it!
    I'm gonna go back after work and read around there a bit more.

    --

    There are some odd things afoot now, in the Villa Straylight.
  55. Matlab for Linux by Kunta+Kinte · · Score: 2
    --
    Based on upvotes, Ageism is the only "-ism" Slashdotters care about and think isn't SJW
  56. GCC optimization by Antity · · Score: 2

    Since more x86 benchmarks have been posted, people might have a look at some hints for optimization. I will only list some options important for Athlons ATM:

    • -march=athlon-xp Yes, gcc-3.2 not only includes "athlon" but also "athlon-xp" and even more finer-graded pentium architectures. Use them! (implies -mcpu)
    • -O9 Always use it. I've yet to see miscompiled code with gcc-3.2 and -O9.
    • -fno-rtti / -fno-exceptions Only if you know the program isn't using them.
    • -ffast-math "Simplifies" some assumptions the compiler makes over your FPU code. Could lead to slightly inaccurate results (down the commata..), but usually works great, even with xaos and co and gives a huge speed boost
    • -fno-math-errno If you don't use errno after math operations at all
    • -funroll-loops / -funroll-all-loops Well.. unrolls some (1st) or all (2nd) of your loops. The first one is more sane and already included by many -O levels
    • -fprefetch-loop-arrays Important! On newer chips (Athlon/Pentium) this will generate instructions to prefetch memory before / while in a loop. This really works.
    • -malign-double Aligns doubles on 8 byte boundaries (instead of 4 byte boundaries). It's a must on newer x86s but it breaks compatibility with many precompiled libraries. Just try it. If it breaks, you have to recompile all libraries used with this option (which is a pain in the ass with Glib/GDK/GTK+ etc)
    • -mfpmath=sse Lets the compiler use SSE fp math instead of i387 math. pros and cons... it's worth a try for your application.
    • Last, but not least: -fssa This is still experimental! in gcc-3.2, but after applying all other options for almabench it gave me another full 1% of speed increase. Worth a look, but expect broken code to be generated.

    More in your favorite GCC docs.

    --
    42. Easy. What is 32 + 8 + 2?
    1. Re:GCC optimization by dmelomed · · Score: 1

      -fomit-frame-pointer will save a register on x86, and generate smaller code. This has been perfectly safe for me, but if you need debugging, it will break it.

      For floating point applications - sometimes optimizing for size (-Os) wins over other optimizations.

    2. Re:GCC optimization by Anonymous Coward · · Score: 0

      Out of curiosity, have you ever tried compiling the linux kernel with -O9? Does it work, and is there any noticeable improviement?

    3. Re:GCC optimization by akihabara · · Score: 1
      More in your favorite GCC docs.

      Typical slashdot poster. Of course, if you bothered to read those favourite docs yourself, you would know that -O9 is no different from -O3.

    4. Re: GCC optimization by Antity · · Score: 2

      if you bothered to read those favourite docs yourself, you would know that -O9 is no different from -O3.

      Hello? Did I say anything else?

      There's a difference in meaning. -O3 says: "Use that specific set of optimizations no matter what you can do or if you are a newer compiler", while -O9 says: "Use the maximum set of safe optimizations possible."

      --
      42. Easy. What is 32 + 8 + 2?
    5. Re: GCC optimization by Antity · · Score: 2

      -fomit-frame-pointer will save a register on x86, and generate smaller code. This has been perfectly safe for me, but if you need debugging, it will break it.

      You really got me there. Let me explain. I already started to write:

      This is turned on for every optimization level starting with -O3 by default.

      when I decided to give it another go with gcc-3.2 because I wasn't able to find this in its docs again.

      You're right: -fomit-frame-pointer is (no longer?) standard with higher -Os. I remember when it was (presumably with egcs, or pgcc, or gcc on m68k), when -fomit-frame-pointer was automatically activated by -O3 or higher.

      --
      42. Easy. What is 32 + 8 + 2?
    6. Re: GCC optimization by dmelomed · · Score: 1

      Also compiling with the highest optimization level won't necessarily result in the best possible binary. Profiling is the only way to tell whether it contributed to performance over lower optimization options, or was a detriment.

    7. Re: GCC optimization by akihabara · · Score: 1
      Hello? Did I say anything else?

      Yes, I said they're identical, you said they're not. Only one of us is right, and it's me.

      There's a difference in meaning. -O3 says: "Use that specific set of optimizations no matter what you can do or if you are a newer compiler", while -O9 says: "Use the maximum set of safe optimizations possible." The docs or read the source.
  57. Kernigan's k and java and perl by Camel+Pilot · · Score: 2

    From Kernigan's benchmark test


    k is faster (sum of times)
    k(32) perl(95) java(300) tcl(1400+)
    [k is much faster than c on strings and memory management.]

    k is shorter (lines of code)
    k(9) awk(66) perl(96) tcl(105) scheme(170) vb(200) java(350)";


    Interesting comparison. It took 350 lines of java to compare to 9 lines of k and 96 lines of Perl. also Java was 10 times slower than k and 3 times slower than Perl.

  58. A Very Clear Title by ChaoticCoyote · · Score: 2

    The title of the article CLEARLY states the limits of the tests: Linux Number Crunching: Benchmarking Compilers and Languages for ia32 That doesn't leave much room for doubt as to what I'm testing. I can add Solaris/SPARC numbers if anyone is interested.

  59. Functional Programming by ChaoticCoyote · · Score: 2

    I'm very interested in investigating the efficacy of functional programming for numerics. I've dabbled in Erlang and Haskell a bit, but haven't had an opportuntiy to study them in depth.

    So many tools, so little time to understand them...

    1. Re:Functional Programming by certron · · Score: 2

      Well, I was searching around for a good place to put this, making it a reply to the author of the article seems as good a place as any :-)

      When I was poking around for something to let me learn octave, I came across this:
      http://www.bagley.org/~doug/shootout/bench/ matrix/

      Perhaps it will be useful. It contains some code, too.

      --

      fair.org counterpunch.com truthout.com indymedia.org salon.com
      eff.org guerrilla.net debian.org gentoo.org
  60. start make an object by kfg · · Score: 2

    containing an item stop Now make another stop Now put them together in a new object stop Duplicate this object stop Now make a new object containing the two objects that were the result of the earlier operations stop Count the items in the latest object stop There are four of them stop stop

    2+2=4

    *Sometimes* purely symbolic typographical notation is *far* more readable than natural language.

    A wise programer will use each method appropriately. First learn *math,* THEN learn programming.

    KFG

  61. awk by Charles+Dodgeson · · Score: 4, Funny

    Surely people remember that most excellent O'Reilly book, Numerical Recipes in AWK. Unfortunately the 1998 review of it has disappeared.

    --
    Prime numbers are exactly what Alan Greenspan says they are -S. Minsky
  62. Which is faster, a Ferrari or a snail? by kfg · · Score: 2

    The answer is:

    You haven't got an fscking clue Sparky.

    I haven't given you any indication as to what sort of *conditions* performance will be measured under.

    The author of this benchmark test seems to understand this. Did anybody wailing on him for failures of the tests bother to read his benchmark caveat?

    All a benchmark test does is give you some understanding of how various things perform under the *precise* conditions applied during the test.

    The real value of benchmarking only comes after performing hundreds of tests under hundreds of variants of enviromental conditions.

    Doing so will increase your *human* wisdom about how certain things perform. Performance is a *value* judgement, and any human who abrogates their value judgment to a machine probably gets what they deserve.

    Too bad that sort of shit usually rolls downhill though.

    KFG

    1. Re:Which is faster, a Ferrari or a snail? by ChaoticCoyote · · Score: 2

      Thank you.

  63. An old policy by ChaoticCoyote · · Score: 4, Informative

    Back when I wrote reviews for print magazines (back when there were print magazines, that is), it was standard policy to limit reviews to the actually, shipping, commercial product. Demos often lack critical features (like optimizers) or are tuned for benchmark tests, so I've kept to that policy now that I write reviews for my own web site.

    I own licenses for the Intel compilers, for example -- and, of course, gcc and Sun Java don't cost anything in the first place. I'm considering my options in this case; long gone are the days when a dozen Fortran or C compilers would arrive at my door for a magazine review. Heck, there aren't a dozen compiler vendors left... ;)

    1. Re:An old policy by X · · Score: 2

      In TowerJ's case, the only difference from the production product is the limited time period for use (15 days). However, I checked it out myself and it appears that if you click through they've actually recalled their downloads program. Now you have to register to get to the code (and they may not even give it to you then).

      I can tell you from past experience though that it pretty much killed gcj in performance for this kind of stuff.

      --
      sigs are a waste of space
  64. Seti client? by Ignominious+Cow+Herd · · Score: 1

    I wonder if anyone has compiled the Seti@Home client with ICC and benchmarked against GCC? Could be interesting. What about similar distributed projects?

    --
    Lump lingered last in line for brains, and the ones she got were sorta rotten and insane.
  65. Java & Excelsior JET by GotLinux? · · Score: 1

    System: 1.0 Ghz P3, WinXP

    Solution 1, Java, JET Compiler 3.0
    http://www.excelsior-usa.com/jet.html
    defaul t compilation: jc almabench.class
    Time: 40.1 sec

    Solution 2, C++, GNU g++ 3.2 under cygwin
    CPPFLAGS = -march=pentium3, -mcpu=cpentium3, -O3, -msse, -mmmx
    Time: 82.0 sec

    Solution 3, JAVA + JDK1.4.1_01 javac
    javac -g:none almabench.java
    Time: 114.6 sec

    Times were computed by placing
    System.CurrentTimemillis()/time() before and after the program loop and taking the difference for java/cpp respectively

    From the results, the fastest solution I have at my disposal is java + JET. I need to get the Intel compilers, however. If relative speed of Intel vs. GNU holds, C++ and Java/JET will be about the same speed. I really get tired of "some language here" is slow/fast assertions. Whatever language you code in, you need to be efficient and have a good compiler. As always, there is more than one way to do things, and the most important requirement is to get the job done.

  66. gotta let the load-time situation settle down by Anonymous Coward · · Score: 0

    Since Java has such a different run model than Fortran/C++, the best way to get an apples to apples benchmark would be to write the Java code to run through the loop(s) a few hundred thousand times so the Hotspot compiler can optimize methods, then start the timer and run the timed loop(s).

    Sure load time (and Hotspot method optimization time) counts in the real world, but if we're deciding which language to use on a multi-hour run, what we really want to know is, how fast is the language once the system has paid all start-up costs and settles down.

    As for using this benchmark to reach sweeping conclusions about language speed, don't forget the obvious: everything depends on the speed of the languages double-precision math libraries, which most non-scientific applications don't use at all!

  67. intel tools don't work on AMD by Kludge · · Score: 1

    The intel libraries and compilers are nice and fast, but they don't optimize at all on AMD hardware, even though AMD hardware will do SSE as well. That bugs me a bit.

    1. Re:intel tools don't work on AMD by ChaoticCoyote · · Score: 2

      I really wish Slashdot allowed embedded sounds, so my message could laugh like I just did.

      On the other hand, I'm not sure I want to hear the audio for certain sites that appear frequently on Slashdot... ;}

      Ahem... back on topic. Do you actually expect Intel to produce a compiler that optimizes for processors produced by their biggest competitor?

      AMD appears to have a tight relationship with the gcc team; purportedly, gcc has excellent code generation for Athlons. If and when I get an Athlon system, I'll look into this.

    2. Re:intel tools don't work on AMD by klondike · · Score: 1

      Scott, thanks for your work, for publishing it and for wasting your time talking to this "rabid crowd of coffee spouting adolescents". As far as I know AMD has a working relationship with the Portland Group to optimize the PG compilers for AMD's new 64 bit architecture.

  68. nor matlab, nor ... by g4dget · · Score: 3
    There are plenty of "high performance array languages". Matlab is one of them, and so is Numerical Python, and A+. I don't see any particular reason to push a commercial product like "K". Languages like that derive their speed from excellent underlying libraries; there is nothing amazing or special about that.

    On this particular benchmark, "K" would probably perform very poorly--because it doesn't involve any big arrays. But, since you like "K" so much, why don't you try for yourself and report back?

    1. Re:nor matlab, nor ... by Anonymous Coward · · Score: 0

      There are plenty of "high performance array languages". Matlab is one of them

      No, it isn't.

      Matlab is a nice package, and is convenient to write, but it's mind-bogglingly slow compared to C.

      I've seen speedups of 10x or more when converting Matlab code to C.

      Don't believe me? Try it yourself.

    2. Re:nor matlab, nor ... by g4dget · · Score: 2
      Matlab is a nice package, and is convenient to write, but it's mind-bogglingly slow compared to C.

      Matlab is fast for operations on large arrays. That's because those operations are actually implemented in optimized C/Fortran.

      I've seen speedups of 10x or more when converting Matlab code to C.

      No doubt. That's probably because your Matlab code manipulated arrays via indexes and loops--that is slow. And it's slow in APL and related languages as well.

      And that's my point: languages like "K" are fast in the same sense as Matlab or Numerical Python. Such languages can manipulate huge arrays of data as efficiently as Fortran or C, but they have limitations when it comes to sequential numerical code.

  69. The guy is ignorant about Java by mike_malek · · Score: 3, Interesting
    First off, I have interned three times at Sun, working on virtual machines. So I know a fair bit about VM's, and their run-time and processor-specific optimizations.

    "it has always been clear that Java is inferior to native code applications in terms of raw power. Computational performance depends on the effective use of a target processor's instruction set; such optimization can not be expected of Java given its goals of universality and portability."

    This statement is simply not true! The portability nature of Java does not conflict with a virtual machine that does processor-specific optimizations. Take a look at Sun's HotSpot VM source code (it's publicly available!) In the IA32-specific code, you'll see lots of run-time switches to enable specific P4 optimizations, for example.

    "Perhaps Java's Just-in-Time compiler could be enhanced to perform processor-specific run-time optimizations; on the other hand, doing so would require different JVMs (Java Virtual Machines) for different architectures, or a single bloated JVM with run-time architecture detection."

    This already exists in the current HotSpot VM. There's an IA32 binary, which includes optimizations for several versions of IA32. It does not include PowerPC or SPARC code, as that's in a different binary.

    " The "ia32" world is already fragmented between Pentium III, Pentium IV, Itanium, Athlon, and Opteron architectures, each having unique requirements for optimization;"

    That's the challenges a VM writer has to deal with. And the HotSpot team did a great job in managing this complexity.

    In the future, if you (or anyone else, for the matter) takes the time to write a paper, you should do more research. Some of the statements above are simply misleading.

    1. Re:The guy is ignorant about Java by ChaoticCoyote · · Score: 2

      I've been writing and selling Java since it was first released, so I guess I have a bit of experience as well.

      The HotJava VM has received an official "End of Life" notice from Sun; its technology is incorporated into the current "client" and "server" VMs (so I'm told).

      Portability does conflict with native code generation. I agree that it is possible to be portable and support processor-specific JIT optimizations -- but as a practical matter, such is unlikely. Sun has X resource spread across at least 3 platforms (and their Linux JDK is not, IMHO, as impressive as it could be).

      Intel's C++ and Fortran compilers produce very good code because Intel only cares about Intel processors. The gcc team, on the other hand, has to focus on dozens of architectures, including many within the so-called "ia32" realm. It is possible for gcc to produce code that matches Intel's -- but is it unlikely because of a lack of focus.

      On the other hand, a broad view makes gcc (and Java) portable. And gcc can focus on optimizations for platforms (AMD, anyone?) that doe not have the luxury of vendor-created compilers.

      As you point out, the "ia32" world is very fragmented -- a problem that will only grow as AMD and Intel continue to try and distinguish themselves with new processors. Supporting all these variations would bloat the JVM considerably, or require many different JVMs that could be a support nightmare for Sun.

    2. Re:The guy is ignorant about Java by Glock27 · · Score: 2
      As you point out, the "ia32" world is very fragmented -- a problem that will only grow as AMD and Intel continue to try and distinguish themselves with new processors. Supporting all these variations would bloat the JVM considerably, or require many different JVMs that could be a support nightmare for Sun.

      I'm not sure the x86 VMs are too much for Sun - after all Sun now sells x86 boxes.

      There are only two meaningful variations on x86 - P4 and Athlon/Hammer. Not that big of a deal.

      I do think, though, that AMD should license someone's VM and then provide super high performance 64-bit versions for Hammer under both Windows and Linux. Direct x86-64 support for gcc/gcj from AMD would be nice too. :-)

      --
      Galileo: "The Earth revolves around the Sun!"
      Score: -1 100% Flamebait
    3. Re:The guy is ignorant about Java by mike_malek · · Score: 1
      The HotJava VM has received an official "End of Life" notice from Sun; its technology is incorporated into the current "client" and "server" VMs (so I'm told).

      Again, this is simply not true.


      The "client" and "server" compilers are both part of the HotSpot VM. (There's no such thing as "HotJava".) So HotSpot encompasses both compilers. Sun did not abandon its HotSpot team/work, trust sme. They're still going strong.

    4. Re:The guy is ignorant about Java by Anonymous Coward · · Score: 0

      It is interesting how you argue with the parent poster about what you speculate Java's behaviour is based solely on your experience with writing Java code.

      The real answer is clearly available if you take the time to look at the source code which is available.

      The HotSpot VM clearly does include processor specific optimization - and the reason why it's not a big support nightmare is because of the portability of the VM.

      The same codebase is used throughout every version, from SPARC to IA32. The processor specific parts including optimizations are isolated and is relatively easy to modify and update. It's no harder to add processor specific optimizations to HotSpot than it is to GCC.

      Why would Sun not be willing to make optimizations for their largest platform, especially for the most popular modern incarnation of it? It probably is not as aggressive as ICC at doing so, but nevertheless, you can be sure that the compiled code the the HotSpot compiler generates (not the bytecode) will be different on different IA32 processors.

    5. Re:The guy is ignorant about Java by X · · Score: 1

      Actually, there was such a thing as HotJava long ago... it definitely was EOL'd a long time ago.

      --
      sigs are a waste of space
    6. Re:The guy is ignorant about Java by Anonymous Coward · · Score: 0

      HotJava was a web browser....

    7. Re:The guy is ignorant about Java by kinga · · Score: 1

      HotJava is a *web browser*, and is indeed EOL. But HotSpot is, like you say, alive and well.

      BTW I interned with the JTech group at SunLabs East last year (Dave Detlefs & co.) and worked on new GC stuff in HotSpot. See my webpage (given in my user info) and drop me a line if you like -- be nice to hear from a fellow intern on /.

  70. not slow, but poor nonetheless by g4dget · · Score: 2
    Java isn't slow, but sometimes you do have to program more thoughtfully to make Java fast.

    This benchmark is about as "thoughtfully" written for Java as is possible--it includes only straight line arithmetic and a few simple array references. If a Java compiler/JIT can't do well on that, it's going to have real problems on other tasks.

    But, more generally, I think there is something wrong with your attitude that you have to write the code "carefully". What is the point of writing numerical code in Java if I have to write it in a Fortran 77 style to get any decent performance? This is the 21st century--we use abstraction in our numerical code: classes representing complex numbers, quaternions, rotation matrices, and other algebraic objects. Fortran 95 compilers can handle that and so can C++ compilers. C# has the primitives to deal with it efficiently (value classes, operators), and its compilers will likely catch up performance-wise.

    Only Java is conspicuously absent, lacking both the syntax to express such abstractions conveniently and the primitives to compile them efficiently.

    (And this isn't even taking into account all the floating point related blunders in the Java language definition that make writing efficient numerical Java code hard even if you do stick to a Fortran 77 style.)

    1. Re:not slow, but poor nonetheless by jeremyp · · Score: 2

      I think that the Java programmers should calm down and admit that the language is not very fast. The number of times I've seen them write "it's fast if you write your code carefully" and fail to see the irony of the statement is amazing. The whole point of Java is that you don't *have* to write things "carefully". C and C++ programs don't have issues with memory leaks and buffer overflows if you write them carefully.

      Anyway, hand optimisation is often a bad thing. Good compilers / interpreters are written by people with a much better understanding of the machine architecture than the average high level language application programmer and attempted hand optimisations can actually make performance worse. The other thing is that hand optimisation can increase the complexity of the code making it slower and harder to maintain.

      Java programmers should realise that outright run time speed is really not that important for most applications and point out that if their app is only half the speed that represents 18 months of computer development (according to Moore's Law) but on the other hand it took three weeks less dev, only costs 50% of the maintainance and has fewer security holes (I made the numbers up - I leave it to the Java zealots to provide some real figures). Some of the money saved can be used to buy the extra hardware needed.

      It doesn't matter if something is fast, only that it is fast *enough*.

      --
      All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe
  71. It has been done by popmaker · · Score: 1

    "Intel does not support all gcc language extensions; while it has been used to compile the Linux kernel and other free software projects, it is not a drop-in replacement for gcc."

    found at the bottom of http://www.coyotegulch.com/reviews/intel_comp/inte l_gcc_bench2.html

  72. bad comparison, and who cares anyway? by g4dget · · Score: 2
    First of all, it's hard to tell how the two compare. Does the Lahey compiler assume it's compiling for Pentium? Does it use inline trig functions? Does it use MMX? GNU C is very conservative about assumptions, generating code that should run anywhere by default. Give it some more machine-specific options.

    Second, who cares anyway? The reason why people don't bother hacking Fortran for Linux in a big way is because the people who could contribute to such an effort are already using C++. C++ has much better abstraction facilities for numerical code than Fortran 77 and even Fortran 95. And another big chunk of the market goes to Matlab, Numerical Python, and software like that. Dusty Fortran 77 decks can be compiled adequately with f2c or g77 and linked into C++, Python, or Matlab code.

  73. Jet is Windows-only by ChaoticCoyote · · Score: 2

    What is the point of a portable programming language if you tie it to a specific platform? I don't see a Linux (or Mac, or Sparc, or...) version of Jet on their web site.

  74. meaningless benchmark by g4dget · · Score: 2
    Looking at it briefly, the benchmark pretty much seems to test only straight line numerical code, and it seems to be dominated by calls to trigonometric functions. All the differences between the results might be explained just by how trigonometric functions are handled. GNU C always translates them into function calls, and there are good reasons for that.

    The benchmark also doesn't seem to be done very carefully: I didn't see any analysis of the generated assembly language (does the Intel compiler inline the code, does it use x87 instructions for trig functions), or verification of the results (do the different programs produce the same results when compiled with different compilers), or execution profiling (what dominates the running time). These ought to be part of any new benchmark program.

    1. Re:meaningless benchmark by ChaoticCoyote · · Score: 2
      Looking at it briefly, the benchmark pretty much seems to test only straight line numerical code, and it seems to be dominated by calls to trigonometric functions.

      Well, considering that what I was interested in, I must have done a good job on the benchmark! ;) I think the title was pretty explicit about my intent.

      All the differences between the results might be explained just by how trigonometric functions are handled. GNU C always translates them into function calls, and there are good reasons for that.

      Indeed, I think this is the root of gcc's difficulties. It doesn't invalidate the test by any means; in fact, I've started discussing this very issue on the gcc mailing list. I'll be looking at some generated machine code this evening, which leads to your final comment...

      I didn't see any analysis of the generated assembly language.

      The point of using a high-level language is to avoid the need to play in assembly-land. I like programming for assemblers, but it isn't practical. The trick is picking the right level of hardware abstraction -- do you write for an assembler, a traditional programming language, or a high-level tool like Java or Python? Making decisions involves analyzing trade-offs between development time, run-time, and knowledge.

    2. Re:meaningless benchmark by g4dget · · Score: 3, Interesting
      Indeed, I think this is the root of gcc's difficulties. It doesn't invalidate the test by any means

      Oh, yes, it does. If you want GNU C/C++ to inline trig functions and/or use the machine instructions, you can get it to do that, too. But there are good reasons why it doesn't do that by default. There are other options you can give GNU C/C++ to tell it to make assumptions that let it optimize more. It's really for you to decide what tradeoffs you want.

      The point of using a high-level language is to avoid the need to play in assembly-land.

      For day-to-day programming, I agree. But if you do benchmarks, you have to understand assembly language and look at it. There are a lot of other low-level details you need to look at and understand as well (e.g., caching). That's not so that you can tune your benchmarks for it, it's so that you can determine whether your benchmark is actually doing what you think it is doing.

      The trick is picking the right level of hardware abstraction -- do you write for an assembler

      Unfortunately, your code doesn't test the efficiency of abstraction at all--your code is something that could have been written in Fortran 77. Once you actually start moving to higher levels of abstraction, Fortran 95's capabilities are limited, and Java's performance becomes abysmal. Pretty much only C++ has all the necessary hooks to write efficient high-level numerical code at this point.

      Note, incidentally, that even if your benchmarks are representative, the Pentium4 is probably still not the best solution in terms of price/performance. That's another important factor to be taken into account when benchmarking: how much does that performance actually cost.

      (Incidentally, I hope JPL isn't using this kind of code for actual navigation.)

    3. Re:meaningless benchmark by g4dget · · Score: 2
      Using gcc-3.2, telling it to inline the math functions and using sincos for some of the trig calls instead of separate sin/cos calls cuts execution time from 44 seconds to 29 seconds on my machine.

      Maybe the Intel compiler uses sincos automatically; that would account for most of the difference.

  75. Re:fp by JoeBuck · · Score: 3, Informative

    For the specific case of algorithms that can be expressed strictly in terms of bounded loops where the loop bounds can all be determined at compile time, so that there are no run-time tests needed to determine if some computation must be performed or not, functional programming styles can be near-optimal. Analysis techniques can radically restructure such programs, completely reorganizing the loop nesting.

    There have been a variety of stream-oriented or single-assignment languages to make such things possible: Silage and DFL, Lucid, Lustre, Sisal, and others. You can get very good code from such languages, but they aren't very general.

  76. JAVA is not JVM-only by GotLinux? · · Score: 1

    You're right. I wish JET would work on Linux. Equivalently, I wish that the GNU g++ compiler made C++ code as fast as JAVA w/ JET compilation.

    The point remains the same though, that JAVA code compiled to the native platform I'm using at the moment (WindowsXP) is faster than C++/FORTRAN by a factor of 2 over GNU GCC.

    Reccomend what you like, but those are the numbers.

    (btw, I'm a grad student with no affiliation to any vendor)

  77. FORTRAN 77? by twitter · · Score: 2

    Thanks for the nice scientific computing benchmarks. The only thing that I could have asked for was a run of G77 code. Static memory and only pass by reference should make it quick, no? One day, I think I'll have to try it out myself.

    --

    Friends don't help friends install M$ junk.

  78. interpreters are SLOW by js7a · · Score: 2

    Octave, and all but the very latest version (i.e., of some months ago) of MATLAB are interpreters, and therefore very slow on everything with loops. Granted, there is a lot you can do with some expressions in MATLAB, but anything more complicated than eigenvectors is going to need a loop, and thus will be slowed by the interpreter.

    1. Re:interpreters are SLOW by sql*kitten · · Score: 2

      Octave, and all but the very latest version (i.e., of some months ago) of MATLAB are interpreters, and therefore very slow on everything with loops. Granted, there is a lot you can do with some expressions in MATLAB, but anything more complicated than eigenvectors is going to need a loop, and thus will be slowed by the interpreter.

      You've been able to compile MATLAB for a while now (MEX file, IIRC). And the point of MATLAB is that you have to think in terms of vectors - you would never loop over an array, you would perform the calculation on the array as a vector, which gets you straight into optimized routines in the MATLAB core.

    2. Re:interpreters are SLOW by Anonymous Coward · · Score: 0

      The latest Matlab release (6.5 R13) has enhancements to speedup loops.

      By slow, I presume you mean execution speed and not the development time. A good working matlab (or similar code) is easily converted into another faster option (all or partly in C/C++ or Fortran). While Matlab has a compiler, the first version produced faster C code than Matlab but I did not see a difference in the second version (no clue in the latest version).

  79. -1 troll by Anonymous Coward · · Score: 0

    LOL, why is there always at least one K troll in every single thread that has anything about programming languages?

    He didn't include a ton of languages, but that doesn't mean anything at all. It's hard to accurately benchmark in every single language ever made. Not only would you need to know how to optimize each one, but you would have to rewrite the tests in each language... c'mon.

    People would be using K more if there was a reason. At least at this point in time there is no compelling reason to use K. It's slower than C/C++ for many things and is detrimentally terse (read: error prone).

  80. A+ v K by Jayson · · Score: 1

    K is written by the same person that orignially developer A+, Arthur Whitney. I have never used A+, but Arthur says that K is much faster than A+.

  81. Portland Group Compiler.... by 3rd_Floo · · Score: 2, Interesting

    I know it costs a little money, but i would be very intrested to see the PGI compiler set tested up there as well.. I've seen on alot of CFD code have 10x speedups over g77 with pgf77. I do know that PGI has a 15 day trial license for their compiler, that should be long enough for a test run of the almabench to run.

    1. Re:Portland Group Compiler.... by Anonymous Coward · · Score: 1, Interesting

      The Portland Group Compiler was chosen as
      the default compiler on our Linux Workstations
      (KNMI, the Dutch Weather Service).

      The reason for this was that PGI Fortran simply
      compiled everything we threw at it - certainly
      not because it generated the fastest code in
      town.

      In fact, for the first program I tried with it,
      g77 actually generated code that was 10 % faster
      than the PGI generated stuff.

      Toon Moene

  82. KDB and joins by Jayson · · Score: 1

    In KDB, unlike many other databases systems, normailization will increase speed. Other multidimensional dbs will try to denormalize data to run faster, but KDB isn't like that.

    KDB really has two query language (and a stored procedure language): SQL92 and KSQL. SQL92 is translated ti KSQL, a more featureful and simplier version of SQL. In KSQL joins are implemented as pointer chasing and very cheap: "Parent.Child.datum" will join tables Partent and Child on the key and return the datum field of table Child. No more complicated join syntax.

  83. Troll? No. Speading the Kospel by Jayson · · Score: 1

    Yes, at some level this was an attention seeking post. I try to pump up the language whenever I get a chance to because I am amazed by it. This should be one direction the future of computer languages (and databases) takes. I still have a hard time grasping the simplicity and power in the language.

    If there are any other K "trolls" (probably better called Kx shills... I'll admit to that one) here I would be surprised. I thought I was the only one.

    I wasn't seriously expressing disbelief at him not including every language (especially unknown ones like K). I understand that the work it takes to do these things (and the tedium). However, maybe somebody will see this and next time they need to do something that fits K, they would think about it for a second... or maybe somebody will see this, become interested, and go learn K and use it in the future. That is how I became hooked. I used to use c, java, anc scheme (especially scheme and lisp) for everything. Now I use C when necessary and K for most other things.

    1. Re:Troll? No. Speading the Kospel by Anonymous Coward · · Score: 0

      My guess is you only work in academia?

      Yes, K looks like something fun that an inexperienced programmer or student would play with because of the gee-wiz factor (highly terse, functional, etc.). But really, I don't see K becoming popular in the mainstream commercial world.

      While I can't say I've written thousands of lines of code in it, I have written enough to get the feel. The language is unsuitable for large project development and highly prone to typo errors (and nearly impossible to read when you go try to find errors). This is OK for playing around but for time critical projects with many programmers involved K is just not good.

      Plus, like many functional languages, you needs to know a million and one tricks if you want it to run as fast as a C/C++ program and sometimes it's just plain impossible to make it that fast. I'm not avocating C/C++ (painful languages to say the least) but for the most part, they are the performance leaders.

      I would like to see a good C/C++ programmer implement the KDB (using the same algorithms & techiques as the native K implementation). I bet it would be faster.

  84. yes, scalar data manipulation isn't as fast by Jayson · · Score: 1

    In K you always want to deal with large chuncks of like data: bulk good, scalar bad. However, there seems to be a very small class of problems where you can't write an array version of them. And this array programming methodology happens to lead to very fast code, too.

  85. Oh, I think I understand what you said. by Jayson · · Score: 1

    I think I just understood what you meant concerning updates. Yes, in KDB batching updates together in bulk is much more efficient than doing singular updates.

  86. almabench and c-sharp results by halfdan+the+black · · Score: 2, Informative

    I just ported the java version of almabench to c#.

    I also compiled the cpp version , with MSVC 7.0, pentium pro optimizations. I obtained identical results from pentium and pentium pro optimizations.

    I ran the two programs on my 3 machines and the results are:

    1: AMD AthlonXP 1900+, 512 MB, Windows XP Pro:
    cpp: 25 seconds, c-sharp: 27 seconds

    2: Intel Pentium3 1300, 1024 MB, Windows XP Pro:
    cpp: 33 seconds, c-sharp: 36 seconds

    3: AMD AthlonXP 1500+, 512 MB, Windows 2000 Workstation:
    cpp: 39 seconds, c-sharp: 43 seconds

    Looks like c-sharp compares pretty well with c++, my guess for the slowdown is the array boundry checking.

    If anyone wants a copy of the cs version, send me an e-mail.

  87. Re:Numbers of some Interest. Conclusions a yawn. by Anonymous Coward · · Score: 0

    That C++ performed as well as Fortran on the author's examples is interesting to me. Is the C++ implementations getting better or is the Fortan complier gone soft?

    I would guess that the C++ code did just as well as the fortran code because it didn't use many object-oriented features. Intel knows how to make a fast compiler, and straight-forward procedural numerics in C++ should turn out to be just as fast as the fortran code.

  88. With every GHz milestone... by irritating+environme · · Score: 1

    While I used to be in the C/C++ crowd for performance back in the days of 233Mhz processors, with every GHz milestone this argument becomes more and more invalid. Remember, these days a 3Ghz machine is available for less than a thousand dollars.

    If you're performing atmospheric simulations on a 50-Terahertz supercomputer use C. But with 90% of the code these days in business (which is the majority of custom code written in the world), Java's speed is acceptable and its portability and memory garbage collection outweigh any speed advantages of C/C++ in a Gigahertz world.

    The portability issue is even valid in academicia, where in my school we had NeXT, Mac, Windoze, NeXT-x86, and SGIs, and now Linux. UNIX programs are pseudo-portable, but not like Java.
    Most app slowdown these days is database processing and network transport.

    --


    Hey, I'm just your average shit and piss factory.
    1. Re:With every GHz milestone... by 0x0d0a · · Score: 3, Interesting

      But with 90% of the code these days in business (which is the majority of custom code written in the world), Java's speed is acceptable and its portability and memory garbage collection outweigh any speed advantages of C/C++ in a Gigahertz world.

      Sure. Java's fine for doing a front end or simple database accessor. Hell, Hypercard was great for this.

      It's just not so great to do mainstream apps in, and people claiming that Java is "just as fast as C", which sometimes gets these people to waste time trying to implement their app in Java, gets my gander.

      Look at Corel's suite. They implemented the *entire stupid thing* in Java because it was going to be the "next big thing" and eventually be as "fast as C", according to the frenzied shouts of some of the Java supporters. Then they had to throw the whole thing out because of performance issues. I can't even imagine the cost, both direct and strategic (cost in time sitting on your ass while your competitor does something) to Corel. Same thing happened to Mozilla...the thing was originally going to be in Java. That idea got nixed...

      The other thing that vaguely pisses me off is that almost all of the things that Java does that make performance *suck* really aren't necessary. You can design a fast language that has most of its security model. Ocaml is quite safe -- moreso than Java -- but the Ocaml people imposed almost no overhead from C, because they avoided adding features that required runtime overhead, but went all out on things that could be somehow finagled into compile-time work. They *do* do most array bounds checking, but that's about it. Ocaml has GC, portability, and type safety...it just does almost all its work at compile time. I'd be willing to use Ocaml (well, actually I don't like functional languages much, but I'd endorse its performance) for almost any of the situations where I'd use C or C++.

      I'm not a huge fan of Ocaml itself, but it's a model for what *should* have been done with Java. If a feature is going to nail you performance-wise -- if users are going to have to do contortions to get decent performance -- you should think long and hard before adding it. Everything that sounded "cool" ended up in Java, which resulted in countless wasted CPU cycles for users around the world.

      I don't see why, as processors get faster, people feel the need to keep computers equivalently slow. Why not take advantage of the constant-time improvement? We can do better optimizations, do caching, because now we have the memory and extra constant time to do so. We have better body of knowledge about compilers, so why can't we *improve* performance instead of hurting it? It's *stupid*.

    2. Re:With every GHz milestone... by bluFox · · Score: 1

      Dont get me wrong,

      but it would do good to compare the IDE's which are java based (jbuilder and eclipse) with the IDE's that are C++ based (Visual C++ on NT KDevelope in *nixes )

      I am yet to see an IDE that is java based that has some what the same responsiveness of the c/c++ based ones give us even on the latest cpu's

      -------------

      --
      ~561
    3. Re:With every GHz milestone... by irritating+environme · · Score: 1

      You nailed the feature creep point. I'd say that instead of Java adding with each release a new whole toolbox to GUI tools, just optimize what's in there, and let marching processor speeds render the C-based GUI vs. Java-based GUI indistinguishable. Why the last couple of BILLION-cycles-per-second increases didn't take care of this is beyond me. I mean, a BILLION (insert Carl Sagan voice) ops per second...
      BTW if Corel did port a suite to Java and chucked it, could they PLEASE release it as open source?

      --


      Hey, I'm just your average shit and piss factory.
    4. Re:With every GHz milestone... by Anonymous Coward · · Score: 0

      > The portability issue is even valid in academicia, where in my school we had NeXT, Mac, Windoze, NeXT-x86, and SGIs, and now Linux. UNIX programs are pseudo-portable, but not like Java.

      <sarcasm>
      Oh. Point me to the JDK for OPENSTEP 4.2 (aka NeXT-x86). Please.
      </sarcasm>

    5. Re:With every GHz milestone... by Anonymous Coward · · Score: 0

      Sure. Visual C++ is much faster than any java IDE I know.

      But I am 10 times more productive in Idea.

  89. I am sure by Inf0phreak · · Score: 1

    that someone could cook up a single line of Perl code that could do all that. Of course, the code would be write-only and hellishly slow (and probably involve one or more regular expressions of extraordinary length), so it wouldn't do much good though.

    --
    ________
    Entranced by anime since late summer 2001 and loving it ^_^
  90. Re:yes, scIn Kalar data manipulation isn't as fast by g4dget · · Score: 2
    In K you always want to deal with large chuncks of like data: bulk good, scalar bad. However, there seems to be a very small class of problems where you can't write an array version of them. And this array programming methodology happens to lead to very fast code, too.

    As I was saying, there is nothing special about "K", it's just like Matlab, Numerical Python, APL, A+, and lots of other tools. And your assessment that "This seems like something that would be perfect for the language." is just wrong: simulations of celestial bodies are about as ill-suited to array processing languages like "K" as can be.

    That really leaves me wondering: what is your interest in "K"? It's the wrong tool for this job and there are plenty of other languages like it, many of them free and much more widely used.

  91. A Few Other Fast Ones by Lucas+Membrane · · Score: 3, Informative
    OCaml -- if you can do tail-recursive list processing instead of array processing, this is just about neck and neck with anything else. Arrays are slower.

    Corman Lisp and MLton -- Other fast functional languages.

    GNAT Ada -- Runs pretty close to C/C++ speed. Sometimes faster if the compiler can do expeditious compile-time optimizations.

  92. Trig stuff by ChaoticCoyote · · Score: 2

    Thanks for the pointer; however, I looked through the gcc documentation (on the gcc web site) for any options related to intrinsic functions. I didn't see what you allude to; which specific options did you use?

    1. Re:Trig stuff by g4dget · · Score: 2

      -ffast-math should inline the trig functions. However the Pentium trig functions are not entirely standards conforming, which is why this isn't the default. The trig functions in bits/mathinline.h try to work around the limitations while still going inline.

      There are several other -f options you should give if you care about maximum performance; since I don't use Pentium4, you'll have to experiment yourself and find the best combination. On my aging Athlon, this seemed to work pretty well: "-O4 -finline -mcpu=athlon -msse -ffast-math -fomit-frame-pointer -fschedule-insns -funroll-all-loops".

      For inlining "sincos", you can use the sincos function from bits/mathinline.h, which attempts to be correct even for large arguments. If you want more speed, use this definition:

      inline void dsincos(double &s,double &c,double a) {
      asm("fsincos" : "=t" (c), "=u" (s) : "0" (a));
      }

      Sincos should really be part of any standard numerical library; it's an odd omission that it's not in C99.

      It's not entirely clear to me whether an optimizing compiler can legitimately perform this optimization itself. You might suggest it to the GNU C developers and see what they say; they may have considered and rejected it.

      Please let us know what the Intel C++ compiler outputs and whether the differences really are due to the use of fsincos.

  93. my interest by Jayson · · Score: 1

    I really don't know the nature of celestial simulations. I used the think the same about many string processing routines, too, and that just proved that I didn't know how to vectorize the problem. So my history of knowing that is vectorizable isn't the best.

    By "plenty" you mean APL, J, matlab, SAS, and a couple others? Well, I think that K has them beat in most categories. For simplicity trying to compare K against any of them is silly. J is a monstrously difficult and complex language to me. SAS has these huge tomes for manuals. In all fairness, it has a very large library, and that is most of the documentation. However, SAS (and matlab) are far more limited in aplicability. K is a general pupose language and is used in many different fields. You would not see a database written in matlab, because it is the wrong tol. However K is the right tool for that, and K is also the right tool for stock market analysis, and data mining, and even something like parsing is very simple in K. After having to learn SAS and other small specialty languages, I would rather just learn K once.

    If you try to compare on performance considerations, it is also hard to beat K. I don't know clockins on matlab, but K for complex problems will run as fast (and often faster) than C. Beside just making array processing easy, it gives you excellend memory management and manipulation.

    As with any language, there is a classes of problems that are not appropriate, but for K that seems to be a very small class. Celestial simulations might just be a problem that isn't easily vectorizable. Or maybe matlab might run it faster (I doubt it, though). The only way you really learn about the costs and benefits of a particular language is by using it, though.

  94. close, here is a K adage by Jayson · · Score: 2

    The creator of K once posted a list of "you know you are getting better at K when..." to the mailing list. One of them was "You know you are getting better at K... when zip expands."

  95. Illegal Java by Latent+Heat · · Score: 2
    My experience is with illegal Java -- I found that J++, C#, and VB.NET all run at the same speed, and they range to within 10 percent to maybe a factor of 2 off from VC++ when doing signal processing -- mostly multiply-accumulates and no trig.

    I believe the problem of optimizing byte-code for numeric work has essentially been solved, and for a byte-code system to turn in poor benchmarks means you have a bad library or a bad JVM or something. There may be reasons to stay with C++ -- templates, pure open-source implementations -- but numeric speed is not one of them unless you are quibbling over the last 10 percent.

    Now GUI's and other libraries are another matter. Don't you think something like SWT, tuned for individual platforms, will knock the socks off Swing, generalized for all platforms?

  96. Article Updated; My Comments on Your Comments! by ChaoticCoyote · · Score: 3, Informative

    The original article generated an exceptional collection of interesting and helpful of responses. In this section, I'll run down the important points people made.

    Note: This is a duplicate of a new section I added to the review; I'm posting it here for posterity.

    An overwhelming number of people suggested that I include results for IBM JDKs -- and I have. In fact, I've added results for Sun JDK 1.3.1_06, IBM JDK 1.4.0, and IBM 1.3.1 RC3. Adding these JVMs made a significant difference in the results, cutting runtimes in half. On the other hand, almabench runs as an infinite loop with Sun's 1.3.1 JVM (it starts, but never finishes). Note that I recompiled almabench with the corresponding javac for each JDK, so the JVMs were executing code generated by their corresponding compiler.

    The problem with Java's performance is not my code or my lack of Java skills -- what real problem is that Java 1.4 is slow. Both the Sun and IBM JVMs lost significant performance in the move from 1.3.1 to 1.4, whether due to a new language requirement or other factors. My faith in Java is severely shaken when applications lose significant performance by upgrading to the current release of Java.

    Java 1.4 added many new features to the language and packages; however, changing from version 1.3 to 1.4 should not double run-times! Nor am I comforted by the problems of Sun's 1.3.1 server JVM.

    Given the nature of the problem, my conclusions about Java stand (albeit slightly softened). By Sun's own definition, JDK 1.3.1 is obsolete; the fact that it performs better than the most current JDK is indicative of a serious problem with Sun's improvements to their language. Since Java 1.4.1 is what Sun is promoting, so that is what I base my conclusion on. I can say that IBM's product is superior, and have already set it is my default JDK. It's no wonder Sun is upset about IBM usurping Java -- IBM is producing better tools.

    Some people asked if my Java results were biased by the amount of time it takes to load the JVM. I've tested several empty and near-empty applications; a Hello, world program, for example loads and runs in less than 2/10ths of a second -- hardly significant. The start-up time increases with the number of imports -- but almabench.java imports only one small class package, java.math.*, which (in my tests) does not impose measurable overhead.

    I did not include any commercial Java compilers. Most, like the oft-cited Excelsior JET, are Windows-only; this article is about Linux. I don't benchmark Visual C++ or C# for the same reason (although I will look at Mono and C# some time in the future). The free version of Borland C++ does not include a complete optimizer, so I don't think it fits in this review.

    How do I know that the programs are producing the correct output? Each program includes code to display results; I run the programs with I/O to ensure that all calculations are being performed, then I comment out any header inclusions, imports, and print statements for actual testing.

    How am I timing the results? With the Linux time command. Table 3 reports the real value reported by time (the elapsed time of execution.) Embedding timers in the actual code is fraught with problems; for example, each language implements different time scales and abilities. I'm sure someone will tell me that time is full of problems too, but it works for me and is consistent across all programming languages.

    Amid the barrage of Java-related comments, a few people actually noticed the Fortran code. I am looking at other Fortran compilers for future updates. As for GNU g77 -- I wrote the code in Fortran 95 because I find Fortran 77 to be annoying. I wrote piles of Fortran 77 back in my CDC and VAX days, but these days I'm writing for environments where Fortran 95 is more appropriate. Believe it or not, Fortran 95 is a very clean, orderly language that eliminates many Fortran 77 idiosyncrasies while adding features important for high-performance coding.

    1. Re:Article Updated; My Comments on Your Comments! by Anonymous Coward · · Score: 0

      Java 1.4.x is not slow.

      I've written only 100K+ lines of Java in the past 2 years, so I'm not an expert. But, I am an expert on high performance computing....and this analysis is very lame.

      The only thing this code tests is the java.lang.Math.* trig functions. It's the case that the Sun Math functions are jest links to StrictMath, which are very slow and very correct implementations of the relevant functions; implementations that will return the same values on any platform. The relevant routines use native code from a common math library.

      It is straight-forward to replace the java.lang.Math routines with much faster versions and you'll find that the java code runs much faster.

      There is little difference between the -server and the -client execution times....because the run time is dominated by the StrictMath routines.

      Finally, so many people have no clue about the compilers in the Sun JDK. Using
      java -XX:+PrintCompilation will show that the compilers convert the relevant functions to machine code very early in the run. The problem is that the trig functions are the limitter.

      One can be sure that all this code does in *any* language is measure the performance of the relevant math library that is being used. Look at the code: all it does is trig functions and sqrt()'s! This is not a benchmark that tests the actual code generators in the compilers.

      Finally, you're confirming that you don't have a very good understanding of recent changes in Java VM's. The 1.3.1 JVM isn't obsolete by any means. Sun is still releasing updates and bug fixes to it. The fact that you're using the very limited and strictly defined StrictMath implementation that was added in Java 1.4 to smear Java run times is just amazing. IBM's VM may well be superior to Sun's in general, but you've made it your default VM *only* because it has a better implementation of sin(), cos() and sqrt().

      You're drawing conclusions that simply are justified by the data you've presented.

    2. Re:Article Updated; My Comments on Your Comments! by toriver · · Score: 2
      The start-up time increases with the number of imports

      No it doesn't: import statements only affect compilation. Can you consult someone with some Java knowledge next time?

      How am I timing the results? With the Linux time command. Table 3 reports the real value reported by time (the elapsed time of execution.) Embedding timers in the actual code is fraught with problems; for example, each language implements different time scales and abilities. I'm sure someone will tell me that time is full of problems too, but it works for me and is consistent across all programming languages.

      Sure, but you end up measuring something else than execution speed of your code - thus it ends up as misleading for languages running in a virtual machine, like Java, Perl or Python. It becomes very misleading to call it a true benchmark.

      (It's a bit like measuring the average driving speed of two cars, where you in one instance measures one driver from when he opens the door and drives away, and another from when he gets dressed before going out to the car.)

      Timing only the loop itself, my findings puts JRE 1.4.1_01 on par with g++. (Caveat: System.currentTimeMillis() on Windows has an inaccuracy of between 10 and 20 ms.)

    3. Re:Article Updated; My Comments on Your Comments! by ChaoticCoyote · · Score: 2
      No it doesn't: import statements only affect compilation. Can you consult someone with some Java knowledge next time?

      Okay, to be very specific: "import" does, indeed, increase run time if it brings in classes used by the program. Interpretted Java loads packages dyanmically at run-time -- or didn't you know that? Of course, an import for an unused package has no overhead.

    4. Re:Article Updated; My Comments on Your Comments! by ChaoticCoyote · · Score: 2

      It is not valid to require that people rewrite parts of the run-time library in order to obtain effective speed. Run-time libraries are part of the product, just as much as code generators -- and if the library is slow, the product is slow. The best code generator in the world is of no avail if the runtime library is ineffective.

      I will be adding an accuracy benchmark in the near future, as well as test that do not invoke transcendental functions.

      I realize the trig functions are the limiter, and have said so since the benchmark was first released. That is one of the things I wanted to test, because the trig functions are intergral to the work I'm doing. I would be a fool to test without any trig functions, assume that Java is fast, and then have my app slow substantially when I apply real code. This is not an abstract benchmark like Whetstone; the code is actually trying to do something.

    5. Re:Article Updated; My Comments on Your Comments! by toriver · · Score: 2
      "import" does, indeed, increase run time if it brings in classes used by the program.

      No, because the class file only concerns itself with actual classes referenced in the code: Whether you use import or fully qualified class names in the source is irrelevant.

      Every class used from a class has its fully qualified name in the class file, whether the programmer used "import foo.*;" or not. Import statements are only relevant at compile time - if you meant to talk about class use why did you bring up import statements?

    6. Re:Article Updated; My Comments on Your Comments! by ChaoticCoyote · · Score: 2
      Import statements are only relevant at compile time - if you meant to talk about class use why did you bring up import statements?

      Because, my dear fellow, the import statement implies usage; there is no point in importing something you do not use, so the existence of an import indicates the need to load classes at run-time. You are correct that import, in and of itself, is moot in terms of run-time performance -- but the specification of an import implies (almost always correctly) that something is being loaded at run-time.

    7. Re:Article Updated; My Comments on Your Comments! by Anonymous Coward · · Score: 0

      No one said to rewrite the run-time libraries. However, if all you're doing it trig function then get a clue and use *faster* implementations.

      For example, libc has a function called sincos(), that returns the sin and cosine in one call. Yes, this will be 2 times faster than calling sin() and cos() for each input...which is what you're doing.

      Sheesh. You claim to be doing numerical work and you don't know about this sort of thing?

      Again, you've made conclusions that aren't justifed by your data.

      Java is slow? Wow, then how come the IBM JDK is only a bit slower than g++?!

      Oh, another point I forgot to make earlier: Sun hasn't cared too much in the past about the Linux/x86 JVM so it's a poor cousin compared to the Windows and Solaris code. You would expect IBM to have a better linux JVM since they're moving to linux for all their non-mainframe server systems and they sell a lot of x86 systems. Sun is getting much better now as they are also now selling linux/x86 servers.

    8. Re:Article Updated; My Comments on Your Comments! by toriver · · Score: 2
      Because, my dear fellow, the import statement implies usage;

      Only on part of the programmer; the compiler will try to resolve those classes, but there is no requirement for the code to use any names imported. Additionally, the lack of an import does not prevent usage.

      there is no point in importing something you do not use

      But it's both perfectly possible and legal even though it's pointless.

      but the specification of an import implies (almost always correctly) that something is being loaded at run-time.

      No, it only means that a name becomes available at compile-time. Runtime loading of classes depend on the class references in the compiled class file, which may or may not be related to import statements.

      import java.awt.*;
      public class test {
      }
      Compile this, and the resulting class file will not have any reference to java.awt in it.
      public class test2 {
      java.net.URL = null;
      }
      Compile that, and the class file will reference java.net.URL even though it has no import.

      "import" in Java is the same as "uses namespace" in C++. Nothing more, nothing less.

    9. Re:Article Updated; My Comments on Your Comments! by ChaoticCoyote · · Score: 2

      sincos() is not an ANSI/ISO Standard function. I am writing the applications to Standards for maximum portability; therefore, using sincos() is not an option.

      Heck, I could just drop some inline assembler code into the C program -- but then, I'd be benchmarking hand-tuned assembler language, not Standard C code.

  97. OT: please DON'T add signature divider! by Xtifr · · Score: 2

    PS: Please use a divider between your message and the signature. Less confusion that way.

    Bad suggestion, no biscuit! If you are easily confused (as, I confess, I am), then enable the "Signature Dash" option in your user preferences. (I believe this is the default.) Adding a manual divider to your signature just makes it look stupid to the people who have this option enabled. And people who don't have this option enabled have noone but themselves to blame for any confusion they may experience.

  98. Ugh. by ChaoticCoyote · · Score: 2

    Please don't harangue me about minor grammatical errors in the above; I'm tired, and pasted an old buffer (which I thought was a new buffer that I'd proofed. Damn these modern conveniences like cut-and-paste! ;}

    I'm going to watch Reign of Fire with my lovely wife now.

  99. g95 status by Anonymous Coward · · Score: 0

    ... is the parent's subject. I forgot to change it. My bad.

  100. Executable line noise by Julian+Morrison · · Score: 2

    I mean, take a look at this for example. Ouch. I mean, perl can be bad, C can get hairy, but sheesh. As far as hairy goes this is chewbacca overdosed on rogaine.

  101. Troll. by Anonymous Coward · · Score: 0

    Too obvious: mild personal insults to make the poster want to refute you, vague hand-waving or nebulous "problems," easily beat down arguments to create more of an attraction, trying to play in the "language zealot" nature of many people, etc...

    sorry.

  102. The problem quickly becomes worse by Jayson · · Score: 1

    I don't think anybody would argue that precedence rules would be bad if you only had to deal with the four major arithmetic operations. However, as soon as more operators are introduced the complexity quickly becomes not worth it. As proof look at what people do with C: they are encouraged to not even learn what the precedence levels (and associativity of each level) are and just use parenthesis.

    1. Re:The problem quickly becomes worse by t · · Score: 1
      I personally would love a gcc flag that disabled precedence rules altogether and instead required parenthesis. You on the other hand are saying that a right-left precendence is better than the mathematical rules.

      The secondary benefit of requiring parenthesis is that it gets ugly fast, forcing one to break the math up. This helps debugging weirdities like underflow/overflow which are not as obvious as division errors.

  103. What NASA Uses by ChaoticCoyote · · Score: 2

    The "technology testbed" probe, Deep Space 1, was programmed in Common LISP, I'm told. As I understand it, NASA engineers can (or could; I believe the probe is shut-down now) bring up a prompt and actively write/debug code while the probe was in space. Quite impressive; perhaps I need to brush-up on my LISP? ;)

    The Space Shuttle is programmed in Ada -- not terribly surprising given the origin of the shuttles in the late-70s, early 80s. Ada is a pretty good language, from what I know of it.

    NASA uses a lot of different tools and languages -- which proves that intelligent life exists on Earth. No one programming language is the ultimate tool, and people who cling to one language for all solutions are ignorant at best and foolish as worst.

  104. Some interesting results... by Glock27 · · Score: 2
    OK, I must admit I went into this with some preconceptions which I'm now re-evaluating. I think the author did a pretty good job, despite those inner-loop memory allocations and his timing methodology.

    My feeling about timing is that it is trivial to get the system time to less than a microsecond resolution on x86 systems, and the overhead of doing so is totally negligible in a reasonable benchmark, as long as it only happens a few times. I modified his Java benchmark to print out a little more information. I also followed some advice from the discussion on better compiler switches for gcj.

    Here are the results I got this morning:

    [glock27@rigel java]$ java -version
    java version "1.4.1_01"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
    Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
    [glock27@rigel java]$ javac *
    [glock27@rigel java]$ java almabench
    starting...
    elapsed ms: 3915
    elapsed ms: 3904
    elapsed ms: 3893
    elapsed ms: 3894
    elapsed ms: 3888
    elapsed ms: 3909
    elapsed ms: 3893
    elapsed ms: 3895
    elapsed ms: 3897
    elapsed ms: 3899
    elapsed ms: 3893
    elapsed ms: 3897
    elapsed ms: 3890
    elapsed ms: 3918
    elapsed ms: 3893
    elapsed ms: 3897
    elapsed ms: 3891
    elapsed ms: 3908
    elapsed ms: 3893
    elapsed ms: 3893
    total elapsed ms: 78509
    [glock27@rigel java]$ gcc --version
    gcc (GCC) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
    Copyright (C) 2002 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    [glock27@rigel java]$ make
    gcj -o almabench.o -march=athlon -mcpu=athlon -O3 -ffast-math -funroll-loops -fno-bounds-check -c almabench.java
    gcj --main=almabench -o almabench -march=athlon -mcpu=athlon -O3 -ffast-math -funroll-loops -fno-bounds-check almabench.o
    [glock27@rigel java]$ ./almabench
    starting...
    elapsed ms: 1227
    elapsed ms: 1202
    elapsed ms: 1209
    elapsed ms: 1206
    elapsed ms: 1209
    elapsed ms: 1211
    elapsed ms: 1207
    elapsed ms: 1211
    elapsed ms: 1219
    elapsed ms: 1204
    elapsed ms: 1212
    elapsed ms: 1207
    elapsed ms: 1205
    elapsed ms: 1215
    elapsed ms: 1207
    elapsed ms: 1212
    elapsed ms: 1205
    elapsed ms: 1207
    elapsed ms: 1207
    elapsed ms: 1206
    total elapsed ms: 24478

    GREAT showing for gcj...now 3.2 TIMES faster than Sun JDK 1.4!!! I'll post results for gcc with similar mods later.

    All times are on my completely stock Athlon 2100+ XP - which benched faster than his P4 2800 using JDK 1.4. Maybe he should check out AMD after all. ;-) My bench did not reflect startup time, but trust me it wasn't close to six seconds (more like less than one).

    This has really changed my thinking about gcj, although I'm also impressed with his Intel compiler times. I'll see if there is a free trial and see how the Intel code does on my Athlon. I've heard the generated code runs well on AMD systems also - I suppose unless SSE2 is used. ;-)

    --
    Galileo: "The Earth revolves around the Sun!"
    Score: -1 100% Flamebait
    1. Re:Some interesting results... by Glock27 · · Score: 2

      Well, I was going to post the main() method I modified, but Slashdot won't let me. :( It was two long variable instantiations, two calls to System.currentTimeMillis(), and two calls to System.out.println(). I bet you can guess where...

      --
      Galileo: "The Earth revolves around the Sun!"
      Score: -1 100% Flamebait
    2. Re:Some interesting results... by MikeBabcock · · Score: 2

      Thanks for the extra information (consider this a mod +1 informative). This was very helpful in deciding what I should choose for my own JAVA apps.

      The original article plus your benchmarking should be combined on the author's page, but aren't (yet). Hopefully it will be soon.

      --
      - Michael T. Babcock (Yes, I blog)
    3. Re:Some interesting results... by ChaoticCoyote · · Score: 2

      And if I use a language-specific timing loop, people will complain that the comparison is unfair. Timing routines are language-specific; C, for example, doesn't include a Standard function for obtaining time on the millisecond level. If the cross-language comparison is to have any meaning, the timing method must be consistent across all languages.

    4. Re:Some interesting results... by Glock27 · · Score: 2
      And if I use a language-specific timing loop,

      Not a 'timing loop' - 'time function'.

      people will complain that the comparison is unfair. Timing routines are language-specific; C, for example, doesn't include a Standard function for obtaining time on the millisecond level. If the cross-language comparison is to have any meaning, the timing method must be consistent across all languages.

      If the total runtime is (say) 25 seconds, and (say) 3 microseconds is taken doing time queries (I'm sure its less in our example), the overhead is way down in the 6th or 7th decimal - which you aren't even reporting and is meaningless anyway.

      There is a simple test for overhead...remove the time tracking (and I/O) from the inner loop and see if your outer loop timing changes. Bet it won't.

      Though I didn't discuss it in my post, I wanted to see the effect of further HotSpot optimization over time. As with other benchmarks I've seen, it tends to be negligible after the first couple of iterations.

      I think one of your problems is that you don't have a convenient hi-res timer function in C on Linux. I'll see if I can track one down that uses the appropriate Pentium instruction - it is a single assembler instruction to retrieve the high performance timer value. Resolution is under a microsecond.

      You could always go over the top and call the C function using JNI or whatever C language binding is available in your other languages of interest. Really, though, I think System.currentTimeMillis() should be sufficient in Java.

      Don't lose track of my results over this issue though. gcj performed MUCH better in my benchmarking - please attempt to at least duplicate the compiler switches and run again. Thanks!

      --
      Galileo: "The Earth revolves around the Sun!"
      Score: -1 100% Flamebait
  105. You're welcome by kfg · · Score: 2

    But you've just made Linux Today, so I'm afraid the assault isn't over yet. :)

    KFG

  106. some more info for you by Jayson · · Score: 1
    (the ascii-line-noise example also illustrates this - because all those symbols are already overloaded with lots of meanings)
    The overloaded nature of the symbols in K has been discussed on the list, actually. The next version of K that has been "imminent" for at least 6 months now, as I am understand it, will remove that. No more overloaded operators. Another major change will be that the syntax processing will be lifted into the language and mutliple overlays will be possible. Two of the provided ones will be the current symbolic nature and another that uses english words.
    Maybe it was made for people who simply aren't exactly like you. People are different. Some people may even like the fact that APL-like languages make it easy to use vectorised operations. They may come from VB and realise how much error-prone make-work all those loops were, and PREFER K.
    I started off as a big Lisp/Scheme fan. When I first saw K (my roommate showed it to me) I laughed and couldn't understand wanting to use it, so I can understand other people's reluctance. After digging into the language for about 2 weeks, though, I was hooked. I now use K for 80% of my work and C for most of the rest (thankfully, there is a simple K-C interface).
    1. Re:some more info for you by DGolden · · Score: 1

      Well, I stayed a big Common Lisp* fan - one idea I've been toying with (i.e. I'll probably never actually do it and even if I started I'd probably never finish) is an APL-syntax parser for Common Lisp arrays, so one could write (apl-eval "...") and have it transform the APL in "..." into CL functions operating on arrays. And with CL, one could easily implement even the fancy stuff like function composition.

      Would be quite cool, because one could then mix Maxima symbolic math stuff, APL numeric math stuff and Lisp... stuff... in the one program.

      There's a paper which shows that a good CL compiler can be competitive with a fortran compiler for numerical processing.

      * Beware that Scheme is rather different in many ways to Common Lisp - if you've investigated Scheme but decided it wasn't for you, but haven't investigated Common Lisp, then I suggest having a look at it.

      --
      Choice of masters is not freedom.
  107. It's not the OO, it's the optimisation by Anonymous+Brave+Guy · · Score: 2
    I would guess that the C++ code did just as well as the fortran code because it didn't use many object-oriented features.

    There's little that's inherently slow in using OO. Yes, you can have virtual function look-ups giving you an extra level of indirection, but to achieve the same result without OO, you'd just need some other (similarly time-consuming) technique. OO formalises stuff that people do anyway, it doesn't automatically generate new overheads.

    A far more likely explanation is that C++ compilers now optimise better than they used to. Comparing native C and C++ procedural code, you should see identical performance, yet C-only compilers have always produced executables that outperformed C++ ones because they've had that much more experience optimising within the framework C creates. As the C++ compiler industry matures, better optimisations are being developed all the time, and the gap is closing as you would expect.

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  108. Updated gcj numbers and timing issues by ChaoticCoyote · · Score: 2

    I've once again updated Linux Number Crunching article based on questions asked and suggestions made by readers. New options help GNU gcj produce code that is faster than the VM-based JDKs. I've also added an explanation of why Java became slower with its 1.4 release, and show that JVM initialization does not significantly affect test times.

    I appreciate the comments and bits of information I've received from readers. Onward to accuracy!

  109. Pointless benchmarks by gss · · Score: 1
    The main reason we have so many different languages is that you pick the right tool for the job. Obviously there is no one perfect language for every job. So maybe this little test of yours is usefull for some people but I certainly hope people don't use your results to pick a tool for general purpose development. Like you said in one of your posts if you really want performance write everything in assembly.

    There are way more important factors to consider when writting code, development time, maintainablity, code reuse, etc. Which is why nobody in their right mind would write an application in assembly anymore.