How Do YOU Learn a New Programming Language?

No alt text provided for this image

How do you learn a new programming language? In this article, I’ve dissected my first hour of learning Python. To me, goal setting, and generating my own language guides have always worked, and I describe the process here. I also tackle the next steps, while making references to what cognitive psychology teaches us about learning.

I’m writing this article because I’m really interested in metacognitive processes and learning, and I’d like to know how others learn. The background is this: I need to learn Python for my new job, and being a parent of three children, I must do it in as little time as possible. In addition, I want to spell it out to myself how I actually go about learning a new programming language. So, without further ado, I’ll describe the procedure I followed during the first hour of learning Python along with all details and rationale. Here it goes:

Setting a Learning Goal

First, I chose a goal; what did I want to achieve in one hour? Learn everything there’s to know about Python? Too ambitious. Follow a tutorial? Too boring. I decided on trying to write a piece of one of those old text-based games where you walk around on a map, pick things up, and fight monsters. This would be doable in one hour and would teach me the basic control structures and something about variables and functions. Good enough. Now, this kind of goal setting is kind of important. According to Locke's goal setting theory of motivation, I’d perform better, having this clear goal, than if I had set a vague goal. Now there’s more to this theory than that, but in this context it’s enough to say that clear and somewhat challenging goal have always helped me learn languages or frameworks. Historically, it’s been particularly important that I cared about what I produced. And for this short session, producing a basis for a MUD or just text adventure felt compelling enough.

Getting an Overview

Next, I skimmed through a Python tutorial for 2-3 minutes. I noted down things that I found interesting. In this case, pass and lambda caught my attention. I wrote those down. I then googled ‘python user input’ and started off with a program like this:

user_input = input(">")

print (user_input)

I was half done 😊

Writing Code

Then started implementing my map walking functionality while googling constructs as I needed them. I needed to look up the following:

  • python check empty string
  • python compare strings
  • python do while loop
  • python arrays
  • python dictionaries
  • python array size
  • python functions
  • python tuple
  • python lambda
  • python global variables

Google took me to either Stack Overflow or some tutorial; I didn’t care, since I was after a solution not the best solution. While writing the code, I strived to try things out, rather to get the best and cleanest code. For example, I tried to use tuples (dead end) and I made uses of global variables. While this is horrible, it gave me a chance to try out Python’s rather distinctive take on scoping. Going with lambdas early also proved fruitful. To sum this up, I coded with a goal while maximizing exposure to things I found particularly Python-specific or having an interesting twist in Python. Ergo: to maximize learning.

Keeping Notes

While doing the above, I also noted down some things creating a “language guide”. At the end of the session this guide contained six paragraphs that described Python-specific syntax or interesting things. By interesting, I mean constructs that differ from other language. For example, I put tuple in my notes. Very few languages have this notion built in at the core language level. That’s interesting.

There’s a theoretical aspect to this too. Next to practice testing, generating your own content is one of the most powerful techniques for learning things, or so cognitive psychology tells us any way.

Results

After roughly one hour, I had my little maze and I could walk around in it. User input was somewhat error handled and I had tried out basic control structures, some data types, and some things that I found more specific to Python. Learning goal achieved.

Next steps

OK. Writing something that reads a string and writes things to the console seems a little puny. What steps will I take next? Here’s the plan, along with the rationale. I expect to spend no more than one hour on each step (except for step 5), maybe less.

1.      Read the PEP 8 style guide: No point in learning a new language and start with bad habits

2.      Learn what OOP looks like in Python: That’s the paradigm we use most of the time

3.      Learn a unit testing framework: As an author of a book on software quality I don’t have a choice. Having said that, unit testing is a critical core practice, and bringing in a framework will also expose me to dependency management.

4.      Do something with REST: While not very glamorous, much programming these days involves providing or consuming REST services. That’s just the way it is. This step connects the learning experience to reality.

5.      Read a book! This is critical in my mind. Programming by Stack Overflow works for experienced software engineers, but it’s still precision bombing. By reading a book (250+ pages) you get the breadth of the language along with some depth. Otherwise, your knowledge is uneven and fragmented. Chances are that your brain will lack an underlying structure to attach all those concepts to. Cognitive psychology teaches us that organizing information into trees or similar constructs supports learning. I find books to be helpful here, but I guess there are options.

Meta Meta

By writing this article, I created content on the importance of goal setting, practice testing, content creation, and information organization, and their effect on learning 😉

To view or add a comment, sign in

More articles by Alexander Tarlinder

  • 13 Hobby Projects And Why They Matter

    A while ago, I read an article about software hobby projects you MUST have tried at home. It was a disappointment…

  • Looking back at 25 Years in the Industry

    After having been doing something for 25 years, one has seen and experienced a thing or two. I love telling war stories…

  • Att studera mitt i livet

    Det senaste året har jag gjort det politikerna vill att man ska göra: utbildat mig mitt i livet för att möta ändrade…

    14 Comments
  • Erfarenheter av första IT-chefsjobbet

    Efter dryga två och ett halvt år som IT-chef på ILT Inläsningstjänst går jag på föräldraledighet och avslutar min…

    16 Comments

Others also viewed

Explore content categories