Machine code is very difficult to write for us humans, but easier for machines to understand.
It also takes time to write a program, find errors and update the new features.
High level programming languages can help us here. They enable us to write our own code to program the system. At least to some degree they resemble english
Lets look at this code snippet from machine code
.data
msgEqual db "Equal", "$"
msgNotEqual db "NotEqual", "$"
.code
main proc
mov bl,"Alice"
mov bh,"Bob"
cmp bh, bl
jne NotEqual
mov ax, seg msgEqual
mov ds,ax
mov ah, 09h
lea dx, msgEqual
mov ah, 4Ch
int 21h
NotEqual:
mov ax, seg msgNotEqual
mov ds,ax
mov ah, 09h
lea dx, msgNotEqual
int21h
main endp
end main
Lets look at some higer level programming
IF "Alice" == "Bob" THEN
print "Equal"
ELSE
print "Not Equal"
ENDIF
When we write higher level programming using languages then to execute they needed to be converted to machine code.
To convert the higher level programming into machine understandable format, we have
Compilers:
Compilers compile the high level language into low level language
Compilation happens before execution
If language uses Compiler then to make our application work in
Windows: We have to compile to Windows Macine code
MAC: We have to compile to Mac Macine code
i.e We need to compile our application for different platforms
Compile applications can directly run on target platforms
Interpreters:
Intepreters convert the high level language into low level language
Interpretation happens during execution.
Since it happens during execution, we need the interpreter software to be installed on the machine where we execute our application
In the modern world languages like C#, Java, Python Go with the hybrid mode i.e. these lanugages use both compilation and interpreters
Hierarchy of programming languages
Puzzle
I know a kid Anil
Anil knows only addition. (adding numbers)
Now i want to make anil multiply numbers without teaching about multiplications