5 ms·
I can live with the error handling. But as I wrote. The problem is that it encourages if-programming. Something that is a problem in the Go community.
by AtNightWeCode 5y ago
I can live with the error handling. But as I wrote. The problem is that it encourages if-programming. Something that is a problem in the Go community.
- handrous 5y agoIf it's helping keep the "'if' considered harmful" crowd away, I say keep it. There are plenty of other languages.
- mountainriver 5y agoYeah exactly, conditionals around errors are fine. Nothing like being pedantic for no reason
- mseepgood 5y agosince when is if-programming a bad thing
- skybrian 5y agoIt depends on what kind. I didn’t find maintaining codebases littered with platform-specific ifdefs all that fun. If statements used for error checking are a bit verbose but basically fine.
- mseepgood 5y agoGo doesn't have platform-specific ifdefs sprinkled throughout the source. Platform-specific code is separated into files guarded by build tags as recommended in 'The Practice of Programming'. Compile-time control flow is not mixed with runtime control-flow.
- skybrian 5y agoSure, that was in C. Go is an improvement.
- AtNightWeCode 5y agoWhat you learn at school when it comes to programming is to avoid if-statements for control flow. It is error prone. If-statements are mainly used for various types of guards.
- Thaxll 5y agovs exception based control flow which is way worse.
- mseepgood 5y ago'if' is the epitome of control flow (next to looping). It's fundamental to computer programming. It's honest. Don't be ashamed of control flow, don't hide your control flow as if it didn't exist.
- morelisp 5y ago> It's fundamental to computer programming. I'm weakly pro-if, but no, it's not. We went a lot of years without it, and some rending and gnashing accompanied its introduction.
- AnimalMuppet 5y agoAnd what you learn after a few years in the real world is that, when school tells you "this is the right way", they're almost always wrong. Or, there at least almost always wrong in many circumstances. The real world is a lot more complicated than they teach you in school, and the correct answer is almost always "it depends". Should you avoid if-statements? It depends. What are you going to have to do instead? You're going to have to do something. Is that something going to be more understandable for your co-workers for the lifetime of the code? Maybe, depending on your co-workers. Maintainability over the lifetime of the code far outweighs and "should" that they tell you at school.
- xh-dude 5y agoI really think Go’s opinion here arises from a sense that some abstractions of control flow just should be verboten for concurrency. For example exceptions dumping a stack trace in a concurrent program is often OK and occasionally extremely cursed.
- nobleach 5y agoSpectre I think? The mitigation patches make branch-heavy code slower.