Day One - Feeling It
note: I tend to write the journal entries a day or so after the event.
On Day Zero I basically did some setup, made this blog and did some light reading. Today was the first “real” day of learning Elixir.
These journals are generally just me putting down what I’ve learned or places I’ve explored.
While strolling through Elixir Forum I found a couple posts talking a Red4 video, so I decided to check it out. The sample was pretty good and entertaining, so I paid $25 for it. You can read my review for it here: Red4 Training Video Review.
Today I worked through about 40% of the video and began building out the example app. It was great seeing some scaffolding and seeing how data flows through the functions.
If you’re someone who has income to spend on training, I recommend checking it out.
I learned about the Elixir Foundation Podcast last night and subscribed on my Android phone. Today on the way home from work, I listened to the latest episode (Elixir Fountain Ben Marx 2016-08-16). It was pretty good. I recommend checking it out. I’ll be working my way through the past episodes this week.
I signed up over at Exercism.io and got everything all setup. I did the first exercise, which was a “Hello, World!” with a little twist. While I did it properly, I soon learned about how string interpolation is done in Elixir:
My original solution wasn’t as elegant:
As time permits, I plan to work my way through the other problems.
I learned a good bit of Elixir so far and shared what I learned with some co-workers. Here are some of the key points:
When I first saw x = 5 I thought it was assignment. Nope, it’s equality. And this really didn’t sink in until I saw the following code in the Red4 video:
It’s Algebra again.
By the way, <> is a string concatenation operator.
Since Elixir does pattern matching, you can have function override by passing in different types. For example:
If you call that function with a :miles ATOM, it will use the first one. And if you use a :meters instead, it will use the second one.
Atom: The name of the atom is its value. Example:
Tuple: It’s a collection of things. Generally a tuple is going to be up to 4-5 items, because after that, you’ll probably look into using a MAP. Also (as far as I know), it’s common for the first item of a tuple to be an atom, which describes the data of the tuple. Example:
List: It’s a list of things and while it may look like an array, it isn’t really one. Example:
Keyword List: This is a list with labels (and those labels are atoms). Example:
Maps: It’s like a hash. Maps have any value as a key. Keyword lists must have an ATOM as a key. Example:
Structs: Structs have Predefined keys and the benefit of default values along with type safety. Example:
I learned another way to call functions, which I like.
I find that it’s easier to read and cleaner. Speaking of cleaner, I also like this method of piping functions:
And lastly in the style department, I learned a second way to write out functions.
Over the past day and a half I signed up for many things and have been spending time ready Slack messages, forum posts and listening to a couple podcasts. So far, I’m enjoying life and looking forward to improving.
Next up I’ll be looking into some other training offerings and continuing on the Red4 video. Stay tuned!