How to overcome a mental block when learning Erlang?

Joe Armstrong summed up commenting just great in this talk, which includes one of my favourite quotes of all time: “Robert […] who developed Erlang with me […] was famed for his comment. Yes, singular.” :laughing:

9 Likes

This is just programming. I have been programming in various languages for 30 years and I still feel this way if I have been away from a piece of code for any length of time. There are too many variables, modules, libraries, data structure and design decisions, etc. to remember if you are not actively “in the flow” with a piece of code.

3 Likes

A lot of people have left good advice. It’s not clear if you’re just reading code or writing code, but in case you’re not writing code, that’s what I would suggest is missing :slight_smile: Write more code!

Some of us learn best by doing and perhaps you’re one of those types.

6 Likes

Write more code!

I agree 100%. I’d encourage you to find a medium sized personal project and poke away at it from start to finish. Books are great but nothing’s going to solidify the knowledge as much as making it personal. It’ll also get you familiar with the documentation and tooling which are essential.

4 Likes

At this time of year I can highly recommend using Erlang to participate in Advent of Code which starts on December 1st. It will give you a daily puzzle to solve programatically and can be a great resource for learning the core of the language and data structures.

By discussing the solutions with other members of the community, you can learn a lot by comparing your solution to others. Here is an example from last years event in the Elixir forum.

7 Likes

Take a time off and go do something else for days until Erlang is no longer running in the background of the mind, then come back. At least this worked for me as a dev from php/ c# background. I used it to understand concepts like behaviors, maps, atoms, records, module mailbox etc.

Another challenge to me has been reading erlang source code. Seeing variables named like T, X etc… from and background where a variable is named what it actual contains.

Hope this helps.

2 Likes

If you’re having trouble following the code due to variable naming I recommend you take a look around to try to find some other, more readable examples - this isn’t a general Erlang thing, you probably just found some bad examples (and we have all fallen into the convenience trap before and written code like this). Maybe a list of links to “good examples of well-written Erlang” in the OTP source code would be a useful thing for learners?

The rule of thumb that the variable name length should be proportional to its scope is as true in Erlang as in any other language. The X in [eat(X) || X <- Fruits] should hopefully not be tripping anybody up since the scope of X is just one expression. But if eat/1 is twenty lines long, well-written code would call its argument Fruit, not X.

You have a point with T for tail, but I guess that’s just one of those things you have to get used to. If the function isn’t trivial I like to call the tail Rest instead.

4 Likes

Thanks folks. I have taken a few days off and am going to open up the editor and go through the code that I have written. The main reason that I am learning Erlang is basically this:

I live in a small town which is in the heart of the Western Cape, South Africa. This is the winelands and there are many wine and olive farms here. What I am wanting to (hopefully) create an online protal where the farmers can contact each other in an emergency. (We have a serious crime problem due to the collapsing economy).

I am NOT looking for another whatsapp etc application. It is pretty much a push notification where if there is a medical / security issue, the farmer presses the appropriate button and the message gets sent to his neighbours - be it medical etc. The reason for that is that the telephone system (landline) has pretty much collapsed.

There are these applications available but they are expensive as they are foreign currency and are difficult to implement here.

Am I shooting myself in the foot with Erlang (I love it and do not want to go with Elixir, python etc). I suppose I could say that Erlang is like my favourite cup of coffee. You get coffee and you get COFFEE and Erlang is my COFFEE.

Apologies if this post is not very clear.

Regards,
Dmitri

3 Likes

One thing to consider. I don’t know your background/experience, but the typical newcomer from OO land is going to have to learn many layers and layers of abstractions. The language itself is simple and elegant (mostly). But if you don’t know FP there’s that. Then concurrent programming. Then distributed concurrent programming. Then fault tolerant (hint: OTP) programming, etc. So you’re not going to get it all right away, and that’s fine. It all builds on itself. Keep at it. Have fun.

3 Likes

Well, this is my first attempt at learning coding and I am in my mid 50s. I looked at python but that did not grab my fancy. I also looked at Elixir and the same thing. Then I looked at Erlang and “BOOM”. It just resonated with me - even before I had installed it. I then did the install and wrote my first "Hello World! (Yeah, I know) and I just fell in love. I just cannot explain it.

5 Likes

I wonder, how is that supposed to work then? I mean, you may be able to create the most reliable buttons, broadcasting service, and alarm devices that ever existed with Erlang, but… how are they supposed to talk to each other if there is nothing connecting them?

2 Likes

It will be done via Wifi. Our landline telephone system has not been updated for around 6 years now. Private companies are piling in money for wifi infrastructure.

2 Likes

Good morning. I has been just under 2 weeks since my previous post. I have now reached a point where I need to make a decision whether to carry on or try to find an alternative language. The reason is that I just cannot get to gribs with the syntax. I have taken a few breaks and come back to the code, but still I just cannot wrap my head around the syntax.

A friend recommended that I look at Haskell, which I did. There is a book that was given to me called
“haskell programming from first principles.” I also did quite a bit of googling to see if there are any examples of companies who are using it as a “communications platform” for what I am trying to do (as previously posted). I cannot find anything.

Elixir (as previously posted) just did not grab my attention , neither did python). For some unknown inexplicable reason, I love Erlang. Am I in an unattainable position (relationship with Erlang :slight_smile: )

Your thoughts and suggestions would be much appreciated.

Have a fantastic day.
Dmitri

2 Likes

:flushed: This is one of the hardest languages to learn. Very theoretical language. You need a math background for that.

See great talks of P. Wadler:

If you are into this, go on.

3 Likes

I had a lookthrough of the first few chapters detailing Functional programming basics which I enjoyed. I then browsed through a few pages later on and I put it down. I did maths in the '80s in high school o.O

In your professional opinion what would you suggest. Is there any book that lays out the syntax for Erlang. All the books that I am reading (and then typing in) do not really explain the sytax sequence (If that is the correct term)

2 Likes

I had quite some struggles with haskell when forced to learn it during university.
Erlang was rather easy in comparison, but this might also be due to 10 years of programming experience between :stuck_out_tongue:

Did you read Joe Armstrongs “Programming Erlang”?
I havn’t had big syntax issues when learning with this book.

2 Likes

What’s the problem, it’s just a bunch of monoids in the category of endofunctors. :face_with_raised_eyebrow: Haskell is great as an exercise in truly and purely functional programming. It can be, and is, used in the industry. But it’s not a pragmatic language (by design). If you want to just get something up and running, especially a platform such as the one you’ve described, Erlang would achieve it much faster. Haskell’s documentation assumes you’ve got a background in abstract algebra.

Maybe the way to go is to ask, here or on Slack for example, whenever you find something concrete that you cannot figure out. I think plenty of people would be happy to explain why it looks like it does, and what it means.

3 Likes

Thanks. I will check that book out. Does he explain the syntax in detail or do you have to figure it out as you go along. Our currency is weak against the US dollar so I do not want to fork out some money if it is not going to help.

2 Likes

Right there I need a thesaurus :slight_smile: :grin:

3 Likes

It’s a well known quote in FP, to explain how “simple” monads are :slight_smile:

3 Likes