Why do we have things like Js.String and Js.String2



I mean, I get how String and String2 differ: the latter seems to be data-first while the first one isn’t. But why have the non-data-first version at all if data-first is the recommended style and the String functions bind to the String.prototype methods?

Isn’t code like files->Js.Array2.joinWith("\n\n")->Js.String2.splitByRe([%bs.re "/\\n{2,}/g"]) more convenient than, I don’t know, files->Js.Array.joinWith("\n\n", _)->Js.String2.splitByRe([%bs.re "/\\n{2,}/g"], _) (or having to mix fast and slow pipes in the same expression)? To say nothing of the increased cognitive load and the maintenance burden.


Backwards compatibility, basically.

See also, https://github.com/BuckleScript/bucklescript/issues/2975#issuecomment-502426833.


I don’t know, I think Belt will have to release a major version and break things at some point. Which would be a great chance to streamline all the APIs (or at least great parts of the APIs) without worrying about backwards compatibility.