Saturday, February 4, 2006

Expressiveness and Computer Languages -- I

Over last many years the world has seen plethora of languages, be it, Fortran, Pascal, SmallTalk, C, C++, JAVA, Perl and many others. The list is growing and each language comes with some new idea or new design paradigm lying in it. This is interesting and it will be even more interesting if some one finds whether a similar progress tree was involved in natural languages evolution or not. The popular languages are those which are intended to solve variety of problems with recommendable ease and effectiveness. Ofcourse ease and effectiveness may sometime compete each other but then solving problems of Nature, often requires balance.
I am a darn persistent supporter of the idea that there should be a change in the paradigm of tackling problems in Science and Mathematics. We need to solve problems not only using pen and paper but there should be an algorithmic description of the same. Why an algorithmic description ? There are many causes :-
  1. They give most clear solution. So although they may be written in natural languages, they still manage to give concrete picture.
  2. These algorithms can be translated to a coded language (having a well defined syntax).
  3. With the availability of computers one can check a given algorithm for a variety of inputs. This gives scope and limitation of a given algorithm.
However in most of the science and technology books, that I have seen, I have found that such type of description is often absent or is present only in end-excercises or appendix. This makes one feel that these algorithms are not in the main flow of subject matter and can be easily skipped.
There are many other level of confusion. With the evolution of Information Technology and Computers, many computer related subject matter have been introduced in pre matriculation classes. I met one student ( a standard IXth student) who was studying JAVA for one week, VB for another, also C, HTML ... and in the end he was totally confused. Moreover it often gets very hard for a person to relate study of these subject matter directly with other subject matter. For example, say Mechanics with C. Now it is evident that C can be used to simulate motion. But is it very simple? By simulating motion of projectile can we hope for simulation of simple harmonic motion ? Will our involvement in algorithmic discussion will digress our attention on the subject matter ? These questions are very pertinent. Consider Mathematics that is taught in schools. There are text materials on the conception of number lines. So a student is told that we can lay numbers on a lines, as,

----1----2----3----4----5----6----7----8----9----10----11----12----13----14----15.

This number line conception is extended to accommodate negative integers and then real numbers. In a sense authors try to give an idea of "Scale" to measure things. Can we introduce the idea of "int, float, double" there? So at the same point we can say that an "int" is a scale which can measure say upto 2^32 -1 on this or that computer. So instead of introducing "int" as a data type, we can naively introduce it as a scale. Similarly consider floating points. We can't measure any number to infinite precision. Consider a scale which measures to a resolution of millimeters. We can't expect it to measure micrometer or nano meter. It is analogous to idea of floats. Can we introuduce there datatypes like "float" or "double" which also measure to a given precision. This will help students to relate with these data types more effectively. (This is important because many prime languages have basic data types --- int, double, float ). A thought will then pop up --- this will make study of Mathematics harder. The answer is a big NO! Instead of making it tougher it will make the subject matter more clearer. Impact of integration of languages with Mathematics will give clearer picture and will make Computer Science part of main stream. Also Computer Science will not become an extra subject rather it will merge into rest of subjects.
However a much finer thread can be sewed by making languages expressive. What do we mean by being expressive ? Consider addition of two complex numbers , A and B.
void fun()
{
complex_int A,B,C;
//input A,B
C = A.add(B);
//output C
}

Another variant is :-
void fun()
{
complex_int A,B,C;
//input A,B
C = A + B;
//output C
}

I think definitely the second one is more expressive. So instead of doing hard work round "." operator it is fine to do with "+" which we call operator overloading. There are many such scenario. Consider the Statistic subject of class X. Students are told to fine mean/median. This is nothing but some additions and divison.
So if we have these numbers, 10,15,16,20,34,45,56, the mean is

(10 + 15 + 16 + 20 + 34 + 45 +56)/7.

Instead of getting the core conception of what mean is all about, students are more bothered about addition and subtraction. Can we go for this thing :-
void fun()
{
vector_double v;
file >> v; // file points to file in which data is kept.
double mean = v.sum()/v.size();
}

What can be a possible framework for integration of Computer Science with other subject matter ? How languages can be made more expressive so that they can be easily applied to other subject matters ? Can we go for expressiveness and effectiveness of a language at the same time ? I will continue writing on this topic.

3 comments:

  1. Computer programming is, I think, rather like every other area of human activity : it is subject to fashions and fads.

    I can't help remembering that man went to the moon before object oriented programming came along! During my PhD studies I wrote about 11,000 lines of code and never once used O.O.P.

    ReplyDelete
  2. Actually I also support your view. The key point is that "Algorithms" are cleanest way to solve problems. Meanwhile these "Algorithms" are better expressed in terms of some computer languages. Now often we use programs to solve problems of varied kind. The blog addresses the problem of clear, concrete integration of programming languages with main flow of subject matter like, say, Physics or Mathematics. How languages can be moulded effectively so as to apply to these subject matter ?

    ReplyDelete
  3. difficult to live without OOP.
    now there are new things comming up. Aspect Oriented Programming and Test Case Oriented Programming.
    Cheers man

    ReplyDelete