New Educational College - http://www.nec.ac.mu/portal
Introduction to programming
http://www.nec.ac.mu/portal/articles/60/1/Introduction-to-programming/Page1.html
Ramrajsingh Buskalowa

"In youth we learn, in age we understand"- Author unknown.  I am a computer studies teacher and I love computers and Mathematics. 

 
By Ramrajsingh Buskalowa
Published on 10/8/2006
 

This article has been written with computer science students in mind. However, this article is also intended for people sitting alone at home, late at night. Actually this article is me chatting to you. I hope I manage to keep you awake and interested. But of course I may fail. If you find that the humour it contains offends you, well, that just shows that tastes differ. Feel free to write to me about what you don’t like, and I promise that the next article will incorporate your suggestions(especially if you plan to include a joke.)


A user-friendly Introduction to programming

We’ve seen(please refer to the last article) that partialism is a major source of errors in programming. ( Oops! Sorry, did I call them errors? We programmers prefer to call them bugs, because programs contain so many that it would be humiliating to call them what they really are.) Those readers familiar (or intending to be familiar)with programming should bear the following in mind What is needed for good programming is a deliberate effort to resist the temptation to rush into writing code. A phase of activity aimed at broadening one’s perception of the problem needs to be entered first. Software engineers call this the requirements analysis and specification phase of the software life cycle. A discussion between the programmer and the ultimate end-user is required to find out exactly what the requirements are. The specification would mention a precondition( which says what the input data the program should be able to handle) and a postcondition( which says what sort of output information the program should produce).  Just in case you are wondering what data and information is all about- Well data are raw facts and figures whereas information is data which has been processed. To the computer, data is input whereas information is output.

 

Suppose we want to understand how programming works. How is it possible that, by typing or even in some cases, just uttering instructions, a machine can be made to do complicated things? Should we try to answer the question by examining a typical computer under a microscope? NO. It does not make sense. Let’s describe how to break up the problem into levels and how levels fit together. The picture we will paint is of four language levels: the natual language level at the top, the high level programming language level just below, the assembly language level below that, and the machine language level at the bottom.

 

To start off, we have to speak to the computer. To do this, we have to adapt ourselves to the computer’s ear. It would be pointless to tell a pretty girl “I love you” using soundwaves at a frequency so high only bats can hear you. The computer’s ear is the compiler. The compiler does not understand English; English has the wrong “frequency”.

To communicate, we’ll have to provide the compiler with instructions it can decode(i.e we’ll have to communicate at the right frequency, which will hopefully not be too far from the natural frequency at which we normally communicate, otherwise we’ll struggle). Pascal and c++ are called high-level languages to reflect the fact that they are relatively close to English ( and is therefore relatively easy for normal English-speaking humans to use).

 

Now suppose we want to understand the pecularities of the compiler. Just as the human ear changes soundwaves into electrical impulses that are sent to the brain, the compiler changes our c++ program(or pascal program) into a lower-level language, such as assembly language. In fact, the compiler itself is a program written in a low-level language such as assembly language.

(to be continued…)