Re:Hands-on Scala Programming
by 9q9 on Sunday April 19, 2020 @03:16PM
(#22918100)
I agree with your evaluation that parts of the FP community are extremely vocal and extremely smug, and this can and does have a bad effect on a community. This is a problem.
Dealing with this problem requires leadership. In particular a project leader typically has to decide (in a Scala context) whether to go FP or imperative, because mixing both is often a problem. Similar to e.g. using message passing or shared memory for communication between threads.
This is a good example. It is really important to be very clear from Day 1 how to handle errors in a project. One hybrid choice that is popular is: use exceptions for errors that you cannot recover from, use Options for local error handling.
[ Parent
| on HN ]
Re:Hands-on Scala Programming
by erik_seaberg on Sunday April 19, 2020 @05:52PM
(#22919095)
Option does throw away the error. I like Try { expr } a lot, to the point that I retry, give up, and then serialize a Try[T <: Product] into a Row so flaky dependencies don't trash all the output from a big Spark job.
Yes, that's true, if you want to propagate information about the nature of what went wrong locally (e.g. logging) you need to use something richer (e.g. Either).
Re:Hands-on Scala Programming
by erik_seaberg on Monday April 20, 2020 @08:38PM
(#22930581)
Yeah, Try[T] is basically Either[Throwable, T] with some glue for catching and rethrowing.