coding, programming

How to learn all programming languages once and for all?

updated 2021/08/29,  50% complete

What programming languages should i learn?

One of the most frequent question asked when people know that i was a software engineer for over five years in different fortune 500 companies is ‘I have alway been wanting to learn coding, but i don’t know what programming languages should i learn‘?

My answer would always be ‘well, that depents on what you want to achieve through learning programming and programming.’ Then i would recommend one programming language based people’s objectives and expentations. For example, if people want to do data analytics or want a data analytics job, i would suggest Python. I would recommend Java for enterprise application and Andriod App development, C/C++ for system development and lower-level development, JavaScript for WEB developement, Swift for IOS APP development….,etc.

However, a lof of of these people who tried to learn coding failed. Some of them were overwhelmed and intimadated by the flood of information and countless of options.. Some just couldn’t find the right way of learning and lost in those technical details such as syntactic sugar or standard librabries implementaions.

If you ask me the same question today, my answer would be different:

read this article, pick whatever language you like, learn it smartly!

Background on Programming Languages

There are now over 700 different programming languages, including esoteric coding languages.

This wiki page lists some common languages. TIOBE publishes a list of top languages every year, and the top languages of 2021 are:

How to learn all programming languages once and for all? 1

C, Python, Java, C++, C#, Visual Basic, JavaScript, PHP, Assemble language are the top 10 languages of 2021.

C has been the top 1 language for many years, no wonder a lof of industry experts would recommend C as the first language to learn, which i definitely agree since C is a well-designed language and doesn’t have much flaws in its core concepts. C is so powerful and is choosen in written operating systems like Linux and Windows which is one of the most difficult and challenging tasks a programming language can ever imagined to resolve.

Learn all programming languages once and for all.

It is a natural repsonse of people to be overwhelmed when they know there are over 700 programming langguages, and withdraw the decision to learn coding.

As a professional sofrware developer with hands-on experience in multiple languages such as C, C++, Java, Python, Javascript, C#, I can say with confidence that it’s natural and quite common for engineers to work with multiple different languages. How can professional engineers master so many different coding languages? What can we learn from this fact?

Well, the answer is qutie straightfoward: different programming languages have something in common.

Most programming languages share similar concepts of programming and we can learn all the programming languages once for all if we can master these core concepts of coding.

Based on this idea of learning core concepts of programming, i come out with the following approach to learning coding:

  • understand core comcepts and features of a programming language and omit minor detilas in the begining
  • learn a programming language in an interactive way
  • develop and hone programming skills in real projects

Core concepts of programming

Expression and evaluation

By definition, an expression is an syntactic entity in a programming language that may be evaluated to determine its value. It’s a both an mathmatic and programming concept.

2 + 3
2 * 3
1 + 2 * 3

As shown above, 2 + 3 is boht an arithmetic and programming expression. So are 2 * 3, 1 + 2 *3 .

Expression can be a combination of constants, variables, functions, and operators which are all basic building blocks in programming and mathmatics. We will introduce these concepts in the article later.

To get started, we can understand expresseion as any combinations of basic elements in a programming langauges such as numbers, strings, operators…,etc.

An related concept in programming is statement, which is a syntactic entity that expresss some action to be carried out. A statement has no value, it’s just an instruction for the computer. A statement may have internal components(e.g. expressions). Typical statements include assignments, subrountine calls, assertions, input and output…etc. Flow control is also achieved via statements.

Variables and typing model

First, let us look at the following line of code in JavaScript:

var x =  2 + 1 * 5;

x = 19;

x = 23;

x is a variable. In a programming language, variables are used to store data values. Just as the name suggests, the value that stores at a variable can vary. In the example, the initial value of x is 7, but later we change it to 19 and to 23 again. Actually, we can change it to any value we like. That’s why it’s called a variable.

Variable is a fundenmental concept that can be found in almost any programming languages. It’s also a mathmatic concept as well.

A close related concept is typing model. We have different types of values(numbers, strings….) which naturally requires the programming languages have different types of variable to store them. For instance, from math we know there are different types of numbers: natural numbers, integers, real numbers, rational numbers, complex numbers….. and programming languages will need different types of variables to store them accordingly.

Here are some bacis types in Python:

  • numeric types: int, float, complex
  • text sequence type: str
  • sequence types: list, tuple, range

The typing model of a programming language is how the language handles types. Typing models have different categories, but mainly there are two: static typing vs dynamic typing, strong typing vs weak typing.

Static typing means that the type of a variable is known at compile time, which generally means the type of a variable should be specified by the programmer. C, C++, Java are typical static typing languages.

A language is dynamically typed if type is associated with run-time values. Examples are Python and JavaScript.

Generally, static typing means variables have types whereas values have types for dynamic typing languages.

Stong typing and weak typing don’t have precise definition and would not be discussed in this article.

The typing model of a programming language impacts how variables should be defined and used, whether and how type conversions should be conducted, and so on. Therefore it’s crucial to figure out the typing system of a programming language.

Let’s comsider a simple example of C, Java, Python, JavaScript:

    int x = 1;
    x = 'hello world';

Result: error: invalid conversion from ‘const char*’ to ‘int’

   int x = 1;
   x = "hello world";

Result: error: incompatible types: String cannot be converted to int

x = 1
x = "hello world"

Result: works

var x = 1;
x = "hello world";

Result: works

As shown in examples above, C and Java are static typing languages and would generally return error when yoy misuse the type of a variable while Python and Javascript are dynamic typing languages offering great level of flexibility.

Functions and fuction calls

Function is also an fundemental concept in programming and we can find the similar concept in mathmatics.

y = f(x)
  = x*x + 3*x + 1

A function represents a computational process that generates outcome(s) with given inputs. Function is also a way of organize code into reuseable pieces. A function can be used(or called in programming) anytimes once it’s defined; therefore, reusing of pieces of code can be achieved with functions.

Just like function in math, a function in programming usually has same elements:

  • function name( f in the example)
  • functian input/parameters(x in the example)
  • function body ( x*x + 3*x +1 in the example)
  • fucntion output/return value(y in the example)

To express the previous math function in Python:

def f(x):
    y = x*x + 3*x + 1
    return y

When we give an input(parameter) to the function, the fucntion genreates a output based on the rules we defined(function body). This process is a function call.

z = f(3)

In this case, z is 19( 3 *3 + 3*3 + 1)

Function can be as simple as the example above and can be as complicated as it wants. However, readability is also a key point to keep in mind when coding becuase the code we write is both for machines to interprete and for humans to read. Readability is an issue we will dive a little bit deeper in the future.

Funcation is one of the ways that we organize our code and reuse our code.

Control structures

Programming is like setting rules for a machine.

When rules get become complicated, we need a mechanism to control the flow of our logic.

Basically, there are three types of flows in programming to faciliate decision constructs:

  • sequence
  • choice/selection
  • iteration/repetition

Sequence

Sequence means the code will be executed in a sequential ordre from top to bottom.

The ordered sequencing of successive commands is considered one of the basic control structures in programming.

Choice

Iteration

Core data structure

Object-Oriendted Pogramming

Functional programming

References

Leave a Comment

Your email address will not be published. Required fields are marked *