Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

End of Semester 2, 2018

COMP2007 Programming Languages

Question 1 (12 marks)

(a)  Prior to the invention of FORTRAN, under what circumstances would you use machine code instead of pseudocode? [2 marks]

(b)  With reference to two of the programming principles, explain why FORTRAN is a better language than PL/1 [4 marks]

(c)  Name two advances in program language design ALGOL-60 brought about. [2 marks]

(d)  Discuss Ada and Pascal with regards to readability and writability. Which is more important? [4 marks]

Question 2 (15 marks)

(a)  With regards to the Regularity Principle, discuss the difference between Python 2 and Python 3. [3 marks]

(b)  Perl is a fantastically complex language. Name three features you would remove from Perl, and justify why. Remember, this should refer to principles or charac- teristics of programming languages. [6 marks]

(c)  With reference to three of the seven requirements of OO, discuss the differences in implementation of objects between Ruby and Python. [6 marks]

Question 3 (20 marks)

(a)  For the following code, draw the stack, dynamic chain, static chain, and display for the program when execution reaches “Position 1” .

PROCEDURE  S:

PROCEDURE  K:

PROCEDURE  L:

B;

D;

PROCEDURE  A:

B;

PROCEDURE  B:

PROCEDURE  C:

PROCEDURE  E:

D;

E;

PROCEDURE  D:

//Position  1

C;

A;

[13 marks]

(b)  Draw a syntax diagram for a language consisting of any array of numbers, or arrays of numbers, for example: [],[1,2,23],[2,[2,3],3]. [4 marks]

(c)  Write the corresponding EBNF for the syntax diagrams you have drawn. [3 marks]

Question 4 (12 marks)

You have joined a debating club, and the current topic is Shell Scripting” . Choose your favorite scripting language from the ones discussed this semester, and with reference to at least 5 of the programming principles or characteristics (you may mix and match) and examples, explain why your language is better than all the rest!

Question 5 (21 marks)

(a) State the four problems Wulf and Shaw found with global variables in block struc-       tures. Explain with examples how object orientation solves these problems. [8 marks]

(b)  Would you consider Ruby to be object oriented, or object enabled? Why? [3 marks]

(c)  Compare and contrast C++ and Eiffel with regards to the requirements of OO. Why has C++ outlived Eiffel? [5 marks]

(d)  Consider the environments associated with C# and Smalltalk.  With the help of examples, discuss which is more expressive, and which more closely follows the regularity principle, and why they are so. [5 marks]

Question 6 (20 marks)

(a)  Write a Prolog program LocInList that given an atom searches a list for it. Should the list contain the atom, the program will return the index number. Otherwise, it will return No” . For example:

LocInList(3,[1,2,3]) .

2.

No .

LocInList(1,[1]) .

0.

No .

LocInList(0,[1,2,3,4,5]) .

No .

[10 marks]

(b)  Write a Scheme program HighCom that finds the highest common multiple of two numbers. You may not use the inbuilt gcd function. This should work in the following way:

(HighCom 6              (HighCom 6              (HighCom 3

12  6)

6  12)

9  12)

[10 marks]

Question 7 (20 marks)

You have been hired as a development consultant for a software development house. The company wants to build a web browser focused on security and reliability.  Your job is to choose a language with which this application will be built. This language may be any language you know of, and is not restricted to the languages covered in this unit.

You must, to the best of your abilities, and with reference to as many of the program- ming principles, characteristics, and requirements for object orientation as make sense to your argument, argue why your language is the best option. You must also, impor- tantly, argue why other languages are not the best choice.  Examples will be of great use to framing your argument.