News for hackers. Stuff that matters.
Re:Railway oriented programming by insulanian on Thursday June 23, 2016 @07:29AM (#11960192)
> Exceptions are not too bad, but they are very often misused.

This! The worst is when people start using them to control the flow of business logic. I hate that.

Re:Railway oriented programming by nerdponx on Thursday June 23, 2016 @08:05AM (#11960305)
What actually is so bad about doing this?

I'm a data scientist, not the software engineer, so forgive me if this is something you all learned in CS 101.

Re:Railway oriented programming by piaste on Thursday June 23, 2016 @08:44AM (#11960452)
You know how GOTO is real bad? Well, using exceptions for flow control* is basically a thinly disguised GOTO.

Also, constructing an exception object, with the full stacktrace etc., is a pretty heavy operation and can cause big performance issues. But it's mostly the first thing.

* Which is an important distinction. Flow control exception are recognisable because you intentionally throw an exception and expect it to be caught by a particular catcher to process it in a particular way - much like a GOTO, and with all its fragility. In the proper usage of exceptions, when you throw an exception you don't care which line of code catches it and when you catch an exception you don't care which line of code threw it.

Re:Railway oriented programming by nerdponx on Monday July 04, 2016 @10:10AM (#12030859)
Believe it or not, I was just working on a script this weekend that was becoming a nightmare to debug. And when I realized that I had been lazily using exceptions as control flow, this really hit home.
Re:Railway oriented programming by cousin_it on Thursday June 23, 2016 @07:39AM (#11960215)
Just wait until the same people get hold of monads to implement their business logic.