Core Similarities of Programming Languages: What Every Programmer Should Know

programming languages

TIOBE is a company that publishes a monthly list of the most popular programming languages. The ratings are based on the number of skilled engineers worldwide, courses, and third-party vendors. Popular search engines such as Bing, Yahoo, Google, Yahoo!, Wikipedia, Amazon, and YouTube calculate the rankings. The TIOBE index does not rank the best programming languages or the languages in which the most lines of code have been written. Instead, this index can be used periodically to decide what programming languages to use in a new project, or on an individual level, to decide which programming languages to learn.

If you are a newbie in computer software and have decided to learn a new programming language, you can use the latest TIOBE index to make that decision. It will also help you to know that there are many common features in all these programming languages. In this post, we will discuss those common features.

What is the Purpose of A Programming Language?
Every programming language, or program code, has one goal: to give instructions to the computer hardware. Computer hardware implies electronic circuits. Electronic circuits do not understand our instructions directly, except in the binary language of 1s and 0s, which is called machine language. And as you may have seen, Machine Language has not figured on list of the top 10 or 20 programming languages for decades now. That is because machine language is a “low-level language” – easy for the computer hardware to understand, but almost impossible for humans to code in. That means, we must learn the other programming languages such as Python, C, C++, C#, Java, JavaScipt, etc and these programming languages are called “high-level programming languages”. High level programming languages are easy for us to learn, code, read, modify. All instructions (or programs) that we write in high level languages must be converted into the low-level language i.e., the machine code. So every programming language uses a translator or compiler or interpreter which does this conversion. Compilers and interpreters do much more and we will discuss that in another post.

Why so many Programming Languages?
We use computers to solve different types of problems. These problems may be simple calculations, graphics processing, video editing, communicating with another device, updating databases, controlling machines, playing music, controlling a robot on the surface of Mars, or steering a spacecraft through the dark, unknown interiors of the solar system and beyond as in the case of Voyager. All these tasks are diverse and hence require different techniques to solve the problem. This is the reason why there are so many programming languages. In earlier days of computing, COBOL (COmmon Business Oriented Language) was popular for business processing while FORTRAN (FORmula TRANslation) was popular for scientific applications and number crunching. We now have many general-purpose languages, such as Python. But for many applications, such as IoT, C and C++ are preferred. Therefore, the reason we have so many programming languages is that we have so many different types of problems to solve from so many domains. Some problems may require intensive calculations, while others may require the hardware to respond to commands in real time.

Structure of A Program:
Every programming language has a structure, a way of writing the code or statements. A common structure is the one used by the C family of languages and this structure is called the block structure. The C family of languages is the set of languages that have many similarities with C; these languages are C++, C#, and Java. Python and JavaScript have few features in common with C. A block of code is enclosed in the parenthesis { and }. The parenthesis are very useful to group a set of statements that form a group of commands to be executed. Each statement ends with the semi-colon (;). The semi-colon indicates the end of a statement or a command.

Variable Declaration and Initialisation:
Every programming language will contain a number of variables. In these variables, we can store whatever data we want – numbers, names, special symbols, etc. By declaring variables we are informing the computer as to how much space in memory (RAM-Random Access Memory) we need, what type of data we will store. Declaring a variable has many implications but some of these are – giving an address / location to the variable, storing and retrieving data from this location, deciding on what can be stored in the location and for how long it can be stored. There are minor differences in the way programming languages deal with variable declaration, but the purpose is the same. So in C and C++, if we want to store only integer data in a variable, we may declare it as int total; Here int is the data type (the type of data that you want to store – integer, floating point, string, character, etc) and the name of the variable is total. But in Python even this declaration is not essential and Python will give approriate data type to the variable when you store a value in that variable.

Data Types:
We can manipulate different types of data through a computer program. This data may be integers like +2, -7 or whole numbers like 389, floating-point numbers like 3.142, character data like ‘P’, etc. Different types of data require a different amount of storage in the computer’s primary memory or the RAM. It is therefore important to create variables of appropriate data types. Commonly available data types are int (integer data like -7, +3, etc), float (like 3.142, 2.00), char (character data like ‘P’ – a single character), string data like “Calculus” (many characters stored sequentially), boolean data (like True or False), and Currency data type in Visual Basic. Python supports the complex data type to store complex numbers of the form a + ib.

Data Structures:
Data structures form the core of all modern programming. It will be extremely difficult, if not impossible, to write useful programs without using data structures. So what is a data structure? A data structure is just a collection of data, structured in a particular way. Think of a data structure like a building or a structure made out of bricks. All bricks are cubic, yet we can have buildings of different sizes and shapes made out of the same basic cubic brick. So a data structure defines how data is stored in memory, how it is retrieved from memory, and how it is processed.

