Fundamental concepts of every programming language

·

10 min read

In order to learn and master a programming language, it is important that a person understand a few basic concepts about the programming language.

Irrespective of the programming language that you choose to learn, these basic concepts are important and must be understood.

So, for the purpose of this article I am going to take you through these basic concepts giving relevant examples of each in three different languages (Java, python and JavaScript). So, in this article you are going to learn:

Outline

i) IDEs and Programming environment

ii) Variable declaration

iii) Basic Syntax

iv) Data Types and Structure

v) Flow and Control Structures

vi) Functions

vii) Object Oriented Programming (OOP)

viii) Debugging

IDEs and Programming environment

The first item on our list are IDEs, this is because in order to start writing any codes you need an IDE that would be able to compile or interpret your code into the low-level language that the computer can understand.

IDE is a short form of Integrated Development Environment. IDEs are essential in programming as they bring a lot of features that can help the programmer increase efficiency and speed, some of these features includes, Editing source code, syntax highlighting, autocomplete, building executables and Debugging.

We will talk about these amazing features shortly but first there are so many IDEs that can be used by programmers, we have Atom, visual studio code (or VS code), sublime text, code blocks, Eclipse, NetBeans etc.

There are a bunch of them some were built for running multiple type of high-level language program, while some like pycham were built for just a particular language.

For the sake of this article I will make use of visual Studio code and code blocks, because to my opinions these IDEs are the best when it comes to scalability and productivity, well that is my opinion. So now let’s discuss about the features of a good IDE.

Editing source code

While writing a program, it becomes difficult and tiresome most times if we have to complete every single word and command by ourselves.

But with the aid of a good code Editor (or IDE as we have been calling it) we can facilitate this process as it provides features like autocomplete and syntax highlighting, so with these features you no longer need to type every line of code or worry about indentations.

Syntax Highlighting

With the aid of a good IDE, you can write readable codes as IDEs such VScode would give different colors to keyword and special words.

For example:

var objects = "TextBook"

console.log(objects)

The code above is a simple JavaScript code that creates a variable (“Objects”) and passes a value (“TextBooks”) into it, and then tells the browser to print it out on the console.

Well don’t bother about any of those for now, what I want you to take note of is how different colors where applied to the “var” keyword, the variable “Object”, the value that was passed into the variable “TextBook” and also the “console.log” command.

With these different color applied anybody can pick-up your code and understand.

Autocomplete

Some IDEs help programmers in suggesting possible keywords completion while writing codes.

For example say you want to use the system.out.println( ) function in Java notice how long it might be if you would have to type everything out yourself but with an IDE that knows Java, you can get a possible suggestion when you begin typing.

Building Executables

Both compiled languages such Java and interpreted languages such as python and JavaScript require conversion from the high-level state to a bytecode that is executed by a virtual machine. Although this

conversion process varies from different programming languages, but it is necessary. So, with the use of IDEs you can actually do these conversion process automatically and execute the code.

Debugging

Errors can be inevitable in programming and also very frustrating.

Sometimes a simple punctuation mark can cause you to think programming is not for you, and so it is necessary to have a tool that can help you catch and fix bugs.

For example, if you make use an IDE like VSCode, you will always get a red line on the part of the program that has error, with an expected correction.

So, these are the beautiful things that an IDE can help you do. Next, we are going to discuss about another important concept in programming.

Variable Declaration

While programming, no matter the type of language, you will be required to make use of different type of data values like, strings, numbers etc.

Variables are used in programming for making the process easier by storing these values. So, you can say variables are like containers that store these values in a certain memory location.

Declaration of variables differ across different programming languages, but at least some certain rules or convention applies to the naming convention in a few languages.

In some programming language like python you do not need the use of any keyword for a declaration, but in others like JavaScript you need some keywords like “var” “let” and “const” in others like Java you need to specify a return value, with the use keywords like “float” “int” “char” and “double”.

The examples below will show how to declare a variable “msg” on these languages:

On JavaScript:

let msg = "i love you"

on Java:

char msg = "Hello World"

on python:

msg = "Hello world"

Although declaration of this variable in each of these languages have different format, it worth noting that the convention for naming a variable in each language is quite similar.

For example, in any of the programming language above you can start the naming of a variable with a letter either uppercase or lowercase or any symbol, but you can’t start the name of a variable with a number although it can contain a number anywhere inside the variable. So, you can’t say:

let 1msg = "i love you"

for a JavaScript variable or

char 0msg = "Hello World"

for a Java variable or say

2msg = "Hello world"

For a python. Variable like this will be going against the syntax of the programming language.

Basic Syntax

Understanding syntax is a very important step that you must take as a programmer, because without syntax the compiler or interpreter will not be able to compile or interpret the code that you have just written.

