What is a Programming Language?
A programming language is a language used by humans to interact with computers. Programmers assign tasks to machines by writing lines of code on what, why, when and how to do something. It can be anything. The possibilities are endless.
There are two main types of programming languages. Humans use High-level programming language to write tasks and machines use the low-level programming language to understand the assigned task.
Low-Level Programming Languages
Low-Level Programming Languages are almost impossible to be understood by most programmers. They come into existence after the compilation of the programmer-written code to be understood by computer machines. Now there are two types of low-level programming languages:
Assembly Language
Assembly language is a type of low-level language that is writable by humans but much closer to the understanding of computers. It is much faster to execute by the processor but is comparatively more difficult to write than high-level languages like c++, java etc.
Unlike English words like print and class, in Assembly language, we use mnemonics like LDA and STA that contain instructions like load and store. These mnemonic instructions get translated to machine language by the Assembler. Programmers wrote Assembly language frequently during the early days of programming. But now, it is done only when the performance and speed are of the highest importance for a software task or if the hardware is outdated.
Machine Language (Binary Code)
Everyone is most familiar with this computer language. Thanks to the dropping green 0s and 1s in Matrix. Machine or Binary Language is hexadecimal sets of 16 0s and 1s that represent every single instruction and data fed to the computer by humans. Unlike Assembly and High-level languages, it does not need an Assembler or Compiler to be understood by the machine and is the closest to a computer’s understanding.
0101000000010000 : Add sum to the acc;
1011000000001010 : Jump to done if n < 0;
High-Level Programming Languages
It will be almost impossible to write instructions for the computer in 0s and 1s or mnemonics, so we created High-Level Programming Languages. They are human-friendly programming languages containing English words as commands. Programmers can turn their ideas into executable, instruction-based code and design everyday software and applications. They are executed by being translated to machine language by a compiler. There are two ways we can distinguish high-level programming languages.
Procedural Programming Language
This category comes from the initial days of programming. For a procedural programming language, the procedure is the priority and data come second. It uses a top-down approach where we break down a big problem into successively smaller chunks. It is easy to track the flow of a program and find bugs due to the well-structured, systematic order of statements.
Examples of Procedural Programming Languages: Pascal, COBOL, C, Basic, Fortran, Python
Functional Programming Language
Functions are a block of code with a set of instructions/calculation/solutions that we can repeatedly use by using the function’s name instead of writing all of the code once again. Functional Programming languages are the ones that treat functions as first-class citizens in their environment. It means the Functional language treats them like any other variable. We can pass functions as arguments in other functions, return them in a higher-order function, and assign them as a value to another variable.
Examples of Functional Programming Languages: JavaScript, Python, Clojure, Elixir, Scala, Erlang, Haskell, Common lisp, Racket, SQL
Object-Oriented Programming Language
Object-oriented programming language revolves around objects. When we turn a dataset into code, it is known as an object. Let me explain with an example. An object ‘student’ consists of a name (string), roll number (integer), and percentage (float). Now, we can use the ‘student’ object as a custom datatype everywhere in the code.
Classes are templates, and Objects are their instances. In simple words, we create Objects using classes. Class is a template that Objects (like students) use for their structure. Classes can also contain functions that manipulate the data to produce desired results.
For example, if a Class (template) has a Function that decreases roll number by one digit, then all the Objects inherited (created) from that class will have this function and reduce their roll numbers by 1.
Object-oriented programming follows the bottom-up approach. Contrary to the top-down approach, we define small components and solve problems at a fundamental level. We link them to build elements and repeat the integration until we have a complete system/solution. This programming approach is the easiest and most efficient to solve real-world problems as every problem is treated as an entity.
Examples of Object-oriented Programming Languages: Java, C++, C#, JavaScript, Python, PHP, Ruby, Swift, Kotlin, Scala, Common Lips
The doubt you might have
In the examples, you may have noticed that some languages like Python and JavaScript are in multiple categories. So, the question is, do these programming languages support more than one approach to programming? The answer is yes! Most modern High-level programming languages are hybrid in structure and designed for general-purpose programming.
Static and Dynamic Programming Languages
Here you won’t find the programming languages in both categories. If a programming language is static by nature, it remains Static and vice versa. In the previous section of High-Level programming languages, we talked about the structure of the code and programming languages can support multiple such approaches. But here, it is based on compile-time and runtime.
Static Programming Languages
In statically typed programming languages, we specify the data type of the variable. For example, int a = 12;
or string wealth = “cars”;
. We do this because the compiler checks all details of variables. And a variable cannot have two data types, or the code won’t compile and convert to machine language in a Static Programming Language System.
For example, if the variable string wealth = “cars”;
, then we can’t have int wealth = 24;
at the same time because the compiler will show an error.
The error will also show an error if we write int wealth = “car”;
because here the datatype declared is an integer but, the value assigned is a string. The compiler will show the syntax error before compiling.
The Advantages of using Static programming languages
We have more control over the code. We can remove all syntax errors even before the source code goes for compilation. That saves a lot of time and energy that may go into debugging. Static programming languages are comparatively faster at runtime as the compiler translates all the code before running.
Examples of Static Programming Languages: Java, C++, C#, C, Pascal, Go, Kotlin, Swift, Haskell, Fortran, Scala
Dynamic Programming Languages
In Dynamically typed programming languages, we do not specify the variable datatype. For example, we can write like a = 12
or wealth = “cars”
. In a Dynamic Programming Language, the datatype checking happens at runtime, when the program is running as machine code in the form of 0s and 1s.
If you write a = 3
and a = “word”
in the same code, a Dynamic Programming Language will not show an error when compiling. The computer will show an error when the code is running (at runtime as machine code).
The Advantages of using Dynamic Programming Languages
We have to write a lot less code comparatively as we don’t have to deal with datatype specifications. But might give errors at runtime. But that does not bother programmers as dynamic programming languages are faster to write, easy to understand and more flexible. That makes bug finding easier.
Examples of Dynamic Programming Languages: Python, JavaScript, Ruby, PHP, Ruby, Lua, Perl
Thanks for reading! Let me know what you understood and what you didn't. Let's connect in the comment section :)