Learning Elixir Through Exercism

So, here’s the thing: I need to learn Elixir and the Phoenix Framework for some job I have right now.

I find that Elixir has many macros to do a bunch of stuff that it doesn’t do out of the box to make the whole transition process from the whole Object Oriented paradigm, much easier.

But when you’re learning something new, I find that the most important thing is to learn the basics really well and worry about productivity later; otherwise you end up developing bad habits, and those are hard to get rid of.

Well, that’s not an easy task. Even on Elixir’s documentation, there’s at least three ways of doing conditionals and they’re probably just macros to  case.

The exercism way

That’s when I found exercism. You can find tons of exercises to try your skills on a new computer language and compare your doings with other people worldwide. You can install a CLI on your computer and fetch the exercises whenever you want to. All the exercises come with tests, and you must use the TDD approach, which is a plus.

The exercises also come with comments on how to do them. And one particular exercise’s comment caught my attention: list-ops.

# Please don’t use any external modules (especially List) in your implementation. The point of this exercise is to create these basic functions yourself. Note that `++` is a function from an external module (Kernel, which is automatically imported) and so shouldn’t be used either.

That’s what I wanted! I wanted to learn the language without worrying about libs!

So, basically I had to implement from scratch these functions:

  • count
  • reverse
  • map
  • filter
  • reduce
  • append
  • concat

And I did:

Elixir

I found out that Erlang’s BEAM ( think JVM for Erlang ) is pretty good at handling recursive calls, and won’t cause a stack overflow.

tail recursion elixir
Functional Programming @ it’s best

And since Elixir is compiled to Erlang object code, it comes with the same benefits out of the box. Neat, huh?

That’s all, folks.

 

ps: I really need to know how to end an article better.

Leave a Reply

Your email address will not be published. Required fields are marked *