[UMN logo]

CSCI 5106: Programming Languages
Spring 2006, University of Minnesota
Homework 1


Posted: Jan 17, 2006
Due: Before class on Jan 31, 2006


Reminder: Assignments are due in class before the start of class on the day indicated.

Note that each question below is a separate one and therefore merits a distinct answer. For example, simply presenting a program printout as required for Problem 4 does not also suffice as an answer to Problems 1 and 2. For Problem 1, you have to explain the representation you have chosen for the kind of data indicated and for Problem 2 you have to indicate the specific procedure or function you are offering for the purpose described. This kind of requirement will be implicit henceforth in this course. You may want also to look at the protocol for assignments at this point so as to be sure of what we expect of answers.

I am aware that the programming environments and languages in this assignment are new to most of you at this point. However, the programming task itself is very simple and we would have discussed all the new languages enough for you to try to solve this problem in each of them. You should also find the documents I have prepared for you for getting started with each language helpful in doing this assignment. Problem 5 requires you to start thinking critically about language features and paradigms. Don't worry that you are doing this so early in the course: you will have the opportunity to refine and/or revise your thoughts as you learn more about programming languages in the semester.


Problem 1

Suppose that your eventual objective is to develop a collection of functions or procedures for manipulating sequences of arbitrarily many single characters. Describe a representation that you might use for such sequences in each of the following languages: C, Java, Scheme, ML and Prolog. Java is supported by a large library provided in the form of APIs. For this problem, though, you should not use these APIs but should design your own representation.

Your answer for each language should be clearly separated. Notice also that your answer to this question should be in the form of a brief English description followed perhaps by suitable declarations for each language.


Problem 2

Write a function or procedure in each of the mentioned languages that produces the reverse of a sequence of characters represented in the manner described in your solution to the first problem. For example, given a representation of the sequence that contains the characters 'a','?' and 'C', the function should return a representation of a sequence that contains the characters 'C', '?' and 'a'.

Pay careful attention to the kind of functionality that is expected. In particular, at this stage we are only talking about a procedure with a specific functionality, not of ways of observing this functionality. In particular, there is no mention of obtaining sequences from user input on the terminal or of displaying results to the terminal. These aspects may be needed for testing the procedure and would, in this case be components of a later part.

Once again, clearly demarcate your answers for each language. Once again, note that you need to provide the definition of a specific function in each language for this problem, accompanied perhaps by brief explanatory English text.


Problem 3

Devise a set of tests to determine if the procedures you have developed for Problem 2 are correct, and explain the rationale for your particular choice of tests. Remember that this will henceforth be an implicit requirement for all programming assignments in this course.


Problem 4

Test out the procedures that you have developed in Problem 2 as per the strategy you have described in Problem 3. In some languages you may have to embed your procedure in a larger program that allows different sequences to be input and output conveniently. You should turn in a complete program that includes such parts in this case and also pay attention to the overall structure of these programs. Programs and test runs for each language should be presented on separate sheets. Electronic versions of programs should also be turned in as described on the main Web page for this course.

Note that this part of the homework is different from the previous ones in that here you really have to turn in code that can be run for each language.


Problem 5

Comment briefly on the (relative) suitability of the languages used and of your particular solutions within them for the programming task considered. Think of issues such as ease of programming, flexibility in data representation (e.g. does the language support different ways to represent the same data that you might want to choose between depending on circumstances), generality of the solution (e.g. does it adapt easily to treatments of sequences of objects of type different from characters and does the language facilitate adaptation in this way), efficiency, etc. You may find it relevant to break up the languages into categories that you then compare for this problem.

Note that there is no a priori "correct" answer to this question. Rather, what we are interested in seeing is your ability to think of different facets that may be relevant to programming enterprise and also to some extent of the way languages mesh into these considerations.


Problem 6

This problem requires the bulk pack. Read the paper by Wirth entitled On the design of programming languages and the one by Hoare entitled Hints on Programming Language Design that are contained in this bulk pack and discuss these papers briefly. In particular, explain what you think are the most important points made in each paper. Also, based on your present understanding of how programming languages and computer systems have developed in the years since these papers have been written, discuss what the authors have been right about and where they may have been off the mark. Note that we will be looking for your thoughts and opinions on these papers and not for a general summary. Note also that how much you write is not as important as what you have noticed and how insightful your comments and criticisms are. Spend more time on thinking about what is important than on writing itself.


Last updated on January 17, 2006 by gopalan@cs.umn.edu