DEV Community

Murtaza Hashwani
Murtaza Hashwani

Posted on

Murtaza Hashwani - What is a Programming Language?

Murtaza Hashwani - Learn about programming languages and why they are needed. See the different types of programming languages and find a programming languages list of the most commonly used languages.

What is a Programming Language

A programming language is a set of instructions that can be used to interact with and control a computer. These languages are used to design websites, create apps, develop operating systems, control spacecraft, and analyze data. Programming languages are necessary because computers can't understand Engish. Programming languages bridge this gap by helping programmers translate their commands into something that the computer can understand and execute.

Why can't computers understand Plain English?

When people communicate with a computer, it is important to be very specific about what they are asking the computer to do. Programming languages are a tool that allow them do just that. Often, English can be ambiguous and it can be hard for the computer to determine intent. Programmers use programming languages so that they can specify exactly what they want the computer to do.

How do computers think?

Computers are made of many tiny switches that can be either on or off. When a switch is on, it is represented by a 1. When it is off, it is represented by a 0. These 1s and 0s are called bits. Bits are the fundamental language of nearly all computers and every program must be translated into bits before it can be executed by the computer.

Image description

When 8 bits are grouped together, this is called a byte. A byte can represent a letter, for example, 01100001 represents 'a'. A byte can also represent a control character. For example, 00000011 signals the end of a piece of text.

When representing a number using bits, it can be converted from its normal base 10 representation to binary. This is called binary representation.

Binary Representation

While computers use a base 2 system, the system that most people are familiar with is base 10. Base 10 means that each place value is a power of 10. For example, 125 is 100(1) + 10(2) + 1(5). To convert this number to base 2, it must be broken down into powers of 2.

Our goal is to write 125 in terms of 1, 2, 4, 8, 16, 32, and 64. The next power of 2 is 128 and since this is greater than our original number, this place value will be zero and it can be left out of our calculation. 125 = 64(1) + 32(1) + 16(1) + 8(1) + 4(1) + 2(0) + 1(1). Writing each of these bits in order shows that 125 in base 10 can be written as 1111101 in base 2 or binary. Similarly, any number can be converted between any bases. Sometimes programmers will use base 8 (known as octal), base 16 (known as hexadecimal), or even base 64.

Types of Programming Languages

There are three types of programming languages: machine language, assembly language, and high-level language.

Machine language is easier for the computer to understand but harder for the programmer to understand. This is because machine language is simply the language of machines—bits. Sometimes, programmers will develop programs directly with machine code, but because this is difficult to understand and tedious to type, it is more common to program using assembly or a high-level language. Assembly language is slightly easier to understand. The bits of machine language are replaced by numbers and English commands. Before assembly code is run by the computer, it is assembled by an assembler. This converts the code back into the 1s and 0s of machine language that the computer can understand.

High-Level languages use many more English commands and are significantly more readable than assembly or machine language. Many high-level languages have built-in commands that help the programmer write loops, create variables of different data types, and manipulate strings. It is worth noting that all of these are possible in assembly or machine language, but high-level languages make them much easier for the programmer to read, write, and debug. Some newer high-level languages are scripting languages. This means that they are not compiled, or translated into machine language, until just before the code is executed at runtime. Python, Javascript, PHP, Ruby, and Bash are all scripting languages.

Image description

Top comments (0)