Vikrant0 - I have created new universe out of nothing, come have a look at it! Language orientied programmingThe best way to write programs is to write a programming language and then start programming in that language. If anybody thinks it is too much of effort and this statement is just an exaggeration, then I would like to disprove these thoughts in this post. My experience says that this sentence forms a basic philosophy needed to write good programs. Computer languages are made for computers not for human beings. So it is obvious that if one tries to read the code to understand the program, it will be a tedious job. Same tediousness and difficulty comes into picture if a programmer has to explain the understood algorithm (the understanding happens in human language) to a computer (which is going to be in computer language). Going back to first case, by our good luck,the programmer has written documentation in the code which explains the algorithm in plain human language. Then suddenly the task of understanding the code becomes very easy. What about the second case? How can we ease the task of translating algorithm from human language to computer language? One easiest way is to have a automated translator. But Human languages are too fuzzy to translate automatically. So we can not translate human languages directly to computer language. The way to do it is to choose a language which is mid way to human and computer. i.e Domain Specific Language. Human language ->Domain specific language -> computer oriented language Let give me some example from linear algebra. In a human language an iterative algorithm to find biggest eigen value and corresponding eigen vector of a positive definite matrix is as follows.
Lets write a program for this in a java/c like main stream language! oops so much of code to write!
Now let us say we have a matrix language which looks like mathematician's conventional linear algebraic equations. The algorithm in that language will look like as follows
Can you see the difference? algorithms are same but only key is many things are abstracted out in the martix language. For example matrix multiplication, looping over vector, transpose, dot product all these are not implicitly done by the language! These abstractions will make the algorithm look like matrix algorithm and not like a code in computer language. A good DSL will make following good things to your code
last updated 6 months ago # |
|