![]() |
Programing Language |
Hi guys today lets start from basics
Lets say I gave you one mathematical question to find out
multiplication of two numbers say suppose
2*3?
It will not take you more than few seconds to answer. It’s a
silly thing right. But guys what if i ask you to tell me value of 4567*3457??
Now it will take you few minutes to calculate right.
And what about the calculations that are having 7 digits or
9 digit numbers??
You will definitely able to solve that but they are going to
take lot of time.
What if you have a calculator application that will
calculate multiplication of two numbers? I know that you are going to tell me any value
within few seconds.
So that is the use of a computer application (here
calculator). Yes, here calculator is a small computer application for which you
will give some inputs (numbers 2, 3 and a symbol of multiplication *) then it
will give you the result within fraction of seconds.
So we as developers should know how calculator application is
able to do these calculations, right??You know that computer is just a machine which execute the
commands(list of words) you give. In the
same way if you design one set of statements so that whenever you give two
numbers as input It will return multiplication of those two numbers. Then you don’t
need to worry on the length of numbers involving in the multiplication.
Whatever the numbers are, you just enter those numbers and the calculator
application will calculate the multiplication within few seconds without any
errors. And you can calculate any number of multiplications without any waiting
time.
So the main advantages of computer applications are
1) They are very accurate, that is they will give you the
answer based on your code without any diversions.
2) They are very fast.
3) They are robust.
For Example:
Let’s take an example of calculating multiplication of two
numbers:
Problem statements:
1) My application has to ask me to enter two numbers.
2) When I enter two numbers and press enter button, it has
two show multiplication of entered numbers.
So this is the problem statement.
Note:
For the companies the clients
will provide this problem statement only, through frd documents. But since they
want lot of functionalities their requirements (problem statements) document
will be around 30 to 40 pages.
Now we know the problem statement right.
Let’s note down some main points to full fill the requirement
(problem statement)
1)
Take two numbers let’s say A and B
2)
Calculate multiplication of two numbers A *B
3)
Display the result to client(the person who uses
our application to calculate multiplication of two number)
You can see that we fetch three main points from the problem
statement that we have to do.This process of writing main points from the problem
statement in general language (here in English) is nothing but Pseudo Code of
the application.
So know we know the steps we need to follow, right.
Know we will move forward to convert these general language statements
(English statements) into the language statements which cpu(your processor) can
understand.
Unlike English language which contain 26 alphabets, cpu can
understand the language which contain 2 alphabets 0 and 1.
Here 0 = power off
1= power on.
Since CPU is a digital circuit (an electronic circuit) it
works when we supply power to it. But we have designed the cpu such that if we
give different combinations of power on and power off (like 1010001, 000111)
It will behave differently.CPU circuit is combination of
several small circuits. We have designed that small circuits which can give us
the output that we want when we supply particular power series to them as
input.
Example of small circuits:
1) AND circuit or AND gate: which give us
As you can see for this circuit we have 2 input terminals
(wires) and one output terminal (say suppose one small bulb which glows when it
get power to know the result)
So as stated in above table, if you don’t give power to two
input wires then the output is 0 that is the bulb doesn’t get power which means
it doesn’t glow.
When you give power to two inputs then only the bulb gets
power to turn on.
So this is the small visual of what is happening in the cpu.
Cpu is the combination of lot of small circuits like this.
So when you give power supply in some series of 0‘s and 1’s
it will give the output as designed by the designers of cpu.Let’s say you have to multiply two numbers 2 and 3. Then
first you have to convert 2 and 3 into series of 0’and 1’s and after the
calculation the output will be in the series of 0’s and 1’s. Then again you
have to convert the output into numbers.
Let’s say some client asked us to design one application to calculate
the remainder when 10/2 and display the remainder if the remainder is not equal
to 0.
Here in addition to calculation you need to check the
remainder that if its zero or not. In this case we have to use IF. Which is not
numeric. But how to convert the word IF into 0’s and 1’s.And what if we need to do repetitions in calculations.
So the Computer scientist had represented each every key in
the keyboard with some combination of 0’s and 1’s.
And they also assigned some unique combinations to words
commonly used in calculation statements such as IF, WHILE etc...And they also designed one structure to give inputs to CPU circuit
and stated that as programing language. And they had designed some programs
which converts the numbers and words (2,3,IF, WHILE etc., into series of 1’s
and 0’s) which reduce the burden of converting . They named those programs as
compilers and interpreters.
Compiler: A compiler is a computer program which convert the
high level language (English statements) into machine understandable language (1’s
and 0’s) at once.
Interpreter: And Interpreter is also a computer program
which convert the high level language (English statements) into machine
understandable language (1’s and 0’s) line by line.
As developers we write programs using progaming language
structure acceptable by compilers and interpretes. Any program not acceptable
by compilers is not allowed to convert into machine language.
So we must write the programs which are compiler error free
programs.
For example:
Let’s say the multiplication example.
If you give input as in general English. The cpu will give
different output since we are not giving input to cpu in the way that was designed.
So we need to follow the structure noting but programing language.
Here different scientist created different structures to
code for the cpu.
Ex: C language, java language etc.,
Since we are focusing on java language I am going to tell
you the structure of java language
A typical java language structure to implement multiplication
of 2 numbers is as follows
1)
Int a=2;
// assigning value 2 to integer variable ( a variable or symbol which
takes only integer)
2)
Int b=3;
3)
Int c=a*b; // storing multiplication result into
another variable c
4)
System.out.println(“ multiplication of two
numbers= ”+c);
5)
6)
// java typical print statement to display
result in console
Later some scientists and programmers gave different
modifications bound to core structure to reduce the calculation time or storage
space.
In the next post we will learn the speciality of java language.
And why it is different from other languages like c and c++ and some more
concepts.
Thank you.



No comments:
Post a Comment