News for hackers. Stuff that matters.
Re:Twelve Years of Go by AtNightWeCode on Wednesday November 10, 2021 @01:55PM (#29178797)
What 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.
Re:Twelve Years of Go by AnimalMuppet on Wednesday November 10, 2021 @03:46PM (#29180517)
And 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.

Re:Twelve Years of Go by mseepgood on Wednesday November 10, 2021 @02:17PM (#29179173)
'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.
Re:Twelve Years of Go by morelisp on Wednesday November 10, 2021 @02:37PM (#29179479)
> 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.

Re:Twelve Years of Go by Thaxll on Wednesday November 10, 2021 @02:02PM (#29178935)
vs exception based control flow which is way worse.
Re:Twelve Years of Go by xh-dude on Wednesday November 10, 2021 @04:03PM (#29180743)
I 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.