Having problems learning elixir

Don’t assume your code will look like the code of a 12 year vet out of the gate. Aim for “works”.

My core exercise to learn and what I used here was to rebuild something I’ve built many times over. It forces me to work through common problems that I know how to solve to understand how to solve them this way.

Well first congratulate yourself for stepping out of your OO comfort zone and daring to stretch once more. With that comes the feeling of a newbie no matter how long you have been at it. Give yourself a break and stop the comparisons with your progress relative to others. What is the point of this journey if there is no curiosity and joy? Begin again! And repeat this mantra each time you feel stuck. Start small. Put the web portion down and focus on the core would be my suggestion. Next have a small problem you would like to solve for e.g a simple factorial. With this in mind start thinking how you would approach it in OO and then functional. Keep this problem in the back of your mind as you start to grok the fundamentals. Every new concept gets the same weight so having a goal allows you to add importance by assigning relevancy. Once you get the problem solved rinse and repeat as you grok more and more of the concepts, returning to those you saw before but had no use for at the time. But by all means allow yourself to have some freedom to be curious, to fall and to then get back up more determined each time. Oh wait this is about Elixir and not life. My bad. :grinning:


For a beginner I recommend the:

It has some things which help me a lot and other books don’t explain very well.
So after them the books…

After skiing for many years, I tried snowboarding - and I was terrible at it. Friends of mine, who had never skied, picked up snowboarding easily.

A guitarist that plays for many years internalizes the positions of the frets. When they play, they don’t have to look at the neck of the guitar - even though the distance between the frets varies along the neck, this gradual narrowing of the frets is part of their muscle memory. If you made the frets equidistant, it would feel wrong to them - they would suddenly make a lot of mistakes.

I suspect what this comes down to, is that you are simply very good at OOP. Since unlearning is more difficult than learning, this makes FP feel “hard.”

You will get a lot of advice about the best places to start. Personally, I think Saša Jurić’s Elixir in Action is the best first stop, but this community has a disproportionate number of awesome resources for its size, so you will get a lot of other suggestions.


The problem solving is always about individual’s way to come up with a logic. And that can form any rules but there are best rules with which one can find a good solution and that is considered best algorithm. There is a book called “Algorithms A Functional Programming Approach by Fethi A. Rabhi, Guy Lapalme”. Check that out, wherein they explain functional programming method using Haskell.

Actually I learned Functional programming better way because of a online tutorial called Happy learn haskell. Now that helped me to get the concepts of Elixir real quickly too. It’s a different teaching method, but I still am learning how to approach solving problem. And that requires each problem approached different methods and coming to the best solution, and that’s where algorithm comes in and that’s where you find out which say “reduce” or any other is good for a specific problem. And this knowledge comes to us when we constantly learn to use different methods to address small puzzle problems. Immediately it would be too difficult to come to an understanding of this.

So do once check that book . I wish someone wrote the same for Elixir, that would have been a great book for many new comers. Infact one can learn the same how it’s applied in Haskell and try that on Elixir too. That would be a good way to learn that problem solving approach.

My experience was a bit different since my first programming language was functional (Scheme). One way to reason about functional solutions to problems is to start by asking: what happens when I loose assignment operators? Also, what happens when we compute with a functional program in comparison with an imperative one?

I used to teach the Programming Language Design Pragmatics course in a CS undergrad some time ago, and moving to functional languages used to cause a bit of a headache at first. Elixir is a wonderful beast one needs to learn progressively how to ride.

While I have been programming in Elixir for only a bit (~6 months), I would be happy to assist virtually if you find it useful.


Please take a step back and read “Programming Elixir” by Dave Thomas. Reading that book helped me unlearn just enough things for me to be able to write Elixir on my own after just a week of reading. I highly recommend it.

Hello, I won’t go into technical details about FP vs. OOP. IMO At the end of the day writing code requires the same mental discipline in any paradigm, even if some can feel more alike to your thinking processes. I never really digested OOP in my 12 y. use of it but found myself at ease with just function, modules and immutability when I encountered Elixir. Anyway the only path I know to learn myself something in a proper way (no just understanding the concepts behind it) is to throw my self in high waters. It scares, I grant it, but I had to decide to develop a quite demanding project for a customer in Elixir/Phoenix, leaving the comfortable Rails ecosystem behind, to really get my hands dirty, face actual real-world problems, learn the things I had to learn to bring the project to conclusion. Sure the code was far from being perfect, but at the end of the day it was good enough, no major bugs or flaws, and with a decent maintainable architecture too. So my simple suggestion is: drop your fears, leave out the impostor syndrome and start building something amazing with Elixir and Phoenix. The development tools and documentation are amazing, the community is awesome, the libraries are everyday better and numerous, so the real block is only in you mind. Do not overthink, start doing it, you’ll be surprised by yourself and the joy of day to day Elixiring. And not last, have lot of fun in the journey!


When I started learning functional programming what helped me was to think everything as input and output. So basically everything is just data processing. Example you have a data then you have a function that transforms that data to something else. Basically everything is just to push your data forward and you can’t change existing values you can just make new ones. Example if you “modify” something in immutable language it doesn’t really modify your data, it just makes a copy with modifications and your previous data stays as it was. So what that means if you want to “modify” something your function needs to return new copy of it. Like a = modify_a(a)

Pure function is a function that always returns same output from same input data. Try to keep many functions as possible pure. Pure functions are also easier to test. If you want to create non pure functions then you need to store/read data outside of your current process example to ets, other processes, database, file system etc.

1 Like

When I started learning the language a year ago, I also had problems understanding how to build projects with Elixir. It took a lot of time and help from a lot of great people for me to reach a level where I feel comfortable building big and complex projects.

So I can give you some inside information that hopefully will help you get comfortable faster.

Here it goes:

  • Erlang and Elixir play in their own completely separate league from other languages. You are going to learn a completely new programming paradigm. Give yourself time and some leeway. You are going to feel like you are back at the university for your first ever programming lesson.

  • Elixir, aside from being a functional language, is also a concurrency-oriented language that uses the actor model as a base to build distributed apps. You need to understand first how all Elixir projects are built and how they are connected before using a framework like Phoenix.

  • Every Elixir project is a tree of processes. The tree starts from the app.ex and every process it spans up will give birth to other processes. You can check the structure by typing :observer.start in the iex.

  • The processes communicate with each other by messages. If you know the pid of the process you can send a message to it. The process can catch this message and act upon the info it contains. In some cases it might be able to respond back.

  • There are mainly two types of processes: workers that execute tasks and supervisors that supervises other processes. Every other type derives from these two.

  • Elixir supports meta-programming. That means it has the ability to create its own language constructs. Many libraries are built around this concept. These libraries provide useful mechanisms that enable to define a lot of logic with simple keywords. Plug is a great example.

Keep this information in your mind as you learn the language and everything will fall into place.