How to learn any programming language in a short time

Updated Apr 06, 2022 ⤳ 9 min read

Learning a programming language is an excellent thing to do these days, but do you know what’s even better than that? Learning how to learn a programming language.

If you understand the concepts programming languages share, you’ll be able to pick up any programming language in no time.

Let’s see what these concepts are.

Language syntax and semantics

Every programming language is described by two elements: Syntax and Semantic.

A computer program is a sequence of words known as symbols.

The syntax of a programming language describes the allowed symbols in that programming language.

Syntax also defines how programmers should combine symbols to compose a valid statement in a program.

For example, the below JavaScript statement consists of four symbols: let, x, =, and 0.


let x = 0

If the programmer uses an invalid symbol, the code won’t run.

For instance, the following statement won’t work because the JavaScript syntax hasn’t defined such an order.


let = x  0

Now, what is Semantic?

Semantic defines the meaning of the symbols in a program. 

On the other hand, semantics describe the behavior of a program when executing a set of valid symbols.

For instance, the following sequence of symbols means that digit “1″ should be added to the value of x:


x = x + 1

When learning a new programming language, you should begin with learning its syntax and semantics.

Control flow

Control flow is the order a computer executes the instructions of a program.

The computer executes the instructions of a program in a top-to-bottom order – starting from the first line to the last line.

But in practice, you often need to change the flow of execution under some conditions.

That said, it’s not always a simple top-to-bottom flow of execution.

For example, you might need to loop through a set of statements a certain number of times or run it under certain conditions.

Programming languages provide a variety of features to enable programmers to change the flow of execution, such as conditional statements (e.g., if/else blocks) and iteration statements (e.g., for and while loops) 

For example, the following JavaScript snippet runs two different statements based on certain conditions:


let x = 0

// If x is 0, increment it by 1, otherwise increment it by 2
if (x === 0) {
    x = x + 1
} else {
    x = x + 2

Based on the above snippet, if the value of x is zero, then x = x + 1 is executed, otherwise, x = x + 2 will be executed.

After learning about syntax and semantics, control flow statements are the next concept you should learn.

Data types

Computer programs constantly work with memory to store and retrieve data at run time.

In the below snippet, we declare a variable named x and assign it a value, 5


let x = 5

The above program stores a piece of data in the memory (RAM) with the numeric value of 5.

For every variable we declare in a program (like x in the example), a piece of data gets stored somewhere in the memory once we run the program.

When you launch a program, the operating system allocates a dedicated area in the memory to that program.

The program’s data reside in that area for as long as the program is running.

Each piece of data in the memory is called a data object

Each data object resides in a memory block with a unique memory address.

Memory addresses are used by the CPU when it’s executing the program’s memory-related instructions (e.g., storing and using variables).

Programming languages associate an attribute to each data object created in the memory. 

This attribute determines two things: 

  • The type of value it holds – a number, a character, etc.)
  • Its storage allocation in the memory (how much memory it needs and how it is stored).

This attribute is called a data type.

Some programming languages require you to explicitly define the data type every time you declare a variable. 

However, some programming languages would guess the data type based on the value you assign to it.

For instance, in the above example, JavaScript would determine the data type of variable x to be an integer because we assigned 5 to it.

Most programming languages support basic primitive data types, such as numeric types (i.e., integers, floating-point numbers, doubles), booleans (true, false), and characters.

There are also Composite Types, which consists of a set of primitive data types.

An example would be arrays or objects in JavaScript.

Type systems

A type system is a compiler feature responsible for checking and enforcing the constraints defined by data types.

In general, the aim is to prevent performing irrelevant operations on data in a computer program.

For example, two text values are not supposed to be divided in a mathematical operation – because it doesn’t make any sense.

The type checking process is either done at compile-time, known as Static Typing, or at the runtime known as Dynamic Typing.

Compile-time is when a program source code gets converted to a runnable (executable) format.

Run time is when the user launches the program. 

If it’s a web page, run time is when the page loads on the user’s web browser.

Some programming languages use a combination of both.

When it comes to type systems, programming languages are either strongly typed or loosely typed.

Strongly-typed languages have a strict type system to guarantee the programmer never makes a data-type-related mistake.

For instance, if you declare a variable named age with the value of 5, JavaScript will determine the data type to be an integer.

What happens if you unintentionally override the value of age with a string?

Since we initialized the age variable with an integer value, JavaScript would complain if we override it with a string value, right?

Wrong! JavaScript won’t care!

You’d only know about this mistake when you see your code is returning strange results – at run time. 

And sometimes, an angry user might report that.

That’s the reason TypeScript was created to fill that gap.

If you want to be aware of every data-related mistake, TypeScript is the language you need.

TypeScript is JavaScript with superpowers.

Although it has to be compiled to JavaScript eventually, it’ll keep your data-related mistakes to almost zero while you’re coding.

Here’s what happens if you make this mistake in TypeScript:

It will react instantly!

Unlike strongly-typed languages, loosely-typed languages aren’t strict about the rules.


In a computer program, a function is a sequence of instructions encapsulated as one reusable unit.

Just like in mathematics, a program function receives parameters and returns a value.

Most programming languages provide hundreds of built-in functions as part of their standard library. 

JavaScript has many built-in functions you can use out of the box.

For instance, in JavaScript, you can round a number to its nearest integer with the Math.round() function.


// The following line will round 5,65 to 6

If the standard library doesn’t have the function you need, You can create your own custom functions.

Additionally, if you find yourself repeating the same set of instructions to calculate a value or do an action, you can encapsulate these instructions into a function that you can reuse later on.

This is an example of a JavaScript function, which checks if a number is even.


// This is our reusable set of instructions
function isEven (number) {
    return number % 2 === 0

// Printing the results to the console

Without a function, you would have to repeat the statement three times like so:


// Printing the results to the console
console.log(1 % 2 === 0)
console.log(2 % 2 === 0)
console.log(5 % 2 === 0)

Disclaimer: This post may contain affiliate links. I might receive a commission if a purchase is made. However, it doesn’t change the cost you’ll pay.