Programming Languages
This lecture on programming languages focuses on:
- Machine language
- Low-level language
- High-level language
Discussion
We use computer programming languages to communicate instructions to a computer in the same way a supervisor gives instructions to an employee of a company to complete a specific task. One main difference however is that the computer will only execute instructions that are grammatically correct. There are rules for speaking natural languages like English or French and there are rules for each programming language.
The word syntax is used to refer to the rules which govern the structure of a programming language. Unlike humans, a computer will not assume information or interpret instructions but will carry them out literally even if they do not make sense. A computer does exactly what you instruct it to do as long as the instruction is syntactically correct.
Machine language
The first generation (1GL) of computer languages is machine language and it is written in binary code. The language of ones and zeros. Writing machine language is tedious and error-prone but is executed quickly by a computer because it is the native language of a computer. All code for first generation computers were written using machine language but today this is not the case.
An example of machine code is :
1101 1101 1011 1011
1110 0001 1100 0111
0010 1010 1011 0101
Machine language code is the only instruction code that the CPU can understand and execute directly without having to translate it.
Other Low-level languages
Assembly language is the second generation (2GL) of computer languages. Low-level languages are machine dependent. They replaced the binary instruction pattens with mnemonics to make them easier to remember. Low-level languages cannot be understood directly by a computer. Translation is performed by another program called an assembler into machine language before execution.
An example of assembly language statements :
INC COUNT ; Increment the memory variable COUNT
MOV TOTAL, 48 ; Transfer the value 48 in the
; memory variable TOTAL
ADD AH, BH ; Add the content of the
; BH register into the AH register
High-level languges
High-level languages, third generation (3GL), like basic, pascal, java and python use english-like syntax. These languages were developed to allow programs to run on different types of computers without the need to rewrite code completely and they are much easier for programmers to learn than earlier generations of languages. High-level programs have to be translated into machine code and this is achieved using a compiler program. In some cases an interpreter may be used instead of a compiler.
List of some early high-level languages :
ALGOL,
APL,
BASIC - Beginners All-purpose Symbolic Instruction Code. A language with simple syntax for students.
COBOL - Common Business Oriented Language.
FORTRAN - Formula Translator. A scientific, mathematical based language developed in 1950s by IBM.
Pascal - A teaching language for more advance students learning about structured programming techniques.
PL/1
Some common modern high-level languages :
C - case sensitive and somewhat cryptic syntax but powerful
C++
C#
Golang
Java - developed in 1991 for the web but very verbose
Javascript - Excellent for web development
Kotlyn - A general-purpose language designed to work well with Java
PHP - For web development but not very secure
Python - easy to learn suitable for webdevelopment and AI applications
Rust - A fast and memory-efficient modern language
Swift - developed by Apple
Some persons consider C to be more of a low-level programming language because of its power and cryptic syntax.
If you are interested in becomming a programmer Javascript, PHP and Python are recommended for aspiring webdevelopers.
How do language translators work?
Interpreter
An interpreter reads a single line of code then if it is syntactically correct it decodes the line then executes the instruction. It does so line by line in sequence until it reaches the end of the list of instructions or until it encounters a syntax error.
Compiler
A compiler reads the high-level language code and if it does not detect any syntax erros the source code is converted into low-level object code for the computer to execute. Compiler languages are more efficient than interpreter type languages so they execute faster.
Test Yourself
YouTube link
This lesson takes 15 minutes. High-level languages vs Low-level languages