Natural languages that we use in our day to day communication are effective for us humans to communicate and share information. The reason this is possible is because we can easily fill in missing details using our senses and logical thinking. For example if someone in a town you are about to visit tells you that it is raining there, you can easily reason that you will need to carry an umbrella, this is just a simple case, in reality , your subconscious mind will do so much filling ins for you that we tend to take it as just 'common sense'.
When it comes to computers, things tend to get a little bit tangled because computers do not have the power to reason and make decisions, the natural languages are just too ambiguous and vague to give meaningful instructions to computers. The instructions given to computers needs to be as much precise as possible and should not be open to multiple interpretations. Programming languages comes in to bridge the gap between the highly ambiguous human nature and the computer nature which calls for high level of precision.
Computers only understands machine language which is composed of only zeros and ones ,this means that even the program we write in high-level languages like Python or C are eventually translated to their equivalent machine code when we run our programs.
Programs in machine language looks like a long series of zeros and ones and it is nearly impossible for humans to read leave alone understand or write any useful programs in it. Programming languages have therefore evolved to become the middle layer for communication between humans and computers. A typical high level language uses natural words or short form of natural words which humans can easily infer their meaning by looking at them, such as for , while , return , int etc . They also use symbols which with practice humans can easily learn to associate with various activities such as using right curly brace( { ) to enter a block and a left curly brace( } ) for leaving a block , a semi colon( ; ) to terminate a statement and a comma( , ) to separate items in a sequence.Though some languages might not always follow the convention, for example python uses a full colon( : ) to signal a block.
Each programming language like natural languages is unique in it's own way, it has it's own features and quirks that makes it stand out from the rest. It also has it's own strengths and weaknesses which makes it more capable in performing certain tasks than others, for example some languages might be more suited for performing scientific computation and data manipulation while others will be more suited for making web applications or game development.
Classification of programming languages
We can group programming languages according to various categories.
Compiled vs Interpreted languages
Compiling in it's non-computing usage means to combine information from various sources into one work.
In a compiled language all the instructions in the source code are combined and translated to their equivalent machine code as a whole to come up with an executable . An executable is the machine code of a program such that it can be run directly by a computer.
Compiled languages are generally more faster than interpreted languages.
An interpreted language in the other hand, gets the first part of it's name from human interpreters because like how human interpreters translates human languages sentence by sentence, the source code of an interpreted language is translated to it's equivalent machine code one statement at a time.This means that in interpreted languages it is possible to see incomplete results of the already interpreted lines while later statements are not yet interpreted.
It is worth to note that some languages can be classified as both compiled and interpreted one example of such language is java in which the source code is compiled by the java compiler and then goes to the java virtual machine which interprets it.
Example of compiled languages:
- C
- C++
- Java
- C#
- Erlang
- Haskell
- Fortran
- Julia
- Pascal
- Swift
- Basic
- COBOL
- RPG
examples of interpreted languages:
- Python
- Java
- Javascript
- PHP
- Ruby
- Perl
- Swift
- Scala
- Kotlin
- Lisp
- Lua
- Clojure
- Elixir
- VBScript
The lists above are not exhaustive
Low-level languages vs High-level languages
Programming languages can be further be sub-divided into low level languages and high-level languages
low-level programming languages
This are programming languages which are closer to hardware, they can be seen to be more native to computers than high-level languages.Programs written in this languages tend to be mostly non-portable because they are usually optimized for a certain type of hardware architecture.
They are usually more faster and memory efficient than their higher level counterparts but are more difficult for programmers to work with because of the technical details one must keep in mind while using them and also due to their encrypted nature.
While high-level languages are made to ease the development process, low level languages are mostly concerned with performance and efficiency of the program.
types of low level languages includes:
machine code
Machine code is the only language that a computer can process directly with no need for translation.All programs written in other programming languages must be translated to machine code before a computer can process them.Rarely(if ever) do programmers write programs in machine code, the reason being that machine code is highly technical and encrypted for humans to make any sense of programs written in them.
Assembly language
Assembly languages provides a basic abstraction to machine code by mapping human readable symbols to addresses, constants,strings etc.
Though assembly language makes some sense to humans compared to machine language, the level of details one needs to remember is still overwhelming compared to high-level languages.
Advantages of low-level languages
-
programs are fast since computers can understand them directly
-
memory efficient
-
Can communicate directly with hardware
-
gives programmers high control over hardware
Disadvantages of low-level languages
- programs are machine dependent and thus not portable.
- Very hard to read, write , debug and maintain programs in them.
- Are highly error prone
- High technical knowledge required
High-level programming languages
This are the languages mostly used in today's software development.This languages tries to make development process easy and friendly to humans at the cost of speed and efficiency.A code in a high level programming language uses a combination of predefined keywords and symbols to construct statements for various operations and are therefore more readable and easy to use for humans.For example below is a program to print a string to the console in python a high-level language
print("welcome to pynerds.")
While low-level languages are closer to computer, high level languages can be seen to be 'closer' to humans.
They are usually portable meaning they can be used with different hardware architectures with no or little modification.
There are many high level languages, some include:
- Python
- C
- C++
- Java
- PHP
- Kotlin
Advantages of high-level languages
- They are portable
- Easy to learn
- Easy to debug
- Boosts productivity
- Provides high level abstraction from machine language
- less prone to errors
disadvantages of high-level languages
- Takes additional time to translate to machine code
- Are comparatively slower than low-level languages
- Less memory efficient compared to low-level languages
- Cannot communicate directly with hardware
We will look at various high level programming languages in details in upcoming tutorials
Programming languages can as well be grouped according to programming paradigms they support, check programming paradigms to see the various paradigms supported by various programming languages.