Programming Languages

If you go to another country and try to speak with the locals, you have to be sure they comprehend your language. It creates a communication barrier if you speak Hindi and your acquaintance only knows English. We must translate our language into the language that the other person knows in order to communicate.

Similarly, a machine that follows your directions to do a task, must be able to comprehend exactly what you’ve written. If it is unable to comprehend the set of instructions, no output is generated, and the programming session is terminated. As a result, translation is necessary here too.

MACHINE LANGUAGE / BINARY CODE :

Modern computers are incredibly fast, and getting faster all the time. However, computers also have some significant constraints: they only understand a limited set of commands, and must be told exactly what to do.

The limited set of instructions that a CPU can understand directly is called machine code (or machine language or an instruction set). So, to make computer aware of the information, our source code(instruction set) has to be converted to Machine Code.

Here is a sample machine language instruction: 10110000 01100001 

Each instruction contains a series of 0’s and 1’s called as “binary digits” or “bits”. The number of bits that make up a single command varies. Each set of binary digits is interpreted by the CPU into a command to do a very specific job, such as compare these two numbers, or put this number in that memory location.

Drawbacks :

However, because different CPUs have different instruction sets, instructions that were written for one CPU type could not be used on a CPU that didn’t share the same instruction set.

Programmers have to write programs directly in machine language, which is a very difficult and time consuming thing to do. This method is not preferred for obvious reasons.

ASSEMBLY LANGUAGE :

As binary language is so hard to read and write, assembly language was invented. In an assembly language, each instruction is identified by a short abbreviation (rather than a set of bits), and names and other numbers can be used.

Example : mov al, 061h

This makes assembly much easier to read and write than machine language. However, the CPU can not understand assembly language directly. Instead, the assembly program must be translated into machine language before it can be executed by the computer. This is done by using a program called an assembler. Programs written in assembly languages tend to be very fast, and assembly is still used today when speed is critical.

Still, this language too has its limits…

SO WHAT IS THE OTHER ALTERNATIVE?

This is when Programming Languages come in handy! A programming language is neither as simple as our spoken languages nor as sophisticated as Binary Code. It’s in the middle of the two (i.e a mixture).

Position of Programming Languages

Programming languages are not binary. They must be converted to Binary Code, which is far easier than converting human language to Binary since computer languages are intermediate between the two. This is the primary reason for utilising programming languages.

A “Source Code” is a set of instructions written in a computer language.

PROGRAMMING LANGUAGES :

To address the readability concerns, new programming languages such as C, C++, Pascal (and later, languages such as Java, Javascript, and Perl) were developed. These languages are called high level languages, as they are designed to allow the programmer to write programs without having to be as concerned about what kind of computer the program will be run on.

Here is the same instruction as above in C/C++: a = 97;

Much like assembly programs, programs written in high level languages must be translated into a format the computer can understand before they can be run. There are two primary ways this is done: compiling and interpreting.

COMPILERS :

A compiler is a program that reads source code and produces a stand-alone executable program that can then be run. Once your code has been turned into an executable, you do not need the compiler to run the program.

INTERPRETERS :

An interpreter is a program that directly executes the instructions in the source code without requiring them to be compiled into an executable first. Interpreters tend to be more flexible than compilers, but are less efficient when running programs because the interpreting process needs to be done every time the program is run. This means the interpreter is needed every time the program is run.

Process of Compiling and Interpreting

A good comparison between compilers and interpreters can be found here : Click Here

LEVELS OF PROGRAMMING LANGUAGES :

Programming Languages are categorized based on their readability and their readability. Languages can be classified as High-level and Low-Level.

High-Level Programming Languages are easier to read and have high abstraction(design and detail) and portability(use in various environments).

Low-Level Languages have little to no abstraction and very less portability. They have functions very similar to the machine language and thus, we say that Low-Level Languages are closer to the hardware or have a good grip over the hardware.

Higher the level, more is the readability.

SUMMARY :

Programming Languages : Used to make computers understand our instructions.

Binary Code/Machine Language : 0’s and 1's.

Assembly Language : Easier than Binary but still hard to grasp. Fast compile time. Translated using an assembler.

Programming Language : Easier to read and write. Translated using compilers and interpreters.

Tech || Programming || Lifestyle