Why do we have programming languages?
- 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
msgEqual db "Equal", "$"
msgNotEqual db "NotEqual", "$"
cmp bh, bl
mov ax, seg msgEqual
mov ah, 09h
lea dx, msgEqual
mov ah, 4Ch
mov ax, seg msgNotEqual
mov ah, 09h
lea dx, msgNotEqual
- Lets look at some higer level programming
IF "Alice" == "Bob" THEN
print "Not Equal"
- 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 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
- 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
- I know a kid
- Anil knows only addition. (adding numbers)
- Now i want to make anil multiply numbers without teaching about multiplications
- I want anil to do
- So if i want anil to do
5 * 4
5 + 5 + 5 + 5