Elixir docs kick butt! (series)

post elixir

As I wrote already, I'm learning elixir, following this book: The Little Elixir & OTP Guidebook.

It's quite nice and it's getting me familiar with the most basic mechanisms of the language and OTP.

There was a hickup with the example not working, so I had to problem-solve on the go - I created a repo with the example, explaining the problems and solutions, if anyone is interested.

The thing is, the book has been written a couple years ago and it uses the old supervision model with :simple_one_for_one restart strategy.

Here's when elixir's great ecosystem and docs kick in

When I typed the dynamic supervision example from the book and started iex (Interactive Elixir) to play around with it, I immediately got the following warnings:

  warning: Supervisor.Spec.supervise/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
  ...
  warning: Supervisor.Spec.worker/2 is deprecated. Use the new child specifications outlined in the Supervisor module instead
  ...
  warning: Supervisor.Spec.supervisor/3 is deprecated. Use the new child specifications outlined in the Supervisor module instead
  ...
  warning: Supervisor.start_child/2 with a list of args is deprecated, please use DynamicSupervisor instead
  iex(2)>

The example was working as intended, but it was clear I'm using an outdated interface. I suppressed the reflex of googling and used the help tool built into iex - it's a habit I'm getting into, because it is just so damn good.

I simply typed iex(1)> h DynamicSupervisor and got presented with a full documentation of DynamicSupervisor with examples of different usages and a full section about Migrating from Supervisor's :simple_one_for_one.

The documentation gave a full example of old implementation and how to move to the new one. It pointed me to different places in the docs where the worker specifications were explained and it took me around 10-15 minutes to update the example from the book to use the DynamicSupervisor.

I'm pretty hyped about this and can't wait to learn more. Stay tuned, more to come soon (I think).

This post is part of a series!

  1. I'm gonna learn elixir (again)
  2. Elixir docs kick butt! <-- you are here :)