How to overcome a mental block when learning Erlang?

As you might have guessed, it’s “Learn You Some Erlang”. It takes you by the hand and guides you through the foundations (syntax, types, etc) up to recursion (very important), through functional concepts and concurrency up to everything OTP and beyond.

What I really like about the book is the examples. Every (well, most) chapters are built around a small , self-contained toy project. This way, when you want to (re-)read any chapter, you don’t have to read the chapters before that to understand the example code; you need to know the concepts that were covered in the earlier chapters, but not the examples.

As @Maria-12648430 mentioned, this book was written based on an older OTP version (R16 I think it was, maybe even older), and some things have changed in OTP since then. Maps, introduced in OTP 17, are covered only briefly in a postscript chapter, and gen_fsm has been deprecated and replaced by gen_statem in OTP 19.

At some point (not at the very beginning, mind you), it may also be good to start browsing the Erlang docs instead of solely relying on the book. After all, when you’re finished with the book(s), this is pretty much what you will have to rely on, so better get familiar with it.

3 Likes

Yeah, what @juhlig said :wink:

Personally, I can’t learn anything this way :sweat_smile:
For me, nothing beats books. Preferably real books, printed on real paper :blush:

So I fear I can’t give you any pointers in that regard.

4 Likes

The book “Learn You Some Erlang” as @juhlig mentioned isn’t the best for me at this point, but I am going to give it another go.

2 Likes

I second that.
You do not need apply/3
It’s just confusing now.
There is so much you can so with the basic parts.

4 Likes

Morning. Just a quick question. When you folks were studying Erlang, how did you come up with ideas of problems to solve in relation to your studies. Also, in your current work environment, do you form part of a team and do a part of the solution or do you do the entire thing.

Apologies if this question is vague, because I have the basics fairly well nailed down but cannot think of a problem to solve. It is all very well doing the excercises in the manuals, but coming up with something to solve is rather difficult as most of the problems are solved with other software (Excel, Word, messaging programs, etc etc.).

Thanks folks and have a wonderful day.

2 Likes

It’s a very valid question, and one that I struggled with when first learning Erlang.

  1. I reimplemented part of a codebase I’d currently been working on. Actually, that was a poor idea as it was running before I could walk, requiring learning how to use the mnesia database etc. But I did revisit it later.
  2. Implementing a solution to one of our interview questions. This was actually a good move. I then re-implemented it using OTP.
  3. Various small, standalone examples, as if I was trying to teach someone else. E.g., a state machine for a traffic light (not using OTP) and the simplest possible multi-user “chat” program.

in your current work environment, do you form part of a team and do a part of the solution or do you do the entire thing.

This is doesn’t just apply to Erlang. In very general terms, I’d come up with a concept and run that past others (in a formal or informal way, depending on context). I’d then have an iterative process of adding functionality, refining/reworking the design, fixing the inevitable issues and integrating with other components in the system. In short, if you are working in a team, you can use that to your advantage whether you implementing part of the solution or the entire thing.

3 Likes

Good morning. Firstly, I ask that you please do not laugh at my progress as this is the VERY FIRST time that I did not look at any manuals. I did have to look up the ASCII, but in the spirit of the season:

-module(message).
-export([greeting/0]).
%% To everyone that I know here on the Erlang forum who has been extremely kind, patient and helpful …

greeting() ->
([77, 101, 114, 114, 121 ,32 ,67 ,104 ,114 ,105 ,116 ,109 ,097 ,115]).
7 Likes

Thankyou!

Just to prove that I tried it, I spotted the missing letter :wink:
In the spirit of fixing it via code:

{L1, L2} = lists:split(10, greeting()),
L1 ++ [115 | L2].

PS I still had to look up the lists module (lists:join/2 didn’t do what I immediately expected). It’s always good to keep the docs handy/bookmarked, especially for lists as they are so core to Erlang.

2 Likes

Thanks. could you explain the 10 to me. I am not at a console at the moment.

2 Likes
Eshell V11.1.8 (abort with ^G)
1> Greeting = [77, 101, 114, 114, 121 ,32 ,67 ,104 ,114 ,105 ,116 ,109 ,097 ,115].
"Merry Chritmas"
^^ missing an 's' which is 115
2> {L1, L2} = lists:split(10, Greeting).
{"Merry Chri","tmas"}
^^ Splitting the list at the point of the missing 's'
3> L1 ++ [115 | L2].
"Merry Christmas"
^^ adding the parts back together with the missing 's'
4 Likes

Appreciate it. Will add you code and explanation to my notes. Apologies for the missing ‘s’

2 Likes

No need for apologies!

2 Likes