Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming IT Technology

Performance Benchmarks of Nine Languages 954

ikewillis writes "OSnews compares the relative performance of nine languages and variants on Windows: Java 1.3.1, Java 1.4.2, C compiled with gcc 3.3.1, Python 2.3.2, Python compiled with Psyco 1.1.1, Visual Basic, Visual C#, Visual C++, and Visual J#. His conclusion was that Visual C++ was the winner, but in most of the benchmarks Java 1.4 performed on par with native code, even surpassing gcc 3.3.1's performance. I conducted my own tests pitting Java 1.4 against gcc 3.3 and icc 8.0 using his benchmark code, and found Java to perform significantly worse than C on Linux/Athlon."
This discussion has been archived. No new comments can be posted.

Performance Benchmarks of Nine Languages

Comments Filter:
  • Re:Trig functions... (Score:4, Informative)

    by tealwarrior ( 534667 ) on Friday January 09, 2004 @11:41AM (#7928309)
    What is interesting in these functions is that, as pointed in the article, there seems to be something wrong with Sun's implementation for Java.

    For many math functions java uses a software implementation rather than using the built in hardware functions on the processer. This is to ensure that these function perform exactly the same on different architectures. This probably accounts for the difference in performance.
  • by manifest37 ( 632701 ) on Friday January 09, 2004 @11:43AM (#7928352)
    code [cowell-shah.com]
  • by SiW ( 10570 ) on Friday January 09, 2004 @11:44AM (#7928362) Homepage
    Don't forget about the Win32 Compiler Shootout [dada.perl.it]
  • by Mathetes ( 132911 ) on Friday January 09, 2004 @11:47AM (#7928399)

    Oh wait! C# only runs on one operating system. Can you name any other development languages that only run on ONE OS, boys and girls? Neither can I.


    Ximian's Mono has a C# compiler for open OS's:

    http://www.go-mono.com/c-sharp.html
  • Re:Trig functions... (Score:3, Informative)

    by be-fan ( 61476 ) on Friday January 09, 2004 @11:48AM (#7928407)
    Its not proof of anything. Its just proof that the JIT manages to handle JIT-ing properly. All of these were simple loops where the JIT could do its work and get out of the way for the rest of the program. They are not indicative of real-world performance, unless all you are doing are such loops.

  • Re:Trig functions... (Score:2, Informative)

    by techiemac ( 118313 ) <techiemac AT yahoo DOT com> on Friday January 09, 2004 @11:48AM (#7928410)
    One issue with Java is it all depends on the Virtual Machine.
    I, for one, would _never_ trust Java in a mission critical embedded environment. In fact you still see assembly in those envrionments from time to time. Imagine using Java for a fly by wire system. Would you fly on a plane that was using Java for fly by wire? I, for one, would not.
    Java is great for some things. But you get too many cases where companies use a new technology without adequate due diligence simply because its the NTOW (New Technology Of the Week). I still say that a server written in C (written properly of course) will outperform a server written in Java.
  • by enkafan ( 604078 ) on Friday January 09, 2004 @11:48AM (#7928411)
    Because the guy who wrote the code decided to use the VB6 compatability features instead of the .NET runtime for VB. Why one would do this, I have no idea.
  • Re:Trig functions... (Score:5, Informative)

    by csnydermvpsoft ( 596111 ) on Friday January 09, 2004 @11:50AM (#7928454)
    If more people would use the SWT libraries (part of the Eclipse project) instead of the crappy AWT/Swing libraries, then this misconception would go away. SWT works by mapping everything to native OS widgets if possible, giving it the look, feel, and speed of a native app. I used Eclipse for quite a while before finding out that it is almost 100% pure Java (other than the JNI code necessary for the native calls).
  • by Jugalator ( 259273 ) on Friday January 09, 2004 @11:50AM (#7928456) Journal
    Site was showing signs of Slashdotting, so I'll quote one of the more important sections...

    Results

    Here are the benchmark results presented in both table and graph form. The Python and Python/Psyco results are excluded from the graph since the large numbers throw off the graph's scale and render the other results illegible. All scores are given in seconds; lower is better.

    int long double trig I/O TOTAL

    Visual C++ 9.6 18.8 6.4 3.5 10.5 48.8
    Visual C# 9.7 23.9 17.7 4.1 9.9 65.3
    gcc C 9.8 28.8 9.5 14.9 10.0 73.0
    Visual Basic 9.8 23.7 17.7 4.1 30.7 85.9
    Visual J# 9.6 23.9 17.5 4.2 35.1 90.4
    Java 1.3.1 14.5 29.6 19.0 22.1 12.3 97.6
    Java 1.4.2 9.3 20.2 6.5 57.1 10.1 103.1
    Python/Psyco 29.7 615.4 100.4 13.1 10.5 769.1
    Python 322.4 891.9 405.7 47.1 11.9 1679.0
  • Re:Wow (Score:2, Informative)

    by Daniel Boisvert ( 143499 ) on Friday January 09, 2004 @11:51AM (#7928468)
    I found it interesting to note in the benchmark design that the Visual C++ compile used the "omit frame pointer" option, while gcc did not. It seems to be the consensus over at the Gentoo Forums that this flag makes a fairly noticable difference (if negatively impacting debug options), and I'd like to see the C piece re-run using this option. It's tough enough to compare apples to apples in tests such as these, but at least try to use the same compile flags where available..

    Dan
  • Re:Under Windows... (Score:3, Informative)

    by mindriot ( 96208 ) on Friday January 09, 2004 @11:52AM (#7928477)
    The article was actually written by Christopher W. Cowell-Shah. Also, as others noted, except for the I/O benchmark (where gcc was actually faster) the benchmarks couldn't profit much from the OS around it since they were just computationally intensive, but didn't make much use of OS-specific library functions.
  • Re:Wow (Score:2, Informative)

    by jrexilius ( 520067 ) on Friday January 09, 2004 @11:54AM (#7928518) Homepage
    I would say yes, If you are coding just for WinTel platforms I would use MS tools and/or the Intel compiler. If you are coding only for SPARC/solaris, use their compiler.

    GCC, like apache, is meant to be correct and portable first, fast second. Despite this, I wouldn't say thats its performance sucks, I would say that it is the fastest cross-platform option available. (as compared to Java the only other cross platform non-interpreted language in the test group).
  • by PommeFritz ( 70221 ) on Friday January 09, 2004 @11:56AM (#7928536) Homepage
    The Python 'long' type is not a machine type such as a 32 or 64 or perhaps even 128 bit integer/long.
    It is an arbitrary precision decimal type! That's why Python's scores on the Long test are so much higher (slower) than the other languages.
    I wonder what Java scores when the benchmark is reimplemented using BigDecimal instead of the 'long' machine type.
    Python uses a highly efficient Karatsuba multiplication algorithm for its longs (although that only starts to kick in with very big numbers).
  • Re:Trig functions... (Score:3, Informative)

    by CommandNotFound ( 571326 ) on Friday January 09, 2004 @12:04PM (#7928659)
    Since you have 1.4.2 installed, try running the Java2D demo in $JAVA_HOME/demo/jfc/Java2D. The graphics are quite fast on a local machine, largely because (as you said) it uses back buffering to blast the pixels onto the screen. Unfortunately, this is horrible for remote X displays, but I found a workaround. Launch your java app with the option -Dsun.java2d.pmoffscreen=false, and this will disable the backbuffer and tremendously speed up remote X operation, at the expense of some flicker. On my remote machine, I renamed java to java.bin and created a wrapper script named java that always uses this option with the single line:

    exec $JAVA_HOME/bin/java.bin -Dsun.java2d.pmoffscreen=false $*

    That way any plugins or Web Start apps also get this treatment. Just make sure you also change the JRE copy of java, too.
  • Re:Under Windows... (Score:1, Informative)

    by Anonymous Coward on Friday January 09, 2004 @12:07PM (#7928698)
    py-Numeric should be used to do calculations in Python.
  • trig calls in gcc (Score:5, Informative)

    by ajagci ( 737734 ) on Friday January 09, 2004 @12:11PM (#7928746)
    The Pentium trig instructions are not IEEE compliant (they don't return the correct values for large magnitude arguments). gcc errs on the side of caution and generates slow, software-based wrappers that correct for the limitations of the Pentium instructions by default. Other compilers (e.g., Intel and probably Microsoft) just generate the in-line instructions with no correction. When you look at the claimed superiority of other compilers over gcc, it is usually such tradeoffs that make gcc appear slower.

    You can enable inline trig functions in gcc as well, either with a command line flag, or an include file, or by using "asm" statements on a case-by-case basis. Check the documentation. With those enabled, gcc keeps up well with other compilers on trig functions.
  • Re:Under Windows... (Score:2, Informative)

    by haystor ( 102186 ) on Friday January 09, 2004 @12:20PM (#7928865)
    There a tons of things where Python is plenty fast. I'm writing something in Python right now. All it has to do is read a line that I type, parse it, work with the db and prompt me for another line. Well over 99% of the time is spent waiting on me to type a line.

    Python waits for input just as fast as all the other languages.

    Development and benchmarking of 1 million human typed lines is left as an exercise for the reader.

    Oh, and my parsing recognizes verbs, nouns, objects and pronouns. All of this is easily optimized to run fast enough in Python. I'm sure it could eventually be made faster in C but I won't even explore that.
  • Re:Trig functions... (Score:4, Informative)

    by happyfrogcow ( 708359 ) on Friday January 09, 2004 @12:22PM (#7928881)
    SWT works by mapping everything to native OS widgets if possible

    Isn't that what AWT tried to do originally? I'm just delving into Java for the first time the last few months, but I thought I've read this in "Core Java, Vol. 1"

    They say (pg. 236 "Core Java, Vol. 1) that this resulted in a "write once, debug everywhere" problem since you will have different behavior, different limitations and different bugs on each implementation of AWT on each platform
  • by pr0c ( 604875 ) * on Friday January 09, 2004 @12:25PM (#7928925)
    VB.net compiles into the same thing as c#, it SHOULD have benchmarked the exact same and so there would have been no point.
  • Re:Trig functions... (Score:3, Informative)

    by ChannelX ( 89676 ) on Friday January 09, 2004 @12:28PM (#7928972) Homepage
    I'm getting really tired of hearing this comment. First off SWT isn't anywhere near Swing in the functionality department. Not even close. Is it faster? Yes in *some* cases. In the cases where there isn't a native OS widget then it emulates the widget and you're then in the same area as Swing yet with a crappy API to boot. No thanks. Secondly, Swing is not slow if programming properly. I suggest looking at the interfaces of IntelliJ IDEA, the tools from JGoodies (http://www.jgoodies.com), or JEdit to see what is possible with a Swing UI that is programmed properly.

    By calling Swing a crappy library you show that you really haven't used it all that much if at all and are just puking tired, second-hand information.
  • by LnxAddct ( 679316 ) <sgk25@drexel.edu> on Friday January 09, 2004 @12:29PM (#7928980)
    Thank you! I was just about to point this out. Python will handle integers of any length which can really come in handy. None of that puny 64 bit or 128 bit stuff. You can easily work with 10,000 bit integers and higher, I do all the time. There are a few other features of python like this, so its not really fair to compare unless you are using similar functions in the other languages. I for one find this arbitrary precision indespensable.[For those who don't use python or don't code, this simply means that you can pass python any number no matter how big (limited only by your hardware) and it will handle it with no complaints and do whatever you want with it]
    Regards,
    Steve
  • by enkafan ( 604078 ) on Friday January 09, 2004 @12:34PM (#7929048)
    Assuming they wrote the same code, it would compile into the same IL. If you would have looked at the IO code in question, you'd notice this:

    C#

    StreamWriter streamWriter = new StreamWriter(fileName);
    while (i++ ioMax)
    {
    streamWriter.WriteLine(textLine);
    }
    streamWriter .Close();

    VB.NET
    FileOpen(1, fileName, Microsoft.VisualBasic.OpenMode.Output)
    Do While (i ioMax)
    PrintLine(1, myString)
    i += 1
    Loop
    FileClose(1)

    Totally different routines, totally different IL, totally different performance. If he'd had simply stuck to the .NET framework for the VB stuff, then they get the same IL.
  • Re:Trig functions... (Score:3, Informative)

    by maraist ( 68387 ) * <michael.maraistN ... m ['AMg' in gap]> on Friday January 09, 2004 @12:38PM (#7929094) Homepage
    Just to elaborate.. The main advantage of NIO is when you anticipate an arbitrary number of threads..

    Conversely, when you have a finite number, 1-thread-per-stream asynchronous IO is VERY desirable; both in coding, and in some small ways even in efficiency (immeidate responses; limited only by context switching time).. In contrast, IO-multiplexing may have certain tasks take long periods of time (stalling other channels).. Then you have to manually keep track of such situations as you code and push them off to worker threads in certain types of problems.

    But there is simply no substitute when you want thousands of simultaneous idle connections (such as message servers) for IO-MUX.

    Not that it's better, just solves a particular solution.
  • by dnoyeb ( 547705 ) on Friday January 09, 2004 @12:41PM (#7929139) Homepage Journal
    Third, Java 1.4.2 performed as well as or better than the fully compiled gcc C benchmark, after discounting the odd trigonometry performance. I found this to be the most surprising result of these tests, since it only seems logical that running bytecode within a JVM would introduce some sort of performance penalty relative to native machine code. But for reasons unclear to me, this seems not to be true for these tests.

    I dont know why the reasons are not clear to him. Perhaps its because he still thinks the JVM is "running bytecode" and does not understand what JITs did or what HotSpot compilers do. Byte code is only run the first few passes, after which its optimized into native code. Native being whatever the compiler of the c program used to compile the JVM could do. This is fundamental. Which explains his results, and points to a poor HotSpot implementation where trig functions are concerned.
  • Re:Trig functions... (Score:4, Informative)

    by Darren Winsper ( 136155 ) on Friday January 09, 2004 @12:51PM (#7929243)
    Actually, I'm going to complain because you are completely wrong. Sun complained about Microsoft changing the language in a way that was incompatible with everybody else's implementation.
  • Re:Trig functions... (Score:2, Informative)

    by nikster ( 462799 ) on Friday January 09, 2004 @01:12PM (#7929533) Homepage
    Then you have not seen my Java apps. Everything i made in the last 12 months or so has been indistinguishable from native interfaces... I have been doing client app programming for the last 6 years. Java has come a long way since then. Sometime in 2002, the Java GUI was not slow anymore.

    The factors:

    1 - fast-enough machines (response time 1/10 second is not noticable - no one cares if that is 10x slower than native at that point. you can't see it.)
    2 - Improvements to Swing. 1.4 is the first version of Swing which has hardware acceleration built-in, thereby putting it on par with native win apps (native apps would be terribly slow without HWaccel, too - just turn it off in your graphics card settings to see how)
    3 - and, to a certain extent, enough memory in machines. Java is a memory hog (even a small client app uses 20M...). But that doesn't matter if your machine has 256M.

    You can say Swing is still overkill and over-engineered, and the AWT is no beauty, either. All true. Only, at this point, it doesn't matter. The "perceived suggishness"-barrier has been passed and left behind for good.

    If your Java GUI is sluggish in 2004, you have only yourself to blame.
  • by DavidNWelton ( 142216 ) on Friday January 09, 2004 @01:12PM (#7929539) Homepage
    We weren't quite ready to release it, but we've been working on a language performance comparison test of our own. It is available at:

    http://scutigena.sourceforge.net/ [sourceforge.net]

    It's designed as a framework that ought to run cross-platform, so you can run it yourself. We haven't added it yet, but I think we really want to divide the tests into two categories. "Get it done" - and each language implements it the best way for that language, and "Basic features comparison" - where each language has to show off features like lists, hash tables, how fast function calls are, and so forth.

    It's an ongoing project, so new participants are welcome! I would appreciate it if comments went to the appropriate SF mailing lists instead of here, so that I can better keep track of them.
  • Re:Trig functions... (Score:5, Informative)

    by Abcd1234 ( 188840 ) on Friday January 09, 2004 @01:14PM (#7929579) Homepage
    Sorry, dude, but SWT is nowhere *near* as complete as Swing, in terms of functionality. I know, I've tried to use it. Basically, because SWT was designed more or less specifically with Eclipse in mind, it has massive gaps in it's APIs (for example, the imaging model is *severely* lacking). Worse, it's difficult to deploy, and even more difficult to use, as the documentation is remarkably incomplete. So, as much as I hate to say it, SWT simply can't replace Swing right now, and I don't expect it to any time soon.
  • Re:Trig functions... (Score:5, Informative)

    by William Tanksley ( 1752 ) on Friday January 09, 2004 @01:23PM (#7929701)
    Enumorators? Reflection?

    I'm only a beginner in C# and Java, but I know both have reflection, and the proposed Java 1.5 has enums. Kudos to C# for having them first :-), but Java 1.5 has them better, as first-class objects.

    Also .net/IIS is a better platform for webdevelopment.

    Better for whom? Why? Doesn't it have the severe shortcoming of platform lockdown?

    I can write a c#.net app in 1/4th the code of a java one. Go take a look at Microsoft's petshop program if you do not believe me.

    I can write an assembly app in 1/4 the code of a Python one. Assuming, of course, that the Python app wasn't written for small code size... The simile is very accurate; Sun didn't write their petshop for small size.

    The Java Petshop reimplementation here [prevayler.org] spanks both Sun's and Microsoft's petshop in terms of size, and pretty clearly demonstrates that both languages could do better.

    BTW, I absolutely love C# -- from what I've done with it so far. My only complaint is that its support is at best halfhearted for other platforms, and I will not allow my work to be tied down to one platform. This is the only thing that kept me from learning K (well, K is portable, the only problem is that it's only available from one vendor, Kx systems). Anyhow, I think C#'s bytecode is far beyond anything Sun's ever going to do with Java.

    ALso WIndows2k3 is as stable as Linux now. NT4 is old. The situation has improved dramatically. I have never even seen a blue screen on windows2k yet!

    I agree with all of that, but it's not enough. I have seen blue screens and system crashes on 2000 and XP (XP far, FAR FAR more often than 2000). But then I've seen system crashes on Linux, so I'm not just complaining about MS ;-).

    -Billy
  • Re:Trig functions... (Score:2, Informative)

    by Antity-H ( 535635 ) on Friday January 09, 2004 @01:30PM (#7929801) Homepage
    Nope, as the parent poster says, SWT uses the system widget. These are pretty high level calls such as : drawx a combobox with such and such properties at this position in reference to this frame.
    AWT/SWT only uses low level calls (probably as low as : draw this pixel at x,y with this color) and recreates all the widgets "from scratch". And if you ever have the time, go download the source code of java on sun's website (there is a community edition to download for free ) and take a look at the implementation of swings components, no wonder they are sluggish. I won't even get started on the focus management of swing which is "weird" to say the least.
  • by Jerf ( 17166 ) on Friday January 09, 2004 @01:34PM (#7929873) Journal
    The list of benefits coming from using Java is too long to take the speed-only view seriously.

    The problem there is if you start taking a truly open look around, Java stops looking so cool either.

    Its single greatest feature that might justifiably be called unique is the fact that it has a lot of library support you can buy, and if those things help enough they might tip the balance.

    But in every other way, there's a language that meets or beats Java on almost every level.

    To prevent this from becoming too confrontational, I won't try to name the languages. But Java really isn't the king the pro-Java zealots like to pretend it is; it's just the current Big Kahuna in certain domains, just like C++.
  • by BreadMan ( 178060 ) on Friday January 09, 2004 @01:39PM (#7929944)
    Compiled with gcj Benchmark.java --main=Benchmark -o benchmark, compiled other program with the same optimization level.

    Comparison against gcc, gcj and Java 1.4.1 on the same host:
    .......... gcc........gcj.......java
    int.......28,700.....35 ,386....22,953
    double....30,000.....73,504....27, 529
    long......61,520.....61,729....68,914
    trig.. ....11,020....112,497...176,354
    io.........1,930. ....16,533....11,297
    I was somwhat surprised on the difference in the trig tests, as both appear to use libm. Not surprised that the IO was slower, the Java IO classes are nifty but do add quite a bit of overhead compared fputs/fgets.

    (Sorry about the formatting, it was the best I could do)
  • Python Benchmark (Score:4, Informative)

    by SlightOverdose ( 689181 ) on Friday January 09, 2004 @01:40PM (#7929966)
    The windows version of Python is much slower. Testing with Python2.3 + psyco on a 2.4ghz p4 running Linux 2.4.20 yeilds impressive results

    $ python -O Benchmark.py
    Int arithmetic elapsed time: 13700.0 ms with
    Trig elapsed time: 8160.0 ms

    $ java Benchmark
    Int arithmetic elapsed time: 13775 ms

    $ java -server Benchmark
    Int arithmetic elapsed time: 9807 ms

    (n.b. this is only a small subset of the tests- I didn't feel like waiting. Trig was not run for java because it took forever.)

    To dismiss a few common myths...
    1) Python IS compiled to bytecode on it's first run. The bytecode is stored on the filesystem in $PROGNAME.pyc.

    2) the -O flag enables runtime optimization, not just faster loading time. On average you get a 10-20% speed boost.

    3) Python is a string and list manipulation language, not a math language. It does so significantly faster than your average C coder could do so, with a hell of a lot less effort.
  • by James Thompson ( 12208 ) on Friday January 09, 2004 @01:57PM (#7930187)
    You could also use pyrex [canterbury.ac.nz] and save yourself the troubles of dealing with the Python/C API.
  • Re:Trig functions... (Score:4, Informative)

    by Pieroxy ( 222434 ) on Friday January 09, 2004 @02:03PM (#7930277) Homepage
    You are so wrong, that it is a shame you posted this one!

    AWT has native widgets: Combo box, menu, button, text area, input box, checkbox, etc... Not only primitives.

    What you are describing is Swing, not AWT.

    Swing relies on the most basic AWT features: Component/Container and drawImage, and re-implement the whole widget sets in Java, relying on these two AWT components.
  • by Frobnicator ( 565869 ) on Friday January 09, 2004 @02:09PM (#7930350) Journal
    There never has, nor will there ever be, an all encompasing benchmark. ... Thin[k] of all of the parms which go into application performance. ... Think of the amount of impact the coder makes. ... How about compiling & linking flags?

    Not only that, but it helps to have a benchmark that actually tests the things that are claimed at being tested.

    It's a Good Thing (tm) this didn't make the front page.

    The author states "I am by no means an expert in benchmarking; I launched this project largely as a learning experience" and it shows. The man has an associates degree in computer science, and a Ph.D. in psychology. His list of publications [berkeley.edu] are his dissertation, a single published paper, and excerpts within a 15-year-old travel guide.

    Just a cursory glance at the first page of his article shows that he has no clue as to how things work. He states "I first tried to eliminate the CLR from the Visual C++ benchmark by turning off the language's "managed" features with the #pragma unmanaged directive, but I was surprised to see that this didn't lead to any performance gains." If he cannot understand why something that generates a few thousand CPU instructions of initial overhead doesn't change the speed of an I/O- and loop limited program, he isn't skilled enough to interpret his own results.

    His benchmarks never actually test his first, second, third, or fifth question. His fourth question is actually addressed better when his contrived test is compared on relative measure with his two Java tests.

    Look at his benchmark programs (found here [berkeley.edu]). Some of those test can, should, and will have compiler-specific optimizations, having nothing to do with the language. General 'counting loops', which is the only thing he is using, have long been known to produce bad benchmarks. He claims to be testing 64-bit floating point math, but in fact, many of his examples use 80-bit floating point.

    Just for fun, look at his VC and Java 1.4 floating point tests. Now look at his compiler options. It is painfully obvious that the compiler saw "He explicitly said this is a Pentium 4, I can use parallel floating point instructions!" where the other compilers could not. Saying that those languages are inherently faster than the other compiled languages is lunacy.

    This is hardly news. This is a BAD example of benchmarking, and would be given a poor grade in a graduate level CS class.

  • by Anonymous Brave Guy ( 457657 ) on Friday January 09, 2004 @02:31PM (#7930619)
    For many math functions java uses a software implementation rather than using the built in hardware functions on the processer.

    That would explain a lot then.

    Any recent version of Visual C++ supports "intrinsics", i.e., conversions of a function call directly into a specific machine code instruction, or "perfect in-lining" if you prefer.

    That means that if you use something like abs(x) in C++, these compilers would convert directly into an instruction to get x to the head of the floating point stack, then a FPU abs opcode, with no overheads at all. Same goes for trig functions and other variations supported by the FPU.

    Moreover, IME the VC++ optimiser is quite smart about intrinsics, and in lengthy calculations will often arrange for the right values to be coming to the head of the stack in the correct order as cheaply as possible, even if it means planning ahead a few instructions. If you look at the assembly language output from VC++ for a numerical computation, it tends to have a series of instructions to stack what it needs, with the occasional calculation opcode thrown in between them, and then a whole series of neatly co-ordinated calculation opcodes at the end.

    I don't see how any language that has function calling at all could keep up with this low-level, direct-to-FPU approach, and surely any language using software emulation of floating point code won't even come close.

    I don't know whether VC# and VB.Net use the same trick, but given how much effort MS put into sharing things across the product range prior to releasing VS.Net, it must be a good bet. There are some advantages to writing platform-specific code. :-)

  • by milsim ( 739431 ) on Friday January 09, 2004 @02:44PM (#7930779)
    A few posts mention that .NET is for Windows only. That's completely untrue. .NET executables can be run on Linux, FreeBSD, MacOS X, maybe even other platforms in near future. .NET Runtimes: Mono - http://go-mono.com - C# and VB DotGNU - http://dotgnu.org - C# For Windows, the Microsoft's .NET Framework is the winner, being almost twice as fast as Mono, with DotGNU being the slowest, but I've only done synthetic SciMark2 benchmarks. (Also don't forget you can compile Java to .NET assembly :)
  • Re:Trig functions... (Score:4, Informative)

    by Skjellifetti ( 561341 ) on Friday January 09, 2004 @02:59PM (#7930943) Journal
    I seem to recall that if the platform doesn't have a widget that SWT needs, it uses its own implementation.

    Or just doesn't bother implementing it at all. Try printing from eclipse on Linux.
  • Wha? (Score:3, Informative)

    by autopr0n ( 534291 ) on Friday January 09, 2004 @03:01PM (#7930967) Homepage Journal
    You are completely wrong. Java programs are taken and converted into machine code on the target platform. Saying that it's "the same as 'C' code" because the JVM is written in C is like saying that if I were to write a C++ compiler in Python, running the resulting binaries would be the same as running Python code.

    In other words, idiotc.
  • Re:Trig functions... (Score:1, Informative)

    by Anonymous Coward on Friday January 09, 2004 @04:06PM (#7931795)
    First, I am not impressed that Java is faster for some benchmarks. Note: That it uses a JIT-compiler and the JIT-compiler has runtime information. Static compiler as gcc cannot take advantage of runtime info. So with a good JIT-compiler and for benchmarks that runs for some time Java programs can be faster that natively compiled code provided that the JIT can remove most array bound checks.

    Trigonometric functions are not part of the Java language but they are the Java library.

    I think it is slow for the trig functions because of the overhead to call the native OS trig function (switch from Java to native).

    They are probably implemented something as this in class Math:
    public native double cos(double v);
    and the native funcion is:
    jdouble Java_lang_Math_cos(jdouble v) {
    return cos(v);
    }
    The switch from Java to native code involves some overhead. For I/O it does not matter much, I/O is already slow. But if you have trig function in a tight loop, then you have quite some overhead unless the JIT is smart enough to handle special cases and inline directly the cos(v) native code.

  • Re:Trig functions... (Score:3, Informative)

    by be-fan ( 61476 ) on Friday January 09, 2004 @04:38PM (#7932317)
    I don't think Java or C# do this, but more advanced GC'ed languages (Lisp/ML) have advanced compiler algorithms that will stack-allocate any objects they can.

    Its actually a pretty easy optimization: if a reference to a an object doesn't escape the current scope (which they can determine they usually analyze all or most of a program at the same time) then it can stack allocate the object.
  • Re:Trig functions... (Score:2, Informative)

    by cylab ( 217151 ) on Friday January 09, 2004 @08:58PM (#7934741)
    And I refuse to use any IDE (like Netbeans) that uses Swing.

    sorry to say, but this is ignorant. eclipse is a great app and netbeans might have a sluggish gui, but i would not ditch an application because of its toolkit...

    a great example for a good swing-app is intellij idea [intellij.com] and its a hell of an IDE (IMHO the _very_ best java-IDE _by far_) use it one day and you never want to go back to any other java IDE. its pure swing, looks good, feels good and is fast and responsive!

    yes, its commercial, but thats not the point in this discussion (but you can get a trial-licence, so i'd suggest to try it)

  • by Anonymous Brave Guy ( 457657 ) on Friday January 09, 2004 @10:53PM (#7935297)

    I agree with 2/3 of your replies, but you need to look up the difference between C++ destructors and Java's finalize(). Hint: one is useful, the other usually isn't. :-)

"Ninety percent of baseball is half mental." -- Yogi Berra

Working...