By July 2, 2018

How to Learn Any Programming Language

As someone with a mechanical engineering background, I do not have formal programming experience.

Several years back, I became interested in making websites and learned to write my first PHP webpage. Although I did not become a prolific programmer (I still outsource most of my development work today), I would consider myself fairly literate when it comes to programming. This has made my job of running a tech business easy, since I can do most of the smaller tweaks myself without having to depend on a programmer.

One of the key lessons I have learned from building websites is that it is possible to learn any programming language all by yourself. What you need are the right resources and techniques.

Through sharing my own experiences, I am going to provide you with a few tips on how you can start learning to code in any programming language on your own.

Understanding the Basics: Starter Pack

Before beginning to learn a new programming language, it's important to have at least a basic understanding of how programming and algorithms work. I was taught to code in C many eons ago in school, and having that basic understanding helped me while learning new languages. If you're already a programmer or developer, then you're all set with a starter pack.

If you have never taken a formal course in programming, the best way to get started is to use free services like Codecademy. I would recommend learning HTML and JavaScript since they are pretty easy to learn and set the foundation for other languages. For instance, with HTML, you could literally compare each line of code with what you see on a webpage to get a clear view of how they impact the look and feel of the page.

It’s worth pointing out that HTML is not technically a programming language; that is, you cannot perform calculations like you can with a traditional language. Along with CSS, this is merely a language to handle the front-end of a webpage. But it does serve as a great starting point, and it’s very important to learn before you build more complex websites with languages like PHP, Ruby on Rails, and Python.

Move on to the next step only after you are proficient enough to write simple scripts in basic languages.

Creating a Microlearning Kit

I am a big believer in microlearning—that is, using flashcards, storyboards, and checklists to create tiny snippets of learning assets.

Microlearning is essentially the use of learning kits no more than three to six minutes in length, and the pedagogical technique has been proven to improve retention among learners.

When learning a programming language, I create a folder or document with separate sections for every new command I encounter. This is what I call my “microlearning kit.” Here, I include all helpful links (from websites like Quora, StackOverflow or other programming-related message boards) I can find on this topic along with my own personal notes.

However, I make sure that the document does not get too lengthy since that defeats the fundamental purpose (which is to create short snippets for quick reference). This way, if I ever encounter the same command again, I can look it up without wasting much time.

Interpreting Real-World Scripts

In my experience, the best way to get comfortable with learning a new language is by looking at existing pieces of code on the internet.

Let’s try learning Python, for instance. I chose this because I have never seen a Python script until now, so I’m going to learn the language as I write this article.

Now, the most helpful place to learn scripts in any language is GitHub. This link provides you with hundreds of scripts written in the Python language.

Your goal to get used to a new language is to pick a random script off one of the repositories on Github and try to make sense of what the code does. From the link above, I came across a script that does face recognition. That’s a pretty complex algorithm to begin learning a language with, but that’s OK.

Clicking through the source files, you’ll find a page named From the file name, it looks like it’s one of the more important pages for the program.learn any programming language

Let’s start by understanding what the script is trying to achieve here. You will notice that the first line of code, which begins with a hash sign (#), is grayed-out. Grayed-out code is generally a comment added to a script, so we can ignore that. In any case, if you weren’t sure whether you can or should ignore that line of code, you could Google it to confirm.

learn any programming language

Yes, we are right in this case. Let’s move on to the next lines.

They read:

from future import print_function
import click
Import os

A lot of modern programming languages have syntax that is extremely easy to understand. From the code above, it looks like this script is trying to make use of scripts written someplace else.

For instance, print_function could be a script to execute printing. By importing it to this code using this line, you can execute the same task without having to type all that code again.

However, __future__ doesn’t make a lot of sense, as we are still learning this language. It could be a database or a folder, but we could be wrong here.

Once you get a fundamental context of the code, you could look up the syntax of from…import on Google to understand what they mean and why they are placed here on this code.

On Quora, I came across this piece of information that tells me what this line of code does in very simple words. Essentially, it is to import a specific variable or functions (print_function in this case) from another module (__function___). I made sure to note this in my microlearning kit.

The next step is to go through every other line in the code to understand its context and what purpose these lines achieve. Practice the same steps as above—if you don’t know the answer, search for it online. Once you identify helpful learning material that explains the syntax, bookmark it in your microlearning kit.

You may go through several other Python scripts not only for this face recognition application, but also other applications hosted on GitHub. Spending a few hours this way should make you quite comfortable with the language and its various commands and syntaxes.

Writing Your Own Applications

Learning a programming language is never complete without knowing how to write your own program from scratch using that language.

Before diving in to write your own application, picking the right programming objective is critical. You may always choose to start with a simple “Hello, World” code, but that does nothing to test your programming skills since all it does is print a line of text.

At the same time, it is important to not spend time working on a very complex application when you’re using a language new to you. Writing one could take several hours, if not days, and is not ideal to test your skills.

The best applications to start with are those that can be written in an hour or two and involve moderate levels of complexity. Simple “examination-grade” topics, like writing a program to sort numbers or printing the Fibonacci sequence, can test your algorithmic and coding skills, which are fundamental in assessing your programming ability.

Work on progressively more complex problems to become an expert programmer in the new language.

Why Traditional Learning Is Not Good Enough

Before we conclude, I should tell you why, from my experience, this method is better than traditional forms of learning a programming language.

There are dozens of highly exhaustive guides for all popular programming languages. The reason I don’t find them good enough is because they teach coding from the ground up. Most books start teaching the learner about writing a “Hello, World” message and take them progressively through the more complex elements of the language.

The trouble with this method is that it takes a lot of time to reach real proficiency. In the strategy I have described above, you start with looking at really complex scripts, and this gives you a better perspective of how the language is used to solve real-world problems.

In case you find the script too complex, you may look up alternate simpler scripts until you find something that is a good start for your comprehension level. Plus, taking notes in a microlearning style will allow you to reflect on it in later instances.

With my strategy, I’ve found that it’s possible to gain a decent level of programming expertise within just one or two days. With Google at your disposal, you no longer have to become a master of syntaxes. Deciphering the algorithm and having a basic understanding of the programming structure is enough for anyone to start writing code in any programming language of their choice.

Using this strategy works effectively for anyone who’s learning a new programming language, as long as they begin with an understanding of the basics.

About the author

Anand Srinivasan

Anand Srinivasan is the founder of Hubbion, a free to use project management tool for startups. Hubbion has been ranked among the top 20 project management tools by Capterra.