RFC: The encoding for type bytes


Hi all,
We are evaluating that if it is worth to change the current encoding of bytes from regular js array to UInt8Array


  • Better performance
  • Better interop with Node API since Buffer is also UInt8Array


  • This is a ES6 feature, which means lacking support on IE



i think it is good, more performance. i don’t thing people still use IE these day :joy:


Some still do, the question is whether the companies that support IE are advanced enough to use React :grin: IE is mostly irreplaceable in companies with legacy intranet projects, and it makes very little sense to write a legacy project in Reason :slight_smile:


Add to the list less memory - currently we use 32 bit ints for each value rather than 8 bit ints.

I’d be very happy to see this change - and would be more likely to use BS in cases where I needed to read/write binary data


I think we should be fine, because there are polyfills available.

e.g. https://github.com/substack/typedarray


I remember @bloodyowl still supports IE10, is polyfill an option?


IIRC I “cleaned” some code so that it wouldn’t import the bytes related modules. Would the polyfill be required for all cases (e.g. if pervasives had a side effect making use of them) or simply when making use of them?


what is going to happen to the unsafe conversion functions between bytes and string?


Can you be more specific?
Bytes.unsafe_{to,of}_string should be good


I think it’s great. I think supporting more of es6 would be great in general. Most projects that need to support IE probably already have polyfills or another compile step in place.


I’m all for this, as discussed on github some weeks ago. I haven’t had a chance to look into doing a PR myself since then, and to be honest I probably won’t have time until later this year.