Writing a Mathematica Interpreter in Typescript

(spakhm.com)

49 points | by lispybanana 4 days ago ago

4 comments

  • coffeemug 5 hours ago

    Hey, that's my project!

    I just wrote another post about perf benchmarking it against Mathematica proper-- https://www.spakhm.com/ts-wolfram-bench. Really surprised by the result, on the workload I tested Mathematica is only 2x faster than my barely optimized interpreter. A testament to the V8 engine, I didn't quite realize how ridiculously good V8 is until running this benchmark.

  • Someone an hour ago

    > Certainly Mathematica’s term rewrite loop is optimized to death, and I only spent an hour or two making the most basic optimization

    I suspect this benchmarks begint libraries more than term rewriting. A way to test that may be:

      bif[1] := 0
      bif[2] := 0
      bif[n_] := bif[n-2] + bif[n-1]
    
      Timing[Do[bif[15], 1000]]
    
    You can check that neither tool is smart enough to solve that to

      bif[n_] := 0
    
    by comparing running times for different large limits.
  • samlittlewood 4 hours ago

    So tempted to try this myself in another language - just so I can call in ‘tungsten’.

    • stared 3 minutes ago

      Tungsten oxide - for one in Rust.