Types Of Programming Languages And Basic Programming Concepts For Beginners
Explore the types of programming languages, use cases and essential concepts. Gain a solid understanding of computer programming.
Are you fascinated by computer programming? Do you have a secret crush on the guys and girls who love to code? Ever wondered what magic happens behind the scenes of these beautiful machines?
Well, I'm here for your rescue, I'll take you on the adventure of this computer program wonderland. This is going to be a fun ride, so let's get started.
What is a programming language?
You might have heard it many times, "We Live In a Digital Age", this digital era is powered by nothing but computers. We all know how dependent our lives have become on these devices, today, we can't imagine a day without these devices.
Computers are initially built for performing complex mathematical operations i.e. computation, hence the name computers. these computers have evolved with time and now they have become an integral part of our lives.
Computers are best at performing various tasks, storing data, processing it and retrieving it when needed, however, we need to instruct the computers to do so. but as computers don't understand human language, that's where a programming language comes into the picture.
A programming language is a set of generic rules and grammar for computers. These rules are then used to instruct the computer. a set of instructions given to perform a certain task is called a program or application.
These instructions are processed by the CPU - the central processing unit, think of it like the brain of a computer. We will come back to CPU later in this article.
Ok, so now you understand what is a programming language and why we need it, now let's discuss the types of programming languages.
Types of Programming Languages
Programming languages are classified into mainly 3 categories:
- Low Level Programming Languages
- Medium Level Programming Languages
- High Level Programming Languages
You may wonder, what kind of levels are these, right? Well, these are the difficulty levels for a computer.
Low Level Programming Languages: Low level programming languages are the easiest for a computer to understand, typically these are binary languages or hex codes. As the computers work on binary logic i.e. 0s and 1s, and so it's easier for the computers to process these languages. these instructions are very specific to the hardware of the computer.
e.g.: Binary language, Hex codes
# binary representation of "Hello World!"
01001000 01100101 01101100 01101100 01101111 00100000
01010111 01101111 01110010 01101100 01100100 00100001
Medium Level Programming Languages: Medium level programming languages are not so difficult, nor so easy, an example could be Assembly language. It is an intermediate programming language, which makes use of simple instructions, which can be understood by humans as well as the computer.
e.g.: Assembly language
section .text
global _start
_start: ;entry point
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1 ;output stream descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Hello, world!',0xa
len equ $ - msg ;length of our string
High Level Programming Languages: High level programming languages allow a developer to think of the application rather than the hardware of the computer, these are the highest abstraction of hardware and the developer does not need to think of the hardware, architecture, etc. These languages use verbs similar to the ones we use to communicate.
e.g.: C, C++, Java
// example code in C
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
This is how we classified the programming languages but now there are other criteria as well. but before that, we will discuss some important concepts that are used to further classify these programming languages.
There are other criteria to classify the programming languages, based on the features of programming languages:
- Functional Programming Languages
- Object-Oriented Programming Languages
- Scripting or Interpreted Languages
Functional Programming Languages: Functional programming languages groups the reusable parts of a program, those groups are called functions, hence the name. Functions return the result of computation or perform certain tasks, these functions can be called from other functions as well as the same function.
Functional programming languages follow a top-down approach which means that the code starts the execution from the very first line and continues till the last line from top to bottom.
e.g.: C
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
Object-Oriented Programming Languages: Object-Oriented programming languages or OOP are advanced versions of programming languages, these languages group the logically related functions and variables in an Object. These languages define a blueprint of the functionality i.e. class and these classes are instantiated to create the objects. OOP languages use a bottom-up approach.
e.g.: Java, C++
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Scripting or Interpreted Languages: Scripting languages are often used for small programs, mostly related to systems, automation scripts, etc. These languages execute line by line and are generally used in computer terminals to interact with the system resources easily.
e.g.: Bash, Python, Javascript
# hello world in python
println("Hello World")
Execution of code
Well to run a program or a piece of code, we need to go through some processes, these processes are different for different programming languages. To run the program, it needs to be properly translated to the machine-level language, The following are some of the common tools that ease this process.
Assemblers
Assemblers take the assembly language code to the machine level language. assembly language is a set of instructions called mnemonics which are fed to the assembler and translated into machine level language.
Advantages of assembly language: Assembly language is closer to the hardware and so one can access the system resources efficiently and easily work on the hardware level.
Compiler
Some Programming languages need to be processed before their execution, this processing is done by a compiler, a compiler takes the code and converts it into the machine level language depending on the hardware of that system. The compiler takes the entire codebase and converts it into the machine level language.
Hardware, here refers to the CPU architecture, instruction set and other low level details of a computer.
Advantages of compiled languages: Code gets compiled as a whole, so it generally runs faster, also the compiled executable file can be shared without the need of sharing the original source code.
Interpreter
the interpreter is also similar to the compiler, but the key difference here is the interpreter translates the code to machine language line by line, hence it reads, interprets and executes the lines sequentially, hence it is called an interpreter.
Advantages of interpreted languages: Interpreted code is easier to debug since it executes line by line, the errors are caught easily, also it's more flexible as the changes can be implemented and tested easily without the need for recompilation every time.
Virtual Machines
Virtual machines are the virtual abstractions of actual physical hardware. these are software-emulated implementations of different operating systems. Java uses this method to mimic the same environment on all the Operating systems. the VM is called a Java Virtual Machine, the Java code is firstly compiled into the bytecode and this bytecode is run using a Java Virtual Machine.
Advantages of JVM: The same code runs on all the operating systems without any additional steps, creating the same environment on any platform/operating system.
Bonus
Well, that's not everything, there are many other languages, that resemble programming languages but they are not, such as HTML, Markdown, XML, etc.
The most popular HTML, which is the base of the internet is not a programming language but a markup language. Similarly, there are markdown languages as well. I'll cover the basics of markdown in the next Article. stay tuned for more.
Conclusion
In the ever-evolving landscape of technology, programming languages serve as the bedrock upon which innovation thrives. As we conclude this exploration of programming languages, it's proven that these diverse tools are more than just strings of code; they encapsulate creativity, logic, and the power to transform ideas into reality.
From the simplicity of Python's readability to the robustness of Java, each language has its unique strengths. Whether it's the flexibility of JavaScript for web development or the efficiency of C++ for system-level programming, the choice of language often aligns with the problem at hand and the preferences of developers.