Friday, April 4, 2008

Natural language

In this paper I am going to describe about my new prototype, for a new language I am developing. I am naming it as "Natural language" instead of bringing it under the term "Computer language". Because I believe a language should be used to express the ideas instead of implementing it. A language should be used to express the idea and tool should be used to implement it.


All existing computer languages are merely tools and not exactly a language. They provide syntax base to implement our ideas. For example, in order to compute the circumference or area of a circle, all we have to know is the formula and technique. We know that circumference of circle in terms of radius is "2 pi r" and area in terms of radius is "pi r square". If I want to express or calculate this using a existing computer language, for example C language, it goes like this:

main
{
float pi = 3.1415;
float radius = 5;
float area, circumference;

circumference = 2 * pi * radius;
area = pi * radius * radius;

printf("Circumference of the circle: %f\n", circumference);
printf("Area of the circle: %f\n", area);
}

or if the value of pi and radius, have to be received from the user:

main()
{
float p, radius, area, circumference;

scanf("%f", &p);
scanf("%f", &radius);

circumference = 2 * p * radius;
area = p * radius * radius;

printf("Circumference of the circle: %f\n", circumference);
printf("Area of the circle: %f\n", area);

}

so, here instead of expressing the idea, I am just implementing it. Otherwise, lets say if I write "scanf("%f", &p);" as "scanf("%f", p);", this is going to result in a big mistake, because this is due to syntax. Hence, when we want to express our ideas using existing languages, we need to know 2 fundamental concepts

1) what to express
2) how to express

But, How actually a language should look like is:

start:

to find circumference of the circle:
assume pi as 3.1415;
receive the radius from the user via console and store it in rad;
receive the diameter from the user via console and store it in dia;
now compute the circumference of the circle;
store this result in circumference;

to find the area of the circle:
assume pi as 3.1415
receive the radius from the user via console and store it in rad;
receive the diameter from the user via console and store it in dia;
now compute the area of the circle;
store this result in area;

display the output:
display the computed circumference and area via console;

end:

you may ask Why I have not put ";" in the end of the line next to "to find the area of the circle:", because there is no syntax in my language. It is all about ideas and expressions !

this is very easy, simple and straightforward, as this only talks about the idea instead of implementation. Though, one way this can be termed as implementation, there is no way you are going to bother about variables, syntax; etc.

To put it otherwise, if you make some mistake, you are going to end up only logical errors instead of logical plus syntax errors !!!

No comments: