Programming Elixir by Dave Thomas

Starting a thread for this book as it’s the first one I am reading, please feel free to start threads for any books you are currently reading (or have read).

4 Likes

I was 10% of the way through this book (according to my Kindle) but when I updated it to the latest version my Kindle lost all of my notes/bookmarks :icon_eek: so I’ve restarted it (though I’m back up to 6% now).

I love how Dave is covering some of the stuff I was curious about. One such item was why can’t we just call functions like we can methods in OO? Such as name.capitalize which of course in Elixir we would do String.capitalize(name).

Well, Dave says:

When you make a call such as name.capitalize() you have no immediate indication whether you are changing the internal representation of the name, returning a capitalized copy, or both. There’s plenty of scope for ambiguity.

In a functional language, we always transform data. We never modify it in place. The syntax reminds us of this every time we use it.

Similarly, I’m curious why we can’t just use + (like we can in Ruby) to add things, join strings and arrays etc but instead we have a few different ways in Elixir, such as + (addition), ++ (join lists), <> (join strings) etc…

I hope he sheds some light about this in the book as well :lol: Either way I can’t recommend the book enough - I’m loving it so far.

Anyone else got the book? What do you think? How far through it are you?

2 Likes

Somewhere on this board I already did a somewhat longer post about that, but TL;DR is “ambiguity”. I’ll update this post when I find the other one.

edit
Sorry, I can’t find it… Maybe I even did post it at another board?

Anyway, just a single example, why using + for cancatenating strings and lists is a bad idea: 1 + [1], what do you expect? Also, for nummeric addition a + b == b + a holds, this is not true if you use + for list/string concatenation. Since Elixir is a functional language, which you sometimes do reason about at an academic level, the reasoning is easier.

Also some evil tongues may say, it is just because Erlang did it this way, and keeping it this way is needed to stay compatible with BEAM. While this is true, it is only one of many reasons :wink:

3 Likes

I think it may have been on MetaRuby :lol:

I also thought that it being the Erlang way might have been a factor, but your point about reasoning is valid too.

Yeah, it was: My more detailed thoughts over there on metaruby.com in the thread Elixir

1 Like

I very like this book. I am bout 30%. I did exercises till chapter 10.
It is suggested to download source code.
There is book forum https://forums.pragprog.com/forums/431

1 Like

What have been your favourite bits so far @mkunikow? Any bits that you didn’t quite ‘get’?

I am familiar with functional programming Clojure, Scala. I think this helps learning another functional language.Some concepts are common.

My favorite bit is there are no objects, classes and inheritance :). I don’t like OOP.

The problematic “bits” is Erlang itself like: strings sometimes " " or ’ ’ or erlang functions called from elixit and etc.

I want to check OTP (later chapters). The Erlang OTP is ancestor of Scala/Java Akka the most popular way to build distributes systems on Java VM http://akka.io/

2 Likes

Amen to the No OOP. I have been a hard-core Scala nut for about 5 years and have all but dropped it in the last few weeks!

1 Like

@ejc123 About Scala I can agree 40% pleasure FP and 60% pain OOP:). But they have some cool toys like reactive streamd, DDD or CQRS. Maybe someday it will be ported some day to Elixir :slight_smile:

1 Like

I’m finding the book really helpful for getting into Elixir. There’s plenty of documentation on-line on Elixir, but lack a complete and up to date introduction to the language. This book fills that gap perfectly. The writing style makes it easy to read even though it’s quite dense in information sometimes.

Also, the epub and PDF are very wel made with proper TOC, links etc. I would’ve loved the paper book but $25 was a bit too much for an impulse buy. But knows, I might win a copy in the giveaway! :wink:

1 Like

This is one of the reasons I love books so much - I like someone to walk me through things while giving me their opinion on things. This helps me get a feel for the language which documentation rarely does.

Also re the giveaway, we are giving away a digital copy (ebook) :lol:

1 Like

Really enjoying this book. Trying to work through all the exercises but they do get pretty tough!

3 Likes

Is anybody else having issues with the images on their Kindle? Every image (so far) is showing the observer GUI, except the image that’s supposed to show the observer GUI :slight_smile:

1 Like

I’m not sure what you mean @trydis can you take a photo and upload it so we can see?

So far my images have been ok…

Picture that’s supposed to be of a tweet:

Weird formatting of examples with two iex windows:

1 Like

Oh I had the first one too! I would definitely report that as a bug.

I haven’t got to the second one yet, but I would mention it at the same time.

0% through for me! - I just bought it, can’t wait to get into it :slight_smile:

2 Likes

Nice one @alaister :023:

I have just got to 15% :003:

1 Like

I have no idea why there isn’t an index for the book. It’s rather annoying having to refresh your memory of a concept and having to figure out which chapter you’ve read it in or whether you read it in this book at all or from another.

Otherwise, the book has been great. I’ve skipped the exercises for now, although I would like to attempt a few after I finish the book. I’m 30% of the way through.

2 Likes