Computers at a glance
Computers have taken the world by storm, as is evident in its diverse areas of applications. From its simple beginning as an analytical machine, it controls the power stations and chemical plants. They drive airplanes, rockets and ships. Businesses need them for online transactions; Doctors require them for precise medical diagnosis and to predict the health of patients. Scientists, Astronomers and researchers need them for complex computations, documentations; which otherwise would have taken years of time and considerable man power. Artists use them to draw and create 3D models and chefs use them to assist in cooking. They route the communication networks worldwide and into space. They implement connecting and messaging portals like Facebook, WhatsApp, Google mail, YouTube etc.
A computer can only execute instructions and it’s quite fascinating to see, how such a machine that can only do few simple operations such as flipping, zeroing and testing a bit  could accomplish such a wide range of operations.
• How does a computer attain such feats of ability, through these simple operations?
• What is it that translates these operations into those examples listed above?
Complementing the advances in sensor, memory, high end processors, communication and other hardware technologies, let’s try to answer these questions and be part of this great movement.
Understanding Algorithms, A Cookery Example
Let’s take an analogy, from the cooking process. We all like to have a strong cup of tea in morning, or a cut of dessert after lunch. Let’s analyze a simple cooking process and try to understand our subject. Suppose you are told to make tea for guests arrived, and below are the steps taken by you to make the tea;
STEP 1: Initially, move to the kitchen and set up the materials required (tea bags, sugar, milk, tea cups or glass, gas stove and boiling pan);
STEP 2: boil the water in the pan using the stove;
STEP 3: When it starts boiling, add tea powder and sugar to the boiling water;
STEP 4: Once properly boiled, mix the boiled tea with milk in a cup;
STEP 5: Check the sugar content, taste it and serve if fine;
From the above steps, one can figure out that the materials like tea bags, sugar and milk are input to the cooking process, whereas the tea cups or glasses, gas stove, boiling pan, including the cook are considered hardware to the process and the final tea served is the output of the process. The steps taken to transform the raw materials to tea, is known as a ‘recipe’ or in computing terminology known as ‘Algorithm’.
Here an important point to consider is that, it’s the recipe that selects the required raw materials and other kitchen utensils needed for making TEA. Similarly, in Computing it’s the appropriate algorithms that give life to computers and accomplish such great feats mentioned above and even drive the need to invent new and better hardware.
How Computers Understand Human Invented Algorithms
Algorithms similar to recipes are ideas formed inside oneself. These are transformed to machine executable constructs using programming languages such as Assembly language, C, C++, Python, PHP etc.
Computer scientists have devised programming languages such that a programmer (A Cook in our example) can express his ideas (Algorithms) based on few constructs, which are suitable for computer execution.
Basically, computers don’t even understand the algorithms expressed in a programming language. These typed in codes are translated to computer executable logic using compilers and interpreters (which are known as system software, usually supplied along with the machine by the manufacturer).
Thus computer languages allow one to express his ideas or algorithms, in a human understandable format, which are then translated to computer executable constructs using system software.
The Problem With Languages And What To Choose From
Computer languages are designed, keeping in mind the way humans think and express a particular problem. Thus some languages are designed to express mathematical equations (like Fortran, ALGOL), while some are designed for developing graphics user interfaces (like QT framework, Java) and some languages are used to create webpages (like HTML, Java scripts). These languages have specific constructs, libraries and routines that cater to specific problems and as such it’s quite natural for a programmer to express and write his thoughts directly in a particular language.
Considering examples from procedural language (example C) and Object Oriented language (example C++).
First let’s take a problem to design an automatic watering system for household plants. Suppose appropriate hardware is selected, one can write down the Algorithm as below:
STEP 1: Initialize the system, and get the user input for soil threshold level;
STEP 2: Sense the soil moisture content, check if it’s equal to the threshold level;
STEP 3: If the soil moisture is less than the threshold, trigger the water pump to water the plants;
STEP 4: else if the soil moisture content is more than the threshold, Switch OFF the water pump.
STEP 5: Repeat STEP 2.