Think of syntax as the basic rules that define the structure of a language, how punctuations are used, the use of words and symbols etc. Syntax vary across various programming language.

For example, JavaScript, Java and python are case sensitive, so using the identifier “msg” as a variable name, will require that you use the same lowercase identifier and not an uppercase like “Msg” as this will cause an uncaught reference error.

Also, in Java failure to add semi-colon after a statement might prevent the proper running of the code.

Also, there are rules for creating comments, use of whitespaces (indentation) and declaration of variable, which are good practices while programming.

Apart from giving errors syntax help for communication, code integration and most of all clarity and readability.

As a programmer one thing that makes you great or perfect so to say is if another programmer can pick up your code and understand it, because in the future you might be working with a team of other programmers, or maybe you may have to pick-up your code later in the future maybe after 10 or 5 years.

Data Type and Structure

Another thing you should learn about a programming language as a programmer are the types of data value that can be used in the language, how to use them and their structures.

Data type refers the different classifications of data and in JavaScript, Java and python we have some common data types such number, strings, and arrays.

But in a programming language like Java numbers are further divided into float (for decimal) and integer for whole numbers.

Data structure is a collection of data values. You can simply say it is an organization, management and storage of data for easy modification and access.

Some basic types of data structure include

i) Stacks

ii) Heaps

iii) Array

iv) Linked list

v) Graphs etc

Understanding these data structures and how they operate will really help you in organizing your code and accessing different items.

Flow and control

So, after learning about variables, data structure and data types you might want to write codes that actually do something, like repetition of a particular task over and over again, setting conditions for a particular code to run and so. This is what flow control is all about.

Flow control are commands that allow for decision making and there are three basic structures which are:

Sequential

Sequential flow, is a control structure that involves the step by step execution of codes, starting from the top.

Like in JavaScript if a have a code like the one below:

let msg = "Hello world"

console.log(msg)

The browser will work on the first line of statement which is the declaration of the variable “msg” and assignment of the value “Hello World” to it, before moving down to the next command which is to print it out in the console.

Condition

Sometimes you might want the program to do certain things if the condition is true or something else if the condition if not met.

Sometimes, in your program you expect the user of the software to meet some certain condition for something to happen and failure to meet this requirement, you might want to program to do something else.

This is possible with the help of conditional statement and we have a bunch of them that can be applied in different languages.

i) If else statement (Java, JavaScript and python)

ii) Switch statement (Java and JavaScript)

iii) Elif (python)

iv) Nested if etc

LOOPS

Lastly on our list of control flow program is the loop. Of course it is not a bad thing if you wish to repeat a certain operation in your program over and over again.

Well in order to do this kind of task you will have to make use of looping commands like

i) While loop (python, Java and JavaScript)

ii) Do-while loop (python

iii) For loops (Java, JavaScript and python)

iv) for/in loop (JavaScript)

v) for/of loop (JavaScript)

So, these are the examples of work flows we have in programming.

If you are done learning all these work flow and satisfied with practicing it then you can move on to learn the next concept of programming.

Functions

One of the major reasons for programming is to make work flow easier and more efficiency. So as a good practice, programmers are expected to do things with this mindset.

Functions reusable set of codes in our program that we can create and call anywhere in the program to perform some operations.

Functions makes coding easy as it breaks down the problem into smaller pieces of reusable codes for us.

With functions programmers can eliminate the occurrence of data mutation.

Object Oriented Programming

Object Oriented Programming is a concept in programming that focuses on object rather than the logic required to manipulate them.

This kind of programming model will be appreciated by you if you want to venture into manufacturing system simulation software.

Also, codes written in OOP concepts are reusable and efficient. So, while studying Object Oriented Programming concepts there are certain steps you must follow in order for you not to get loss on the way. First you have to understand the basic structure of OOP, which includes classes, objects, methods and attributes

And you can now go ahead to study the basic principle of OOP, which includes Encapsulation, abstraction, inheritance and polymorphism.

Some example of languages that makes use this model include, Ruby, Scala, Python, Java, JavaScript and PHP. Some of these languages like python and Java were designed primarily for this model, so in order to learn and master these languages you have to be familiar with this model.

Debugging

Finally, on our list is debugging. As a programmer or future programmer to say, one thing you can’t avoid and should not be scared of is making mistakes.

Debugging is a special kind of skills that programmers use for catching and correcting mistakes in programs.

With recent Development Environments it is now possible for programmers to debug their codes with ease, as these IDEs help by pin point areas of codes that might throw possible errors and expected corrections.

Conclusion

The world of technology is growing dynamically with the impact rushing in. With the dynamic nature of programming one might get lost trying to find a path for himself in the world of programming.

In this article the path that every aspiring programmer should take was listed, breaking down what you should likely expect in each stages. Remember to always write clean and readable codes and try as much as you can to make your work les complex. Thank you and good luck in your path.