Re: C, MathLink or Java, J/Link
- To: mathgroup at smc.vnet.net
- Subject: [mg28181] Re: C, MathLink or Java, J/Link
- From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
- Date: Tue, 3 Apr 2001 02:37:59 -0400 (EDT)
- Organization: Universitaet Leipzig
- References: <99usl9$61j@smc.vnet.net> <9a1jfh$9o8@smc.vnet.net> <9a6dps$eo2@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Todd, yes your J/Link *is* great. It is one of the best perls of software that I have seen! And the best thing on it, that you can use Java without programming in Java. I have two questions to the benchmark, you gave. What C-compiler ? On Intel boxes Intel 4.5 is usual 20-30 % faster than Microsoft's Visual C. Even the code generated by Borland C 5.5 is better that Mircosoft's. And how does Mathematica with the code ? using all the optimizations that Mathematica can do ? How fast is Mathematica itself with the benchmark ? > Are these results typical of numerical programs of the sort Mathematica programmers are > likely to be writing? I would say yes. I usually expect a Java program to run in a range > comparable to C down to perhaps 1/2 to 1/3 as fast. Hoops ! you mean a C program on a 1.4 GHz PC is as fast as a Java program on a 2.8 or 4.2 GHz PC ... So where to buy the 4.2 GHz PC ?? If this *is* not slow, what else mean "slow" ? For me it make a difference if I have to wait one hour or three. I have seen people that work hard for 5 % performance gain. > > As always, "Your mileage may vary". Nevertheless, people should not rule out Java in > advance as a language for virtually any kind of program based on the (mostly erroneous) > assumption that it is "too slow". I agree with you that in many cases speed is a so critical point. Since the computer spend the most time while waiting onto a mouse click or a keyboard character. So for those cases Java is a lot easyer than C or C++. But you should keep in mind what happens with an application. If the code is fast, one find always a task that can be done also. Every program is extended until the program hit the limits of the computer. > > As for the original question, about whether to use Java or C for an algorithm to be called > from Mathematica, the answer is of course "it depends". Some factors that favor C are: > > - you already are proficient in C > - you just have one function to call and you don't need to have a > complicated interaction with Mathematica > - you don't need to port your program to other platforms > - flat-out performance is overwhelmingly important > The easy usage for complicated interaction with Mathematica is your merit. And it is up to every C-programmer to do similar stuff in C/C++. Your Java/C source is about 500 kByte. This is the real advantage of Java -- that you have done a lot of work on it. But how much of this Java code is used by a typical MathLink application ? The most MathLink programms are written for speed. I expect the advantage of Java in writing custom portable user interfaces for all those people that need more than some buttons and in this case speed is not critical and one has the Java librarys. I think "portability" is not more a serious problem of a C program. MathLink is wonderful portable and one finds for almost every thing a portable library. Regards Jens