3 ms·
just because a footgun exists, doesn't mean you should use it
by 38 2y ago
just because a footgun exists, doesn't mean you should use it
- lolinder 2y agoThen let's talk—with specifics!—about why it's a footgun and we shouldn't use it. "Because Go doesn't support it" would also be a reason to avoid: * Generics (at least until recently) * Classes * Prototypes * Exceptions * Async/Await * Package managers (until recently) * Algebraic data types * Effect types * Type inference * Type classes * Etc. You could argue that one or more of these are footguns, but I seriously doubt you'd consider them all to be, so let's talk about what separates the footgun from the feature that just didn't fit in Go's design.
- 38 2y agoThis isn't about Go. This is about a language construct (&& and ||) that I would argue is terrible and should never be used. Its mainly just sugar, and in my experience code heavy on these is harder to read and write. Couple that with truthiness and it's even worse.
- trealira 2y ago> This is about a language construct (&& and ||) that I would argue is terrible and should never be used. Something tells me you'd hate my five-line implementation of the standard library function fgets in C. char *fgets(char *buf, size_t n, FILE *fp) { char *p = buf; int c = 0; while (n > 1 && (c = getc(fp)) != EOF && (*p++ = c) != '\n') n--; return n > 0 && (c != EOF || feof(fp) && p != buf) ? *p = '\0', buf : 0; } I'm joking; I'd never write code this way in earnest.