Chapter 2
This is the long due chapter 2 review.
Unsurprisingly, this is a long chapter, and the naming of the chapter couldn’t be better.
The chapter nicely separates structure (modules, blocks), action (function, closure), and data (map, list) in a very nice way, as a person who is re-reading this book, versed with Elixir, and coming back to it professionally after some hiatus (apart from AoC), I certainly found it not boring (I was suspecting I would). The order those three blocks were introduced and the way knowledge transitions were made, makes up the core strength of this chapter, which I wish to see followed in other languages.
When I introduced folks to Elixir, my order ot familiarizing folks used to be data, function, structure. Fire up the REPL - create some lists, some maps, show how to transform through pipes, and making the introduction to function (keep macros hidden and let them believe it’s function for a bit), then write functions within modules (without reasoning what modules are, like “public static void main” is just assumed to be there when seeing Java), and then make the transition to module. It’s a ride with some leaps of faith and a few hiccups, but those three building blocks can be introduced to a new comer in any order.
This chapter has a much seamless way of presenting. Starting with blocks, then function, and then data. There is no (We will come to it later), and all this information that might as well by three chapters, feels like rightfully and naturally, one chapter. This I feel like, and felt like when I read previous edition, one of the best ones of this book, one I would adopt if I ever write one.
In gist, this is an introduction to Elixir language, and all you expect from a language is present here. No surprises. As usual, each paragraph crafted with care, flow well thought up.
Now for a funny bit, I was reading this book on my tab and didn’t realize it was 2nd edition (well the colour isn’t as different as 1st vs 2nd was). So I ended up reading the wrong “Chapter 2”. And Elixir being a more or less stable as a language didn’t help either, I mean, if it were JavaScript, I would have caught it on the second sentence.
So, I read the correct edition, and out of curiosity opened the chapter side by side and did a quick scanning for diffs. Here are a few that caught my eye:
- Addition of
#iex:break
– I have seen so many folks having “Aha” moments when I introduced them to this when I was working in Elixir teams. This is a valuable tip and an addition to this chapter.
- A nice sidebar on multiline structure
System.stop
is the winner (as it should be) of the who’s more polite contest!
- Has (thankfully) so, outputs of
Code.fetch_docs
printed out, this gives readers an initial idea of the structure.
Well that’s about it, not many other big changes that caught my eye, apart from a few formatting goodies.
This will be it, my experience with chapter 2-s 