What are the 4 types of Programming Languages?

What are the 4 types of Programming Languages?

There are four types of programming languages: Procedural, Functional, Object-Oriented, and Scripting Programming languages. In this blog, we will learn these 4 types of programming languages in detail.

Table of contents:

Types of Programming Languages

Here are the following programming languages that are used by developers to develop real-life applications:

1. Procedural Programming Languages

These languages work on the sequence of operations that are performed by the computer. It breaks down the program into smaller, and reusable functions.

  • Examples of these languages are: C, Pascal, Fortran, and BASIC

Let’s have a look at C Language(Procedural language ) code:

Code:

#include <stdio.h>

void greet() {
    printf("Hello, World!\n");

}
int main() {
    greet();
    return 0;
}

Output:

Hello, World!

2. Functional programming Language

Functional programming languages are used to execute every program in the form of functions. These languages forced us to run every program in the form of functions.

Examples of these languages are: Haskell, Lisp, Scala, and Erlang

Let’s have a look at the Haskell language code:

Code:

square x = x * x
main = print (square 5)
 Output: 25

3. Object-oriented programming language

Object-oriented languages are language that revolves around Classes and objects. These languages organize code into reusable components called objects. Objects are real-world entities that have their own unique characteristics and behaviors. 

There are six major components of object-oriented programming: 

  • Classes: it is a blueprint for objects. It contains attributes and methods inside its definition.
  • Objects: An object is an instance of a class.
  • Encapsulation:  Encapsulation means hiding the internal details of a class.
  • Abstraction: it shows only the essential details and hides the rest,
  • Inheritance: Inheritance allows a child class to inherit methods from its parent class.
  • Polymorphism: Polymorphism means more than one function can have the same name but perform different actions.

Examples of these languages are: Java, C++, Python, C#, Ruby

Let’s have a look at the Java Language code:

Code:


class Animal {
void makeSound() {
System.out.println("Some sound...");
}
}
class Dog extends Animal {
void makeSound() {
System.out.println("Bark!");
}
}
public class Main {
public static void main(String[] args) {
Animal myDog = new Dog();
myDog.makeSound();
}
}
Output:
Bark!

4. Scripting Languages

These languages are used to automate tasks and manage dynamic content. These languages are mostly interpreter-based languages to execute tasks easily. These are also used for web development, system administration, and prototyping.

  • Examples of these languages are: Javascript, Python, PHP, Ruby, Perl, and Bash

Let’s have a look at the Python code:

Code:

import random

import string

password = ''.join(random.choices(string.ascii_letters + string.digits, k=12))

print("Generated Password:", password)
Output: Generated Password: Wuyi1IIh3NXu

Explanation: The above code generates random passwords each time. Whenever we run this code, it will create a new password.

Conclusion

So far in this article, we have learned 4 types of programming languages in detail. Procedural, Functional, Object-Oriented, and Scripting Programming languages. If you want to learn more about these languages, you may refer to our language courses: C language course, Java Course, Python Course.