CS3723 Homework #4: Historical Debates in Programming - Functional vs Procedural, Assignments of Programming Languages

The fourth homework assignment for cs3723, due on 3/6/08. The assignment covers historical debates over functional and procedural programming, including definitions of functional language, pure functional language, declarative language, imperative language, and referential transparency. It also discusses algol, pascal, and ml, comparing their features and discussing the differences between them.

Typology: Assignments

Pre 2010

Uploaded on 07/30/2009

koofers-user-vso-1
koofers-user-vso-1 🇺🇸

9 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
cs3723 Homework #4, Due:2pm, 3/6/08
Note: If you collaborated with your classmates or used their notes, please note which classmates you collaborated with. If you use an external source,
besides the text book, lectures, notes provided by the instructor, and your own intellect, please cite that source. Use quote marks if you are quoting
material word-for-word from any source (including the text book).
Historical Debate over Functional Programming (Section 4.4)
1. Give definitions for the terms: functional language, pure functional language, declarative language, im-
perative language, and referential transparency.
2. Why did Backus believe pure functional programs were easier to reason about?
3. What attributes of software (factors) did Backus assert were most important in the long run?
History of Algol / Procedural Programming (Sections 5.1,5.2; Lecture 2/28)
4. List five important features of Algol 60 that distinguished it from Lisp and/or Fortran.
5. What is the difference between pass-by-value and pass-by-name? Do you think pass-by-name is a good
idea?
6. List two reasons Algol 68 was not a huge success, especially in the United States.
7. Pascal was derived from a language called Algol-W, which in turn was derived from Algol 60.
(a) Algol was designed to express algorithm. What else was Pascal designed to express?
(b) What is more expressive about Pascal in order to facilitate this goal?
8. Why was Pascal more successful than Algol 68?
9. Why did C eventually eclipse Pascal as a production programming language?
10. (a) C is said to be ‘weakly typed.’ What does this mean?
(b) What data type was provided by the B language?
(c) What is unusual about C’s memory model (hint: arrays)?
Core ML (Sections 5.3,5.4,5.5; Lecture 2/28)
11. List two aspects of ML’s type system that distinguish it from prior procedural languages like C.
12. What two things does the interactive ML environment print after evaluating an expression you’ve entered?
13. What is different about the val declaration in ML compared to variable declarations in a language like C?
14. What is the ML’s analog to Lisp’s lambda keyword?
15. (a) List five primitive value types found in core ML.
(b) List three kinds of compound/data structure types available in ML?
i. Which is usually used as the type of the function parameter?
ii. Which is most similar to C structures?
iii. Which is most similar to Lisp lists (cons/car/cdr)?
(c) For each of these, write an expression having that type?
1
pf2

Partial preview of the text

Download CS3723 Homework #4: Historical Debates in Programming - Functional vs Procedural and more Assignments Programming Languages in PDF only on Docsity!

cs3723 Homework # 4 , Due: 2 pm, 3 / 6 / 08

Note: If you collaborated with your classmates or used their notes, please note which classmates you collaborated with. If you use an external source, besides the text book, lectures, notes provided by the instructor, and your own intellect, please cite that source. Use quote marks if you are quoting material word-for-word from any source (including the text book).

Historical Debate over Functional Programming (Section 4. 4 )

  1. Give definitions for the terms: functional language, pure functional language, declarative language, im- perative language, and referential transparency.

  2. Why did Backus believe pure functional programs were easier to reason about?

  3. What attributes of software (factors) did Backus assert were most important in the long run?

History of Algol / Procedural Programming (Sections 5. 1 , 5. 2 ; Lecture 2 / 28 )

  1. List five important features of Algol 60 that distinguished it from Lisp and/or Fortran.

  2. What is the difference between pass-by-value and pass-by-name? Do you think pass-by-name is a good idea?

  3. List two reasons Algol 68 was not a huge success, especially in the United States.

  4. Pascal was derived from a language called Algol-W, which in turn was derived from Algol 60.

(a) Algol was designed to express algorithm. What else was Pascal designed to express? (b) What is more expressive about Pascal in order to facilitate this goal?

  1. Why was Pascal more successful than Algol 68?

  2. Why did C eventually eclipse Pascal as a production programming language?

  3. (a) C is said to be ‘weakly typed.’ What does this mean? (b) What data type was provided by the B language? (c) What is unusual about C’s memory model (hint: arrays)?

Core ML (Sections 5. 3 , 5. 4 , 5. 5 ; Lecture 2 / 28 )

  1. List two aspects of ML’s type system that distinguish it from prior procedural languages like C.

  2. What two things does the interactive ML environment print after evaluating an expression you’ve entered?

  3. What is different about the val declaration in ML compared to variable declarations in a language like C?

  4. What is the ML’s analog to Lisp’s lambda keyword?

  5. (a) List five primitive value types found in core ML. (b) List three kinds of compound/data structure types available in ML? i. Which is usually used as the type of the function parameter? ii. Which is most similar to C structures? iii. Which is most similar to Lisp lists (cons/car/cdr)? (c) For each of these, write an expression having that type?

  1. What mechanism does ML provide to concisely extract and name individual pieces of larger data struc- tures?

  2. Give an example of an ML function declaration that uses pattern matching to perform the same task for which cond would be used in Lisp/Scheme.

  3. Translate the C declaration enum color {RED, GREEN, BLUE}; into an ML datatype declaration.

  4. Consider the Java class hierarchy:

public abstract class Student {} public class BS extends Student { public final String name ; BS ( String name ) { this. name = name ; } } public class MS extends Student { public final String name ; public final String school ; MS ( String name , String school ) { this. name = name ; this. school = school ; } } public class PhD extends Student { public final String name ; public final String faculty ; PhD ( String name , String faculty ) { this. name = name ; this. faculty = faculty ; } }

Translate this class hierarchy into a declaration of an ML datatype containing the same hierarchy of information.

  1. (a) What does ML call a memory location which can be modified and updated like a variable in C?

(b) What keyword do you use to create one of these? (c) What operator do you use to update the contents of one of these? (d) What operator do you use to read the contents of one of these? (e) Write a sequence of ML statements that would behave like the C statements: int x = 7; x = x + 1; x * x ;