Share
Explore BrainMass

Language evaluation

Here is the problem:

Neither functional programming languages nor logic programming languages are thought of as 'practical' programming languages. Choose either Lisp or Prolog and recommend changes to the language which you think would increase acceptance of the language in mainstream programming.
Justify your recommendations

Solution Preview

Programming Languages
Introductory Notes
Language Types,
1) Imperative model
You are acquainted with the imperative model - a statement like
pay = hours * 6.65;
changes the state of the processor. In this case, the memory location referenced by the variable pay has its content changed to the result of fetching the content of the memory address referenced by hours and multiplying it by the constant. A program is a sequence of changes of state.Much of the course will be devoted to pointing out variations in the imperative model.

2) Logic-oriented model
You are not so familiar with the logic-oriented model. Our example language will be Prolog. In Prolog we can write databases of facts, like
father(anne,buck).
father(alice,buck).
father(buck,charles).
father(barbara,calvin).
mother(anne,barbara).
mother(alice,barbara).
mother(buck,cora).
mother(barbara,celeste).
mother(celeste,doris).
Then we can add some intelligence to our database. It ought to be easy to figure out from the facts when a person Y is a grandmother of a person X, so we write
grandmother(X,Y) :- mother(X,Z), mother(Z,Y).
grandmother(X,Y) :- father(X,Z), mother(Z,Y).
Instead of writing a procedure to figure out when Y is a grandmother of X, as we would in an imperative language, we define what it means to be a grandmother in terms of the facts we have. The symbol ":-" means "if". Now we can write a query like
?- grandmother(anne,Who).
and we expect ...

$2.19