Re: Mathematica to .NET compiler
- To: mathgroup at smc.vnet.net
- Subject: [mg79432] Re: Mathematica to .NET compiler
- From: Jon Harrop <jon at ffconsultancy.com>
- Date: Thu, 26 Jul 2007 06:29:44 -0400 (EDT)
- Organization: Flying Frog Consultancy Ltd.
- References: <200707200725.DAA24728@smc.vnet.net> <f7sflm$rs0$1@smc.vnet.net> <f86onh$g19$1@smc.vnet.net> <f89p6l$54l$1@smc.vnet.net>
David Bailey wrote: > Surely to support all those features you would need to write something > equivalent to a fair portion of the Mathematica kernel - why would your > code work any faster than Wolfram's? Garbage collection for one thing. The real Mathematica uses reference counting, which is widely known to be both flawed (can't collect cycles) and slow (was dismissed as a competitive technique decades ago). Inheriting a garbage collector from something like .NET lets you replace a core component of Mathematica with a piece of code funded by the world's wealthiest software company, written by dozens of experts over many years with enormous emphasis on performance. Type inference for another thing. This technique is widely used in modern high-performance functional programming languages to combine the brevity of Mathematica with the speed of C++. The current Mathematica does no type inference. > I can't see how something like > > expr /. f[a_]->a^2 > > can usefully be compiled if you don't know the structure of the > expression at compile time (which you usually don't). You don't need to. That translates directly into SML, OCaml, Haskell or F#: let rule = function | `Seq(`f, [|a|]) -> a **: Int 2 | f -> f;; replace rule expr;; This is a pedagogical example of term rewriting in these languages, which are used to write theorem provers and compilers and excel at exactly this. When "a^2" is trivial to compose, the above OCaml code will be roughly two orders of magnitude faster than Mathematica. > As far as I can > see, all you could compile that into would be a call to your pattern > matching library code! Whenever possibly, you would compile into the pattern matches of the target language (as I did above). Compilers for these languages already implement high-performance optimizing pattern match compilers. So they handle everything between that and machine code. -- Dr Jon D Harrop, Flying Frog Consultancy OCaml for Scientists http://www.ffconsultancy.com/products/ocaml_for_scientists/?usenet
- References:
- Mathematica to .NET compiler
- From: Jon Harrop <jon@ffconsultancy.com>
- Mathematica to .NET compiler