Some commonly used data structures are array, linked list, queue, tree, and graph. An array is a collection of data in rows and columns. In an array, in C and C++, the restriction is that all elements of the array must be of the same data type (e.g., all integers) and they must occupy successive memory locations. The address of the first element of the array and the data type of the elements – both are used to get the addresses and values of all other elements of the array. In another, more flexible data structure, the linked list, data items can be randomly stored and scattered in the primary memory. Every data item is stored in a free location and the address of the next element is stored along with the previous element’s data. This way, we can “link” a “list” of elements – the linking is achieved through the addresses of successive elements attached to the data of the previous element.

Programming languages like C, C++, C#, and Java support arrays, C# supports “jagged” arrays – different rows can contain a different number of elements thereby optimising the use of memory. C also has a data structure called, predictably, “structure”. This data structure is used to group data of different types together. This is similar to the concept of a record in database management systems. So, in a structure, you can store an employee’s name, department, salary, date of joining, etc. All these are of different data types. Python supports a very wide variety of data structures such as list, dictionary, tuple, set, string, and linked list, among others.

The theory and logic of all these data structures are almost similar. What varies among programming languages is syntax. So mastering data structures in any one language will help in other languages as well.

Flow Control:
Computers obey instructions or commands in the order in which we specify them. The most obvious way is that the computer will carry out commands one after the other, linearly. This type of linear (unidirectional) processing is seldom useful. All programming languages provide ways to break or change the linear sequence. So, for example, a statement or a block of statements may or may not be executed depending on the value of a condition. If a condition is true, execute the block, else skip the block. Commonly available statements that direct flow control is the if statement, if-else statement, switch – case statement.

Looping Statements:
Computers are very efficient at repeating a set of instructions, very quickly. To repeat a set of statements, all programming languages provide looping statements. These statements control how many times a set of statements will be executed, when will execution of this loop stop, and what happens inside the body of the loop. Commonly available looping statements in almost all programming languages are the for statement, the while statement, and the do-while statement.

Operators and Operations:
Operators define what can be done on data. E.g., when we write a + b, the + sign is the operator. Operators are predefined in programming languages. Some programming languages permit an operator to take on a bigger role through the feature of “operator overloading”.

Operators can be of different types and those available commonly are:
1. Arithmetic operators(+, -, *, / , ^ or ** , % and \ )
2. Relational operators (<, <=, >, >=, ==, != or <>)
3. Assignment operators (=, +=, -=, *=, /=, etc)
4. Logical Operators (AND, OR, NOT )
5. Bitwise operators (to manipulate the individual bits of a number) (^, ! and ~ )

Programming Styles:
Functional programming and object-oriented programming are the two main approaches. In functional programming, the key principle is the execution of a series of mathematical functions. The function is meant for performing some specific computation. Data are loosely coupled to functions. The function hides its implementation from the rest of the program. A function must be called (invoked) to execute its code.

Object-oriented programming is the approach followed by Java, C++, and C#. The object is the unit that is dealt with. A class is a collection of data and the functions that can operate on that data. This prevents data from being modified by unwanted functions. An object is the equivalent of a real-world entity. So a box would be implemented as an object which has three variables to represent the length, width, and height of a box). The main concepts of OOPs viz, P (Polymorphism), I (Inheritance), E (Encapsulations), and A (Abstraction) are common to all modern programming languages.

So there you have it. No matter which programming language you plan to learn, they all have a lot in common. Once you have mastered these concepts in one programming language, they will be very easy to understand and implement in other languages. What sets these languages apart from each other is their syntax – the way programs are written. So while a semicolon (;) is mandatory in C, C++, Java, and C#, it is optional in Python. Python creates blocks using spaces while other languages rely on parenthesis. The syntax may differ but the semantics of these various features is the same. Semantics is concerned with the “meaning” of the statement, while “syntax” is concerned with the grammar of the statement. Master the semantics and the syntax can be easily looked up.

Hope this motivates you to learn more than one programming language. Use the TIOBE index to pick up one language and then learn another in the same family of languages.

Happy learning!

Related Posts:

Is it easier to learn other coding languages (like Java, C, C#, C++, Python, etc.) if you know HTML?

What is the order of learning coding (programming) languages?

What is Computer Science?

Advertisements


Categories: Blog, C Programming, C++ Programming, Computer Science, Java, Programming, Python Programming

Tags: , , , , , , , , ,

4 replies

Trackbacks

  1. Are C and C++ Important? – SciTechGen.Com
  2. Can A Commerce Student Learn Python? – SciTechGen.Com
  3. How can I learn programming languages and which programming language should I start with? – SciTechGen.Com
  4. Why is it important to understand the basics of a programming language? – SciTechGen.Com

Leave a Reply

%d