Byte arrays can create some expected errors or bugs that can sometimes be hard to track down. Sometimes you might forget to do a copy because you forgot your own code or the code is not written by you.
The main advantage of a byte array is that it is mutable. However, right after building the contents, I think it is good to copy it into a string. Yes, there is some loss in speed, but compared to disk accesses and network calls, this operation is just a memcpy
and should be highly optimized and negligible in cost.
Furthermore, we often need the byte array in strings, e.g., print out some debug info. You might be casting back and forth between string
and []byte
as the code base grows. I think it will be good to just stick to strings as much as possible, and use byte arrays only when you are building something.
May I convert some byte arrays to strings? I might be able to drop some byte copying or do some other optimizations. Would you all support such a change? @core-devs