How to overcome a mental block when learning Erlang?

Hi folks. All of you are way more experience than what I am. I am still busy studying Erlang and I love it. the syntax is crazy but I love and somehow understand it. Now I have a weird issue. This morning I looked at the small modules that I had done from the programming books and I suddenly had a “sort of realization” that I have no idea what I am doing and reading through the code, I could not understand anything.

Does this mean that I am not cut out to be a Erlang programmer or is this just some “bump in the road” and if so, how did you folks (if you had these moments) overcome this. Do I need to take a break for a few hours / day?

Thanks,
Dmitri

4 Likes

I guess something like this is to be expected in the early days of picking up something new, don’t let it dishearten you :wink: You have to juggle a lot of (more or less new) things in mind at the beginning after all, but they will become natural with time and you won’t have to think about them any more, so can focus more on what you are trying to do instead of how to do each little step.

My advice would be to take some time off, do something entirely different for a day or two (just a few hours might not be enough, depends). Let things settle down in your mind by themselves. If, after that, you find that you still can’t understand what you did, start it again from a blank slate.

7 Likes

I can only guess that it is just a bump in the road.

Maybe try explaining the incomprehensible module to someone, maybe here. Then some clearer question may emerge, that you today need to get clarified to yourself…

6 Likes

@DmitriDumas Ah, right, that’s important, too: make sure you really understand the question/problem :wink:

3 Likes

Thanks folks. I am really cramming all this into my head. I will take the rest of today off and try again tomorrow morning. Appreciate your input.

Have a great day
D

3 Likes

Join Erlang slack and go to #learning channel. Very friendly community and many people that will help you.

3 Likes

Hm, IMO you should avoid cramming.

When it comes to learning something new, think of your mind as a piece of lawn where many people walk about without directions. They all have their purpose, some may have an idea about where they should be going, some might even know their way there. But most of them just walk about and get in the way of each other, all the time trodding down the grass. No paths will emerge, just a muddy mess that is getting messier by the minute.

Instead, give it a little rest once in a while, take it easier, let some grass grow back, let fewer people walk about, and mostly those who already know where to go, and only a few who have yet to find their way, then a few more, and so on.

After a while, you will end up with a nice network of paths across the lawn. Now pave some, put up sign posts, warning signs where appropriate, etcetc. You can take the analogy further from here :wink:

That takes time, yes, you can’t rush it. But if you “cram”, you will probably end up with nothing but the confused muddy mess, I think.

7 Likes

The flow killer always related to some question of “me” (am I cut out to be this).
The flow trigger is outside of me, it’s Erlang, incredibly interesting stuff.

Great to see you learn Erlang!

3 Likes

If I’m stuck on something, I usually do something completely different for a while, this might be going outside for running, do some handycraft, taking a shower…
Often I have the best idea on how to solve something when not thinking about it :smiley:

5 Likes

I like this analogy. Will take a break from it and then just concentrate on a chapter over a day or so.

2 Likes

Great idea. Tomorrow, I will take my bike for a ride for a couple of hours. Get some fresh air and try to relax.

4 Likes

Hey, Dmitri!

I’m a beginner, too, and have been learning Erlang longer than you. I still regularly deal with these mental blocks. It’s perfectly natural when you’re trying to process so much new information that requires you to think differently than with other languages you’ve used in the past. I’ve been working through exercises on the site Exercism.org. I’ve gotten to the point where some of the problems are simple, but others that are supposed to be easy sometimes completely mess with my brain and I can’t figure them out. When that happens, I ask for help on the Erlang Slack, on the #learning channel. Come join us!

2 Likes

I completely agree Maria! In fact I specifically mentioned something like this in a blog post - to not be afraid to take a step back or to re-read chapters - it is completely normal, just go back a step or two whenever you’re feeling a little lost Dmitri :023:

3 Likes

Thanks. I took a ride yesterday to clear my head. This morning I opened up my editor and glanced at some of the modules that I did. It is still murky. It could also be external stress that is causing this issue. I think that I am struggling to see how Erlang gets used in OTP. I know that that sounds weird but somewhere along the line, I missed the “bridge” connecting the two. (If that makes sense).

I will just keep on plodding on :slight_smile: :sweat_smile:

3 Likes

Don’t worry, that’s also a normal reaction in the early stages of learning OTP, which poses sort of an extra (mental) layer on top of Erlang itself :wink: But the feeling of “OMG, how will I ever understand this? :scream:” will turn into “OMG, how could I ever live without it? :heart_eyes:” as you get more comfortable over time.

7 Likes

The jump from learning Erlang syntax to understanding OTP is really big one and taken too early might be daunting. Perhaps consider reducing expectations you put on yourself today - that is focus on having something that works without understanding why - take a note of questions/doubts you have and come back to them later.

When you feel ready to formulate an exact problem - ask a question in a place like this forum.

You can also check my other post, which is maybe related.

5 Likes

I’m a decent programmer. And there are some languages I’ve decades of professional experience with. But you know what: sometimes I look at code I’ve written only days ago and I’m in the same position as you were (“WTH is this? What does it do? Who wrote that rubbish?”)

I think most of the time the problem is (at least) one of:

  • a chunk of code I try to understand is too big - its not well structured
  • bad naming. I was lazy and did not take time to name stuff right.
  • no names at all, just functions that call functions
  • no tests
  • clever code

So what I try to do to keep these WTH-moments at minimum, is: take my time to write code, that does not make my future-self hate me.

6 Likes

What I do is overdo the comments in the code. As I am only using my personal laptop to learn, I print out all the modules that I have done. Having the comments on top helps me remember what I did. Maybe I should get into the habit of writing docs to be viewed on HTML on my browser, but I prefer reading from good old fashioned paper :slight_smile:

3 Likes

Comments (like naming things) are a difficult thing to do right.

See this nice writeup: Putting comments in code: the good, the bad, and the ugly.

I think, for you as the developer of the code, comments should not be the thing you read first when you try to understand your code. That’s for people using your code (if you write a lib for example). Your starting point should be the code. And this code should be as clear as possible, Sasa Juric did a great talk on this topic: Clarity | Saša Jurić | ElixirConf EU 2021 - YouTube

This does not mean that you should not write comments for yourself. You should, but the ones important for you are the “Clarification comments” (as in the article above) - I’d like to add “missing clarification comments” to my list above.

But the most important comments for you as a developer in my opinion are are good names, but …

There are only two hard things in Computer Science: cache invalidation and naming things.

– Phil Karlton

3 Likes

Hey man :slight_smile: Sorry Im late to the party but I just wanted to echo everyone who said, take a break! My approach to learning erlang (which im still learning) was to charge through the learn you some erlang book. I greedily soaked up chapter after chapter, and somewhere mid gen_whadjamakallit I realized I was getting lost. So I stopped, and looked for non OTP problems to solve in basic erlang to just train those muscles instead. I found the advent of code problems and exercism (and the erlang koans). Doing that let me keep compacting my confidence in the actual language, not the frameworks and soon enough I was fresh and ready for the OTP stuff.

5 Likes