Trying to translate a symbolic differentiation performance benchmark to Julia

Hi, I was interested in translating Jon Harrop’s symbolic derivatives benchmark to Julia, but since the original code is really heavy on ADT’s and pattern matching I don’t really have a good intuition for what style would work best when translating it, especially if I want to take advantage of the small union optimization. AFAIK, Julia doesn’t allow union types to be recursive as in const Uniontype = Union{Int,Node1{Uniontype},Node2{Uniontype}…} .

The benchmark source code for various languages is in the following links:

The blog post with the actual performance comparisons is here:

1 Like

Any luck?

1 Like

You might want MLStyle to get syntax support on ADTs and pattern matching.

1 Like

I did end up using MLStyle for the port, since porting the code is simply too tedious without using a dedicated @match macro that supports a wide range of patterns.

Made a quick port of the benchmark at
I haven’t spent any time optimizing it and it is more or less a straight copy of the OCaml version, except for leaning a bit more on the Julia standard library when appropriate.