<aside> π A programming paradigm is an approach to programming based on a coherent set of principles or a mathematical theory.
</aside>
Each language implements one or two paradigms. We can understand every language that exists if we understand the few paradigms that exist.
When we resolve a complex problem we have to use multiple paradigms. This combination of paradigms is done using kernel language.
<aside> π The kernel language is the first part of the formal semantics of a paradigm or programming language. It is its simple core language that contains its essential concepts. Kernel languages are very similar between different paradigms and most of the concepts are in common.
</aside>
β All intermediate results of calculations are visible.
Length of a list
fun {Length Xs N}
case Xs
of nil then N
[] X|Xr then {Length Xr N+1}
end
end
A function is translated as a procedure with one extra argument, which gives the functionβs result.
N={Length L Z}
is equivalent to: {Length L Z N}
# Kernel language
proc {Length Xs N R}
case Xs
of nil then R=N
else
case Xs
of X|Xr then
local N1 in
N1=N+1
{Length Xr N1 R}
end
else
raise typeError end
end
end
end
All practical programs can be translated into kernel language β all hidden variables become visible :
β Kernel programs are longer
β It is easy to see when programs are tail-recursive
β It is easy to see exactly how programs execute
<aside> π A variable is a value stored in memory.
</aside>
<aside> π An identifier is the name of a variable.
</aside>