Monday, 6 April 2009

Learn Programming Easily Step 2

If you have understood what I have tried to convey in my previous post then it is time to move forward. As I mentioned that programming is
A set of logical instructions written to perform a specific task or tasks.
In my previous example I took a mundane task of clearing the bins now lets assume these tasks are to be performed by a computer therefore I shall again over simplify the situation and take a simple task of printing some message on the screen or the output device. Lets say the message is "Happy New Year". If you believe the sci-fi movies and think just saying "Computer show me Happy New Year on my screen" and your computer will do so... then all I can say dream on. Most computers cannot do so and even the ones which may be able to understand speech are very limited in their ability. Have you ever tried to dictate on your computer using the popular speech programs?. Then there is a small problem...computer as a machine does not understand English for that matter any human language. It can understand the language of 0's and 1's called binary thus making it understand your language is a bit of a problem. So how do we go about


My wonderful diagram shows you the task which has to be performed. 'INPUT' means the command or the instructions that you gave to the computer.As I said computer cannot understand the language you speak. So how do we convert it into something which it can understand. There in lies the magic of compilers or interpreters.




I Shall not go into the gory details of compilers just as a simple explanation compilers are a piece of code or programs which take instructions in human readable format and convert them in a format which computer can understand. There are lot of steps involved but that is for some other time. As you know English or any language has a grammar or a way of witting and reading in the same way programs are written following a specific grammar which is quite rigid compared to normal human languages. This grammar is called syntax in technical terms. Therefore if you want to become a crack programmer you must learn the language first. There are many languages each with its own strong points and weaknesses. Some of the well known ones are C++/C, Visual Basic, JAVA, C# etc. But take my word for it the number of languages are innumerable.

Getting back to our discussion as how to print "Happy New Year" on the screen. Now I can say

START
DISPLAY "Happy New Year".
STOP

There we have it our own program to print a message on the screen.(May be I can sell it for a few thousand pounds to IBM).

Your next question might be which language have I used? The answer is none this a style of writing program which are very close to the real thing yet they are not bound by any language. This style sometimes is called 'pseudocode'. For most part of the introduction I shall follow this pattern. Once the basics are out of the way I will take up some language to further illustrate my points.



No comments:

Post a Comment