4 ms·
Does using a less commonly used function for its intended purpose make the code unidiomatic?
by imanaccount247 12y ago
Does using a less commonly used function for its intended purpose make the code unidiomatic?
- coldtea 12y agoIf the goal of using the less commonly used functions is performance, then it probably does. I mean: it's not like the specific problem domain needed a "less commonly used function" (e.g. you need a function to do X, where X is something that you rarely need to perform). Rather it's: "we need to code A, but we will use less commonly used functions instead of what we'd normally use for A, just to get more performance". Plus, it's not like you merely exchange function f with g, while all other factors stay the same. The choice of those "less commonly used functions" also affects other aspects of the program's design (e.g. making it into a more imperative style, going for unsafe, opting for mutability, etc). So the interesting question to call it idiomatic or not, for me, is: "If ultimate performance wasn't a factor, would a Haskell programmer write this program in the same way?"
- imanaccount247 12y ago>Plus, it's not like you merely exchange function f with g, while all other factors stay the same Yes, it is exactly like that. That was the point. It is literally changing out the name of a function. It has absolutely no effect on the rest of the code. Which is why the code is idiomatic by any reasonable definition.
- Edman274 12y agoIf the only differences between the functions are the names and the performance characteristics, then why even bother having the slower versions? There has to be some difference somewhere, right?
- imanaccount247 12y agoAre you serious? Read the thread.