updated 2021/07/04, 30% complete
What programming languages should i learn?
one of the most frequent question i am asked when people know that i was a software developer and had over five years of experience in software engineeering in different fortune 500 companies is ‘what programming languages should i learn‘?
However, a lof of of these people who were trying to learn programming failed. Some of them were overwhelmed and intimadated by the flood of information and countless of options, some couldn’t find the right way of learning programming languages and get lost in those language details such as tiny syntax point or standard librabries.
If you ask me the same question today, my answer would be different: read this article, pick whatever language you want, learn it smartly!
Background on Programming Language
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 language of 2021 are:
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
Learn all programming languages once and for all.
It is a natural repsonse for people to be overwhelmed when they know there are over 700 programming langguages, and withdraw the decision to learn programming. Do all these programming languages have something in common? Can we learn all the programming languages at the same time? Short answer: YES
- 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 any programming language
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
Just as shown above,
2 + 3 is boht an arithmetic and programming expression. So is 2 * 3, 1 + 2 *3
Expression can be a combination of constants, variables, functions, and operators. 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.
variable and typing model
var x = 2 + 1 * 5; x = 19; x = 23;
x is an variable. In a programming language, variables are used to store data values. Just as its name suggests, the value that stores at a variable can change. In the example, the initial value of x is 7, but later we change it to 19, to 23. 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.
A close related concept is typing model.
Basically, variables come with different types becuase values have different types. For instance, from math we know there are different types of numbers: natural numbers, integers, real numbers, rational numbers, complex numbers….. In programming, values come have types, and variables therefore have types because variables are used to store data values.
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 know at compile time, which generally means the type of a variable should be specified by programmer. C, C++, Java are typical static typing languages.
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.
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"
var x = 1; x = "hello world";
function and fuction call
Function is also an fundemental concept in programming and we can find a similar concept in math.
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, code defined the function body can be reused.
Just like function in math, a function in programming usually has the 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(code in 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 it can be as complicated as it wants. Funcation is one of the ways that we organize our code and reuse our code.
flow control and decision constructs
Programming is like setting rules for a machine. Naturally, there are different types of rules. Basically, there are three types of flows in programming to faciliate decision controls: