Hi. This is my first post.
Recently I tried remaking a CoreImp AST for dynamically typed languages (transpiling into Lua, Dart, JavaScript) just for my interest.
I think it will be eventually stale…, but now It’s new!
If you are interested, take a look and give it a try.
I see that you are encoding Sum and Product using tagged records:
I can now experiment with zero cost JSON serialization easily.
It would be interesting to compare the performance against current instance based codegen on node and in browsers (I know that @garyb made some benchmarking in the past). And even try something like { tag: "Left", values: [ 8 ]} so we have constant shape and possibly fast (ICs) based access to the tag when doing pattern matching… or even { tag: 1, values: [ 8 ]} (so we have Smi in nodejs and chrome) if it is possible to do this.
If I find some time I’m going to check these… because it is now possible to do this kind of experiments using just PS
I think Bucklescript uses records with tags too, so it’s probably not that bad. Unfortunately the test case I had was purescript-in-purescript back in the day, which is way out of date now. It was great for stress tests. It was there that I made the discovery that led to our most effective optimisation so far… erasing {} values.
The instance method PS uses currently is targeting the “hidden class” optimisation in v8. I’m not totally sure, but I think nowadays the hidden class optimisation works on arbitrary record values also.
@garyb Could you please tell me if benchmarking examples for purescript-in-purescript are somewhere public (I wasn’t able to find them after a quick look at the repo)? Maybe we can take some inspiration or clone them and provide simple, generic infrastructure for codegen benchmarks (aka “benchmark yourself”) in psimp.