MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: c code generation

  • To: mathgroup at
  • Subject: [mg4474] Re: [mg4362] Re: c code generation
  • From: Mark Evans <evans at>
  • Date: Mon, 29 Jul 1996 02:37:26 -0400
  • Sender: owner-wri-mathgroup at


Your reply is a little off-base; we don't really have an argument.  You 
shouldn't try so hard to dismantle every point in a reply, especially out of 
context.  There is an old joke about the Bible that runs, "A text out of 
context is a pretext."

A long time ago, I posted a very long message echoing all your themes about the 
utility of Mathematica as a front end for C.  I use C and MathLink all the 
time.  Maybe the moderator can insert a reference to my old message for you.  I 
don't have the savvy to find it.

On the other hand, it is a lot easier to type Prime[100000] in Mathematica to 
find the 100,00th prime number than it is to write, compile, debug, recompile, 
and test any C routine you care to name.  Even if the C program has already 
gone through the usual paces, it's still easier to type Prime[100000] than to 
execute a separate, special-purpose program, MathLink or no.  In other words, 
Wolfram Research has done all the work for you, why not take advantage of it?  
"You always endeavour to use the best tool, or the most convenient set of 
tools, for the job at hand" is right.

I use MathLink under two general scenarios.  (1) Mathematica can't do what I 
need, or its interpreted language is too slow.  (2) Mathematica can do what I 
need, but I require a stand-alone C routine for some reason, and want to debug 
it through MathLink.

So I was making a point about productivity more than anything else.  It struck 
me at the time that the person asking how to turn Mathematica code into C code 
was somewhat missing the point of Mathematica.  He clearly fell into case (2), 
because he proposed to write the original code in Mathematica.  Contrary to 
your statement that "Nobody asks it [Mathematica] to [write C code]," that was 
exactly the capability the original questioner had in mind.  Given that 
Mathematica does not write C code, I tried to push him in the right direction. 
 For general numerics work there is little reason to leave the Mathematica 
environment unless compelled to do so by deficiencies in Mathematica itself.


P.S.  I found very interesting the work that a graduate student has done on a 
package that converts Mathematica to C.  This kind of tool certainly has some 
good uses, and maybe even satisfies the original post.  I point out, however, 
that all the output examples supplied convert procedural Mathematica to 
procedural C, and while that much is wonderful, there is no way to convert 
shorthand Mathematica (e.g. Prime[100000]) into procedural C.  To do that you 
would have to build a library of functions identical to those contained within 
Mathematica and convert MMA function calls into C function calls on a 
one-to-one basis.


  • Prev by Date: Re: Loading packages w/o write access
  • Next by Date: Pentium Performance
  • Previous by thread: Re: Re: c code generation
  • Next by thread: Re: c code generation