
What's coming in Elixir 1.3 - tuvistavie
http://tuvistavie.com/2016/elixir-1-3
======
im_down_w_otp
I don't understand the purpose of `with`. If it's to help people deal with
deeply nested or byzantine case-clause structures, then that seems weird to
me.

Isn't the way to deal with that problem is to hoist those clauses into
functions with different pattern signatures and rely on function-head
matching?

Everything else looks awesome. I have to say, somewhat selfishly, that my
favorite part of Elixir is actually the pressure it's putting on the Erlang
community to up its game and care more about developer experience and
enablement through better tooling, etc.

~~~
erydo
The `with` statement seems similar to Haskell's `do` notation for monads,
where the monad(ish) here is pattern matching.

I'm new to Elixir but I've definitely run into the "byzantine case-clause"
issue and it can be very annoying. My case was very similar to the example:
pulling something from a form, validating the format, validating it in the
database, and returning something. All failable, single-purpose functions in
sequence to narrow down the result.

I grappled between using a monad macro library[0] to simplify `{:ok,
_}`/`{:error, _}` signatures versus just raising exceptions. I ended up doing
the latter for the additional benefit of stack traces. Exceptions seem
culturally discouraged in Elixir, though I don't quite grok why yet.

Out of curiosity, would you be willing to show how you might refactor the
post's "create_organization" example?

[0] [https://github.com/rmies/monad](https://github.com/rmies/monad)

~~~
tuvistavie
Exceptions are not discouraged, using them for flow control is. There are I
think a few reasons why exceptions are a being a little frowned upon.

The first one is that usually we do not want to rescue them, the let it crash
philosophy. If an error happens, the the process will crash, it will be
restarted, the error will be logged, and everyone will be happy.

In the case we really do want to handle an error, we can usually just use
`case` or `with`, which are simpler, avoids to rescuing something we did not
expect, as well as some pitfalls, for example the fact that recursive calls
inside a `try` cannot be optimized to be tail-recursive, which can be an issue
depending on the case.

However, I think it is fine to use exceptions if it can avoid deeply nested
code, which was probably your case.

------
tbrooks
I'm most excited about the Calendar datatypes.

There are 2-3 really good Elixir libraries around dates and times: calendar,
goodtimes, etc.

Choice is great, but I really like a canonical library around something so
core as time.

~~~
im_down_w_otp
Yeah, that's going to be absolutely epically useful and save a lot of pain and
debugging.

------
qaq
Elixir is moving forward at a very good pace.

~~~
tuvistavie
Yes, both the language and the ecosystem are getting better and better!

------
BuckRogers
Anyone who keeps an eye on Elixir and isn't aware of the Elixir Radar mailing
list should check it out. I don't use Elixir regularly but like to stay
updated with the most interesting tech platform of our time and ER is the best
mailing list out there for this that I've found.

------
andy_ppp
I've just started using with instead of case today and its tidied up a lot of
code and made each piece more modular. The new with looks even better at
handling errors, although I wander if it will discourage me from breaking up
my functions quite so much.

------
desireco42
A lot of really good things. Elixir is already a pleasure to use, with these
additions, Date standardization, it is going forward.

------
mperham
Side note: your blog content doesn't show up at all with JS disabled.

~~~
tuvistavie
Oh, thanks, I was not aware of that. I'll fix it!

