5 ms·
- Simple and lots of duplicated code. Golang took DRY overuse and turned it on its head to be dupliate everthing everywhere - Its duplicated everywhere which m
by dd82 3y ago
- Simple and lots of duplicated code. Golang took DRY overuse and turned it on its head to be dupliate everthing everywhere
- Its duplicated everywhere which means I need to mentally figure whether I need to figure out this path or ignore. Mental load of typing is small, load of reading is not
Golang has alot of good things about it. This is not one of them and is a wart on the language that is tolerated because the genesis of the language is to be an entirely inverted approach to verbosity than Java. Its not something to be praised.
- marcus_holmes 3y agoThe mental load of reading a lot of simple code is less than reading a small amount of complex code, I find. It's easy to look at a 50-line function with one statement every 5 lines and find the bit I'm interested in, because it's easier to screen out the bits I'm not interested in. Rather than unentangling a 5-line function that has 10 statements in it, because I have to work out what all of it does in order to understand it and I can't focus in on the bit I'm interested in.
- et1337 3y agoThe problem with lots of simple code is now there’s 5,000 slightly different ways of doing the same thing. You end up trying to wrangle it with a mess of code generation and linters.
- marcus_holmes 3y agoYeah, this is something I think feels like a bigger problem than it actually is. If I change the way I'm handling something, it is a lot of typing. But it's just typing. No big deal.
- setr 3y agoThe usual issue isn’t the typing, but the fact that you need to make sure you identified and updated every site correctly. DRY isn’t about reducing LoC
- marcus_holmes 3y agoBut the same is true with the concise code. Only with that you have to unentangle each chain to work out if it needs to be refactored or not, and that's hard.
- setr 3y agoYou’re talking about code that’s been reduced from 10 lines to like a one-liner; whether it becomes more understandable or not (and whether to keep it as such) is a matter of taste. But not copying and pasting code by merging common logic is a matter of reducing the number of times you can fuck up, and reducing the number of “accidentally/unnecessarily special-cased” scenarios. You’re trying to reduce the amount of information needed to understand the codebase. The former is preserving the information, it’s just writing it more densely.
- dd82 3y agoits a lot of repetitive noise. Coming from other languages like python and java, this is a good example of normalization of deviance to me.