Structural vs Physical Equality in Reason


#1

The Reason doc says:

Use structural equal tastefully. It’s convenient, but might accidentally make you compare two deeply nested data structures and incur a big performance hit. It’s also not always clear what counts as “equal”.

While the performance hit when run on the browser is real (and much worse than native OCaml?) wouldn’t this go against the principles of value-oriented programming? It discourages pure functional techniques and would want the programmer to use arrays and hashtbl over immutable structures like lists and maps.

What’s the general wisdom here and how do you deal with this in your codebases? I’m also curious whether immutable-re might be a long-term solution for this. If anyone is familiar with how Elm, PureScript, and Fable tackles this, that’d be great to know too.

Thanks!


#2

tbh I use structural equality almost exclusively – I think that warning is misleading


#3

Good to hear that Jared. I’ll raise a PR :slight_smile: