4 ms·
This is the opposite of specialization, so there are reasons to not do this. Examples: are you likely to write unit tests for your GetFirstChar? A specialized
by thephyber 3y ago
This is the opposite of specialization, so there are reasons to not do this.
Examples: are you likely to write unit tests for your GetFirstChar? A specialized open source library that built this function is far more likely to have unit tests and documentation. Those unit tests and documentation come in handy during edge cases and when your coworker decides to extend the function with an `options` parameter.
Also, general developers rarely understand the full breadth of character sets, for example. So if your function just grabs the 1st byte from a string and expects it to be a character, your end user might be angry when only the first byte of a multi byte character is returned. Similarly the difference between a character and a glyph and a rune, etc. are important and lesser understood.
- boppo1 3y ago>difference between a character and a glyph and a rune What is the difference?
- consilient 3y agoCharacters are abstract entities, glyphs are the shapes that represent them. a and a are two distinct glyphs for the same character. "rune" is Go's name for a unicode code point.
- mxkopy 3y agoThe best option as always is somewhere in between and depends on context. If you’re Netflix or Walmart, localization is a high priority concern and these sort of things need to be considered. If you’re a N=50 company doing logistics for a fishing company, you probably only need to worry about your own internal Char representation that you have complete control over.