I'm looking for an exhaustive list of source-to-source compilers to all other languages, if any exist that is.
-
3I suspect the number of all the cross-compilers would be zero. – bill s Dec 06 '14 at 04:07
-
Perhaps something like "MathCode C++" and/or "MathCode F90" would do what you want. These are advertised as "Generates Optimized C++/F90 Code from Mathematica Programs". – Stephen Luttrell Dec 06 '14 at 10:08
-
I expect that any such tools will require you to write simplified Mathematica code before they can translate it to another language. – Szabolcs Dec 06 '14 at 17:59
1 Answers
Mathematica has a very large number of builtin functions, most of which would be part of libraries in other languages. Many of these functions are next to impossible to implement in a compatible way, think e.g. Integrate. Mathematica is also very different from most other languages: it is based on term rewriting and operates with symbols (concepts not found in most other languages). For this reason there aren't any general source-to-source compilers that can translate Mathematica.
There are however tools which can translate a very limited subset of Mathematica. These usually require procedural Mathematica code that operates only with machine reals or machine integers.
Let's compile a list of such tools in this community wiki answer.
Mathematica has builtin tools to generate C code, through
Compile. See the detailed documentation.MathCode C++ and MathCode F90 are commercial packages that generate C and Fortran.
CForm,FortranForm,TeXForm, and related functions can translate simple symbolic expressions to other languages. These don't support arbitrary code, just simple expressions, e.g.:FortranForm[x^5 + Sin[x] - 6]$\rightarrow$-6 + x**5 + Sin(x)The ToMatlab package translates expressions to MATLAB (similar to
CForm, etc.)Maple includes a tool to translate Mathematica expressions, code snippets or even whole notebooks to Maple expressions, code or worksheets.