|
CSE307 Spring 2007 Stony Brook |
Principles of Programming Languages
Annie Liu Assignment 1 |
Handout A1 Jan. 25, 2007 Due Feb. 6 |
Comparing Languages --- Reading Tables
This assignment has two goals: writing programs to read data in the form of tables, and comparing languages while doing this.
Much if not most application data processed in information systems are in the form of tables, which include in particular data from databases and spreadsheets. The structure of these data appear to be flat and easier to process, whereas programs as data appear nested or recursive and harder to process. So, we will start with processing data from tables.
Reading tables
To be concrete, we will read Excel data saved in tab-delimited text. Note that this makes our program widely applicable since many applications use Excel, and many databases dump data into Excel formats. Tab-delimited text format has the advantage that tabs are always separators between cell values; there can be other special characters such as commas in the values.
Your program should treat the first row specially, say, as names of object fields, or as keys to look up cell values for each row; for simplicity of this assignment, assume that cell values in the first row are distinct strings containing no special characters. Given any cell value in the first row, your program should sort the rest of the rows, in increasing order, according to the cell values of that column.
Finally, your program should write the data in a neatly lined-up fashion. Note that columns in tab-delimited text might not be aligned because cells of the same column may have text of different lengths. To get some statistics, your program should also compute the numbers of rows and columns, as well as the output width in terms of the number of characters in each line.
When run, your program should take 3 arguments from command line: input file name, output file name, and a column name (i.e., the string value of a cell in the first row); read data from the input file; and write the results to the output file, containing the statistics and the sorted table with columns aligned.
Comparing languages
Write your program in 3 different languages: Java, C/C++, and ML (or whichever language you learned in CSE113, or another language that you choose). See pointers to these languages under Other Resources on the course homepage.
In addition to the usual requirements, your README file should compare your programming experience in these different languages. What was easy or hard in which languages? What features of which languages make which parts of the code clearer or messier? Are there noticeable differences in speed? Be sure to describe any features of your code that the TA might not immediately notice.
Extra credit suggestions
Write your program in some other languages. A language that differs more significantly from the ones above, such as Lisp, Scheme, Haskell, and Prolog, would be particularly interesting.
Handins
Hand in everything electronically, using Blackboard, by 5pm on the due date. Your handin should include your README file, code, test data, and anything else you have to show your work.
Grading
This assignment will be graded based on 100 points, allocated in proportion to the estimated amount of work for each part. You may do this assignment in a team of two people; the two people will receive the same points. Exceptionally well thought-out and well written work will receive appropriate extra credit. Extra credit work will be graded based on the estimated amount of extra work.