Programming language:
we have many programming language because they are for different applications
About new programming language
Histroy: we used to write byte code. But we developed "speedcode" as first compiler and then FORTRAN I by John Backus. Before 1958, 50% of code was written in FORTRAN.
Five Phasis:
For FORTAN, the semantic analysis part is small and the rest is evenly distributed accross different phasis.
For today's compiler, we have big semantic alalysis phase and very large optimization phase. Other phasis are small.
Lexical Analysis: divide program text into tokens.
Inconsistency example:
Jack said Jerry left his assignment at home
// Do you know what "his" is refering to?
// Answer: No
This is a problem in semantic analysis
To avoid this issue we use scope:
{
int Jack = 3;
{
int Jack = 4;
cout << Jack; // It will print 4
}
cout << Jack; // It will print 3
}
Consider the following code
X = Y * 0
While this could be optimized to
X = 0
However, this optimization does not always hold. It only holds for integers, but invalid for floating point since NaN * 0 = NaN != 0
Generate lower level code.
Table of Content