News for hackers. Stuff that matters.
Re:PHP: why GOTO instead of recursion? by wyager on Tuesday September 23, 2014 @12:07PM (#8356024)
If you need to use GOTOs in your code for speed and you're not coding in C, you should probably find a faster platform.
Re:PHP: why GOTO instead of recursion? by quotemstr on Tuesday September 23, 2014 @12:34PM (#8356217)
Not all useful control flow graphs can be described with while and if. It's perfectly fine to use goto. Look at some of the contortions people need to go through when avoiding it. Avoiding goto often makes programs harder to follow.

Why is it inexperienced programmers go through a phase where they think goto is evil incarnate? I wish Dijkstra had never written that damn paper.

Re:PHP: why GOTO instead of recursion? by wyager on Tuesday September 23, 2014 @02:01PM (#8356917)
>Not all useful control flow graphs can be described with while and if.

They can be described with if, while, for, case, pattern matching, recursion, etc. There is almost always a better alternative.

>Why is it inexperienced programmers go through a phase where they think goto is evil incarnate?

It seems to me that most people who support general usage of GOTO are inexperienced and don't necessarily realize it. They lack knowledge of better control structures. See the blub paradox.

Besides, the justification here is performance, not readability. I'm saying that performance in particular is a bad justification for using GOTO.

Re:PHP: why GOTO instead of recursion? by jtc331 on Tuesday September 23, 2014 @02:05PM (#8356951)
Agreed that sometimes it's right for control-flow purposes. Hence why I pointed out in the OP thread that I've used it before. But that's not the justification being used by the code author; his justification is purely performance.

>> "Why is it inexperienced programmers go through a phase where they think goto is evil incarnate? I wish Dijkstra had never written that damn paper."

You seem to be referencing my comments. I'm not inexperienced, and I don't think goto is evil incarnate. I do believe that optimizing for individual CPU cycles in PHP is generally pointless.