3 ms·
Normalize writing your own code. If you’re in an environment where importing GetFirstChar from an essentially random person is the norm, this is bound to happen
by mxkopy 3y ago
Normalize writing your own code. If you’re in an environment where importing GetFirstChar from an essentially random person is the norm, this is bound to happen. It seems like some developers write code only if the functionality isn’t provided by some package, when really they should be reaching for the imports only if writing the package is too much effort.
- thephyber 3y agoThis 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.