Quotes from Programming Elixir

Threads Programming Elixir ≥1.6: Functional |> Concurrent |> Pragmatic |> Fun by Dave Thomas.

Some of Dave’s words I found particularly interesting, insightful, or inspiring.

“But mostly, I want you to have fun.”

“…you can think about programming in a different way.”

“You no longer have to think too hard about protecting your data consistency in a multithreaded environment.”

“I don’t want to hide data. I want to transform it.”

[Read More]

Programming Elixir Chapter 22 Notes

Macros and Code Evaluation

My interest is in application development so macros are not something I expect to ever be creating. So this is mostly a chapter for reading.

Did work through the first two exercises. Took awhile for me to understand that I cannot use a macro-defined function in the module where it was expanded. Makes sense since Elixir first compiles then loads, so the dynamically-created function isn’t available for use.

[Read More]

Programming Elixir Chapter 17 Notes

OTP: Servers

Dave discusses an alternate component-based approach to writing GenServers. This consists of modules in three files:

  • A public API to hide the GenServer complexity.
  • The GenServer interface.
  • Implementatation.

The public API is just a wrapper to the GenServer functions and the GenServer functions are just a wrapper to the implementation. This hides the GenServer call/cast complexity and isolates the implementation.

I like this approach, but think that breaking it into three files is too complex. If the public API is only a wrapper to the GenServer API and the GenServer API is only a wrapper to the implementation, we can easily put them into a single file.

My approach implements the GenServer in two files:

  • Public API which calls the GenServer functions.
  • Implementation
[Read More]