Concepts of Programming languages
When I started learning programming languages concepts, I didn’t know any such thing as the basics. I just knew the basics of A+ and Network+. But C, Java, Python were altogether a different world for me. Besides, there was hardly anyone to help me since I was the only one among my friends from an IT background. So, I finally decided I would start learning from the most common concepts of programming languages out there. I then came to know about C and C++. I started learning C, but I was actually head over heels since importing modules, and all those stuff usually went bouncer for me. I learned C for a month; then I thought C was a bit tough and thus started learning Bash.
Though bash is a scripting language and not a programming language concept, it was again difficult to understand. I got stuck at cron jobs and stuff. Finally, nowhere to go, I started learning Python. But heck no…It was the worst. When I used to write codes in C, I had to write each and every piece of code. But in Python, there was a lot of magic going around to actually understand what is happening. And yup, this magic is different from the ones you are thinking of, and ‘magic’ is the official word in Python. Magic in Python means that you want to do something, and that thing happens, but you don’t know how it happened. Yeah, and that’s where python tends to get complicated.
When I started to learn all of these concepts of programming language, the most important thing I was not able to understand was why should I import any specific module. For example, say, when writing a hello world program in C, we usually write ‘include stdio.h’ or ‘include conio.h’. So, my question was, why only this. I even saw some people not even typing in the conio part. Similarly, in python, to do complex math, we import cmath, but why don’t developers already combine math and cmath and shorten the whole process of importing it twice? But then I thought, let’s do one thing. Let’s start with the very basics of programming language concepts.
I decided to hit rock bottom and start back from there. And as of now, I can write any program in almost any concepts of programming language such as Java, C, C++, Haskell, Scala, Python, Ruby and many more. Over the years, I have been able to build a rock-solid foundation in programming concepts. And the main reason for this because I cleared all of my basic fundamentals in concepts of programming languages. You may hardly hear anyone talking about the basic fundamentals, but they are the most important to get your concepts right in programming concepts, and that is the main reason I thought of writing this blog. So let’s get started with the fundamentals and terminologies of programming language concepts.
Pseudo codes, Mathematics, and Comments on concepts of programming languages
If you know math, then most of the things will come by easily. Writing a program is not much different from solving a math problem. Besides, when learning functional languages like Haskell, math is the only thing that can be a prerequisite for learning the concepts of programming languages. Most problems can be solved by simple mathematics and pseudo-codes. Math and pseudo codes go hand in hand. For example, whenever you want to solve a specific problem, just write it down in simple algebraic and geometrical format in the form of theorems and hence proved formats. Now write down these pieces of code in pseudo-code format. When I say pseudo-codes, I mean writing the program in such a way that when you write an actual program, you would only need to change some values and vocabularies, and the program would work. For example say, to calculate the sum of all the numbers from 1 till it reaches to 20, one can write pseudocode in the following manner:-
let x = 1x = x + 1if x = 20 then stop and print xelse continue and repeat everything again |
Now, this code is a bit buggy, but we are not here for that. As you can see, first, I assigned the value of x to 1, and then I added 1, 2, 3 till it reaches 20. If x reaches 20, the program will stop and print the output; else, it will continue and repeat the same thing. So, when you write this kind of pseudocode, it becomes extremely easy to just convert it into an actual program. And also, make sure you write comments next to all those lines which you think are confusing. The main reason for writing comments is because first, it doesn’t get executed, and second, you can always point out what you did, where you did and why you did something. Comments are not of much use in 5-10 lines of code, but when you have multiple files with like around 40-50 lines of code in each file, it becomes easy to find where the bug lies or why some file was imported by just looking at the comments.
Variables, constants, and Datatypes on concepts of programming languages
A variable is something that can be used to store data, string, number or almost anything. A collection of such data is known as an array. If I refer to the previous example, you can see that I have assigned the value of one to X at the start; thus, it makes X a variable. Here the one is an integer, and X is the assigned variable. Similarly, I can also input string into a variable as well. A simple example would be:-
X = ‘Hello world’echo $X |
The above is an actual concept of programming languages that can be executed in bash, an awesome Linux terminal. X is assigned the value of the string ‘hello world’ and echo prints whatever is inside of X. The dollar sign is used to represent that we are calling the value of X here.
In a similar fashion, constants are also variables, but constants cannot be changed, unlike variables. In the first example of concepts of programming languages, I assigned the value of one to X; then, I kept on increasing it in ascending order. But for a constant, X will always be one, and the value cannot be changed until the concepts of programming languages are quit. Data types are just bifurcation of different types of data. For example, real numbers, integers, floats or even Boolean and strings. Boolean refers to True and False and is often represented by 1 and 0.
Functions and Procedures on concepts of programming languages
In this programming language concepts, functions are just assigned values to large pieces of codes. They are usually made that way so that a person won’t have to write the whole code down repeatedly and simply call the whole code with just one simple syntax. A Function is just an encapsulated task that contains multiple lines of instructions to be executed. When writing large pieces of codes, functions are usually pre-developed and stored in separate files inside a folder. Later whenever that piece of code is required, any number of times, one can just call for the file name or the function name which is defined and the whole piece of code within the file will get executed.
Functions have their own workspace, which means that all variables inside a function are usable only until the code’s execution gets completed. Once it gets completed, the variable gets undefined (except in the case of garbage collection, which I have not mentioned here since that is a very huge topic to discuss on). And also, functions can also be nested within a function. This means that one function can call any other function as well, even including itself. But the later one is not recommended since that will result in a boot loop until otherwise executed in an acute manner.
On the other hand, procedures are almost similar to Functions except that functions always return a value, whereas a procedure is just the execution of commands. Mostly when starting to learn programming concepts, you may see a lot of people use the terms functions and procedures interchangeably. But this isn’t the case if you start learning functional concepts of programming languages like Haskell or Scala. One thing to keep in mind when writing functions are to make sure that they don’t have side effects.
Conditions and Loops on concepts of programming languages
Condition and Loops are something I have explained previously in the example. They go by the manner of something like this ‘If it rains, I will be wet. Else I will not be. Yeah, that sounds like a dumb example, but that is the most easier it can get. Conditional statements depend on each other. Usually, they are interconnected and go in the form of “if, then, else and elif”. Even conditional statements can be nested as well. Conditions within conditions are very common these days, but if indentations and comments are not done in a proper manner, the program will become extremely buggy and hard to understand.
On the other hand, Loops are used to repeat the execution of codes, functions, and procedures till the desired result is returned. If you check my first example, you will see that I have stated something to repeat everything again. Thus, loops are very powerful, and they make concepts of programming languages extremely compact. But too much use of loops will make the program slow. They should be used only when necessary. Loops go in the form of “for, While, Do-While loop, and for-each loop”. The while, do-while and the for loop are the most commonly used loops. The pseudo-codes for the while, do-while and for loop would go in the following manner:-
While Loop:- |
While the condition is false,{execute the code and check whether the condition is true}Stop when the condition becomes true. |
Do – While Loop:- |
Do{execute a code} while (check whether a statement is true, else repeat the Do) |
For Loop:- |
for ( a, b, c){execute code} |
In the above code, a is a condition that gets executed once and first, b is the condition of the loop, and c is the code that gets executed once the loop is about to stop. |
Control Structures on concepts of programming languages
Control Structures in programming concepts are just a combination of conditions, loops and other sets of code. The control structure is a block of codes, which analyzes the whole structure of the programming language concepts, and then decides which to go further, as in whether to stop, or repeat or call for a function or execute the other block of codes. In short, to be more specific, Control structures in concepts of programming languages is just a decision-making process that decides the flow of a program. One full piece of code performs in the following block type of manner:-
Pre ConditionControl StructureEnd of Control StructurePost Condition |
Object-Oriented Programming and Functional Programming
Now, this is one of the most debated topics by developers. Object-oriented programming deals with just ‘objects’. Don’t take that statement too literally. Object-oriented programming or OOP basically deals with data that contain fields, attributes, procedures, and methods. C is an object-oriented programming language concepts. Python is not purely object-based. But there have been books where some people tend to say that Python can too work in an object-oriented way. Now similar to object-oriented programming, there is also something known as Functional programming languages concepts. Functional languages are more of math-based. A purely functional concept of programming languages I can remember of is Haskell. Another one is Scala, but it is not fully functional, but it can be made to work that way. On the other hand, Haskell doesn’t tend to work like other concepts of programming languages, and it is based on pure logic. Having a bug in Haskell is very less since there is less at least no side-effects of functions in Haskell, unlike Java, C, Python or most other languages.
All in all, programming concepts are very easy to learn. One just needs to input proper logic into a problem and find multiple ways of solving a problem rather than just one to sort a problem. Once you have the basics right, developing software or learning frameworks based on them would just be a piece of cake.
Recommended Articles
This has been a guide to programming languages concepts here; we have discussed how programming concepts are easy to learn if one has a proper idea of solving problems in multiple ways. You may also look at the following articles to learn more –
41 Online Courses | 13 Hands-on Projects | 322+ Hours | Verifiable Certificate of Completion
4.5
View Course
Related Courses