CSc 4101 Programming Languages

Fall 2007

 

Course: Tues & Thurs 1:40-3:00 PM  Coates 236

Instructor: Donald H. Kraft     Office: 286 Coates      Phone: 578-2253

Office Hours: Mon & Wed 2:00-3:30 pm . Tues-Thurs 3:00:-4:30 pm

Email: kraft@csc.lsu.edu         Web: http://www.csc.lsu.edu/~kraft

Grader: Alfred Samman            Email: asamma1@lsu.edu        Phone: (225) 266-0536

Required Text: R.W. Sebesta, Concepts of Programming Languages, 8th edition, Addison-Wesley, 2007 (http://www.aw-bc.com/sebesta)

Recommended References:

Scott, Programming Language Pragmatics, 2nd edition, Morgan Kaufmann, 2006

Tucker and Noonan, Programming Languages Principles and Paradigms, 2nd

 edition, McGraw-Hill

            Wilensky, Common LISPcraft, Norton, 1986

            Bratko, Prolog: Programming for Artificial Intelligence, 3rd edition, Addison-

Wesley, 2001

            Horstmann, Big Java, 3rd edition, Wiley, 2008

Additional Readings:

G.I. Steele, “Growing a Language,” OOPSLA ’98, ACM, 1998

H.G. Baker, “I have a Feeling We’re Not in Emerald City Anymore,” ACM

SIGPLAN Notices, v. 32, n. 4, April 1997

R.P. Gabriel and R. Goldman, “Mob Software: The Erotic Life of Code,”

OOPSLA ’00, ACM, 2000

            The Association for Computing Machinery (ACM) and the IEEE Computer

Society have journals and proceedings with good articles on programming languages (e.g., ACM Transactions on Programming Languages and Systems) and ACM/SIGPLAN Notices)

Useful Links:

            http://www.csc.lsu.edu/~kraft/courses/csc4101.notes.html

            http://www.csc.lsu.edu/~gb/csc4101.html                                  http://java.sun.com

            http://www.cs./rice.edu/CS/PLT/packages/drscheme/    http://haskell.org

            http://www.webber-labs.com/mpl/pitch.html                              http://www.perl.com

            http://www2.latech.edu/~acm/Helloworld.shmtl

 

Credit: 3 hours                                                                        Prerequisites: CSc 3102

Course Catalog Description: Principles of programming language design; specification of syntax and semantics; underlying implementation of block structured languages; dynamic memory allocation for strings, lists, and arrays; imperative versus applicative programming; logic programming; modern programming languages and algorithmic analysis.

Course Outcomes: Master using syntax-related concepts, including context-free grammars, parse trees, recursive descent parsing, printing, and interpretation; master analyzing semantic issues associated with function implementation, including variable binding, scoping rules, parameter passing, and exception handling; master implementation techniques for interpreted functional languages; master using object-oriented and functional languages; be familiar with design issues of object-oriented and functional languages; be familiar with language abstraction constructs of classes, interfaces, packages, and procedures; be familiar with implementation of object-oriented languages; be familiar with using functional languages; be exposed to using logic languages.

Grading:

            Programming and Projects                                                                                30%

                        Hard copy if possible, if late up to 3 days then lose 10 points/day

            Research Paper                                                                                                25%

            Midterm examination                                                                                        20%

            Final examination - Wednesday, December 12 5:30-7:30 PM                       20%

            Participation                                                                                                      5%

Approximate Grading Scale: For undergraduate students: 85-100 A, 75-84 B,

65-74 C, 55-64 D, below 55 F.  For graduate students: 90-100 A, 80-89 B, 70-79 C, 60-69 D, below 60 F.

Exams – the midterm examination will be over the material covered in the first half of the semester; the final examination will be comprehensive but will emphasize the material covered in the second half of the semester.

Paper – all students must write a short (ten pages or so, but do not take that number literally), research paper along the lines of a bibliographic essay on some aspect of programming languages.  The paper should describe a concept and relay the state of the art in terms of the programming language topic chosen.  In other words, do not provide a tutorial; rather, focus on research.  The choices of topics must be approved by the instructor by the end of the third week of the semester.  The paper is due by the end of the twelfth week of the semester.  Also, do not simply concatenate several abstracts from papers, and do not rely solely on textbooks; rather, weave a pattern in terms of what research is going on with the topic selected.  This should be based upon the open literature in the filed, especially in terms of journal articles, conference proceedings articles, and even web sites if needed.  Do not forget to list your references and cite them in the paper.  Most importantly, do not copy entire sections of your sources, especially if you do not cite them.  It is academically, as well as intellectually, dishonest and violators will be caught and prosecuted.  Sample topics for this research paper include: special purpose languages (e.g., concurrency, design – such as UML, or functional programming – such as Haskell), net languages (e.g., HTML, SGML, VRML, Perl, Python, PHP, XML), application oriented languages (e.g., Visual Basic, other visual languages, Javascript, SQL), relatively new and interesting languages (e.g., C#, Ruby, ML), new environments (e.g., .NET), special features (e.g., data abstraction, exception handling), comparative studies (e.g., AWK versus Snobol, Scheme vs. Lisp vs. ML, Python vs. Perl), or modern issues in programming language translation.  Try to avoid the standard languages (e.g., Fortran, Cobol, Pascal, C, C++, Java, Prolog, or Lisp) as these will be discussed in class to some extent.  For students taking this course for graduate credit, a second paper is due at the same time as the first paper (the topic, which must be different than the first paper’s topic, is also due at the same time as the first paper’s topic) and should be more detailed with even more emphasis on research issues.

 

 

Assignments – late homework, programs and project will not be accepted.  Makeup exams will not be given.  Exceptional cases, such as illness or accidents, will be handled on an individual basis (the instructor must be notified prior to the test of the problem and proof presented – otherwise a score of zero will be given).  Students will have three class days from the date an assignment (homework, program, project, exam) is returned to seek corrections on the grading; after that, no changes will be made to the grade.   All programs must conform to the guidelines in the CSC Program Requirements Guide.  Programs must be done by the individual student unless the assignment is given as a group project, in which case collaboration across groups is prohibited.  All cases of plagiarism or collaboration on assignments or exams will be treated as academic dishonesty.  Homework problems may be assigned from time to time in class.  Written answers are due at the beginning of the class period on the due date given.  The homework grades will be part of the participation portion of your final grade.

Students are responsible for knowing all information presented in class and materials assigned for self-reading.  The students are strongly encouraged to ask questions in and out of class.  It is recommended that students keep copies of all the submitted materials.  It is important that students observe the student conduct code in doing works in this course.  Self study through reading the material BEFORE (and after) class and completing all the homeworks and project is very important for learning in this course. Topics:

            Preliminaries                                                                                         Chap. 1

design, implementation, environment

History                                                                                     Chap. 2

plankalkul, pseudocode, Fortran, Cobol, Algol, Pascal, Lisp,

Basic, C, C++, Ruby, APL, Snobol, C#, Modula, block

structured languages, Java, markup languages, graphical

languages, Raptor

Formal languages                                                                                  Chaps. 3,4

Compilers, syntax, semantics, lexical and syntactical

analysis

            Identifiers                                                                                             Chap. 5

Names, binding, type checking, scope

            Data types                                                                                            Chap. 6

            Statement level control                                                              Chap. 7

                        Expressions, assignment

            Review

            Mid-term Exam

            Subprograms                                                                                        Chaps. 8-10

                        Arguments, implementation, run-time stack

            Data Abstraction                                                                                  Chap. 11

            Object oriented programming languages                                    Chap. 12, Horstmann

                        OOP – C++, Smalltalk, Ada, Eiffel, C#, Java

            Functional Programming                                                            Chap. 15, Wilensky

            Lisp, Scheme, FP, ML, Haskell

Logic Programming – Prolog                                                     Chap 16, Bratko

 

Symmetric/concurrent programming                                          Chap. 13

            Parallelism

Exception Handling                                                                   Chap. 14

String languages – AWK                                                          -

Review

Final Exam     2/12 5:30-7:30 pm

 

 

CSc 4101 Programming Assignments

(Due dates may be revised during the semester)

 

1. Due 9/11  Consider the issue of compound interest.  Let P = the principle = the present value, n = years of investment (or loan), i = annual interest rate (expressed as a decimal), m = number of time periods in a year, S = the future value, and R = the payment rate.  These variables are related as follows:

            S/P = compound amount = single payment future value = (1+i/m)n*m

            P/S = single payment present worth factor = (1+i/m)-n*m

            S/R = uniform series compound amount factor = [(1+1/m)n*m-1]/(i/m)

            R/S = uniform series sinking fund factor =  (i/m)/[(1+1/m)n*m-1]

            P/R = uniform series present worth factor =

[(1+i/m)n*m-1]/[(i/m)*(1+i/m)n*m]

            R/P = uniform series capital recovery factor =

[(i/m)*(1+i/m)n*m]/[(1+i/m)n*m-1]

For example, a loan of P = $50,000 for n = 10 years at interest rate i = 0.08 (8%) can be repaid with a monthly (m = 12) of R dollars, where R is calculated using the R/P formula above.  Note that the total money paid is R*n*m but the worth of the money at the end of the loan is S (calculated using the S/P formula above).

            Write a program, in the programming language of your choice, that allows one to enter all but two of the variables (n, i, m, P, R, S) and calculate one or both of the other variables.  Note that one can calculate P given R, n, I, and m in a straightforward manner as the case with calculating R given P, n, i, and m or with calculating S given R, n, i, and m.  However, it may be more difficult, perhaps even involving root finding or trial and error methods, for solving for n or m or i, given the other variables.  For example, with the loan data given in the example above, we need to calculate R.  Now, suppose that the borrower wishes to refinance that loan over n = 20 years, still with a monthly (m = 12) payment, but needs to know what interest rate he/she can presume so that the monthly payments are half what they were before (R/2). – we need to calculate i.

            2. Due 9/25 Redo assignment 1 with at least one of your functions, perhaps the exponentiation function, being recursive (i.e., using recursion).

            3. Due 10/25 Redo assignment 2 with the recursive function replaced by manipulation of the user-created run-time stack.

            4. Due 11/8 Redo assignment 1 in Lisp, or a similar functional programming language (e.g., Scheme).

            5. Due 11/29 Redo assignment 1 in Prolog.

 

            6. Due 12/4 Redo assignment 1 in Java (either as a regular program or as an applet).

            Project – Homeworks 7-10 Due 12/4 – Boolean Query Parse Tree For this project, you must implement a mechanism to create and output a parse tree for a Boolean query for a search engine.  First, to understand Boolean queries, consider any input to a standard search engine, perhaps a web search engine such as Google.  The input query will consist of a series of keywords (which may be a single term such as “jobs” or consist of multiple terms such as “knowledge management systems”) along with the Boolean (logical) operators (AND, OR, and NOT).  For example, “fuzzy” AND “information retrieval” AND NOT “probability”.  While you need not worry about errors (bad queries such as “dogs AND) but you may not assume that queries are in normal form (neither conjunctive nor disjunctive normal form).  Your mechanism must input a series of Boolean queries.  Then, for each query, identify the Boolean (logical) operators (AND, OR, and NOT),  as well as any open or closed parentheses, parse that query, determine the parse tree for that query, and output that parse tree.  An object-oriented approach, and perhaps an object oriented programming language, is recommended.

            Like any tool that processes text, your mechanism needs to do lexical analysis and parsing, which implies storing the input in some internal data structures.  This mechanism should incorporate the following components, a lexical analyzer that splits the input text into tokens, a parser that analyzes the structure of the input query and builds a parse tree (a recursive descent parser is recommended), and a parse-tree traversal that outputs the parse tree.

            The lexical analyzer should input and break down the query into individual terms or operators.  These terms or operators are then represented as tokens and passed to the parser.  Your lexical analyzer needs to do the following: i) discard white space (blanks, tabs, newline, carriage-return, and form-feed characters); ii) discard comments (everything on a line to the right of the semicolon ending the query to the enc of the line); iii) recognize open and closing parentheses; iv) recognize the Boolean (logical operators (AND, OR, and NOT); v) recognize the terms in the query.  You should also be concerned with whether or not your mechanism can distinguish between upper and lower case characters in the terms or in the operators.  It is therefore recommended that it is simpler if you convert all tokens to lowercase.

            The parser gets tokens from the lexical analyzer and analyzes the syntactic structure of the token stream.  Since Boolean queries have a simple grammar, using a recursive descent parser should not be too difficult.

Administratively, you can work in teams (2-3 students per team is recommended).  Moreover, an “extreme programming” style, with one person sitting in front of the computer screen with at least one other team member suggests what is to be entered.  When turning in your program(s), provide a brief explanation how your program was designed, what works, and what doesn’t as part of your external documentation.  It is noteworthy that perhaps the hardest parts of the project are understanding the data structures and understanding the object oriented programming.  To make this project easier, look at the lexical analyzer and the token data structure first, implementing the analyzer afterwards.  Still later, you can add the parse tree data structure and write the parser and output components.  Note that an input file of queries will be given to you after the midterm exam.


Bonus Program 1. Due 12/6 Redo assignment one in Python, Perl, Ruby, PHP, or XML (or another language if approved by your instructor).  A good front end is required for using your program for full bonus credit.    This can be done in a team of 2-3 students.

Bonus Program 2. Due 12/6 Write an AWK program to count the number of times each word is used in a given text file and test it on a file to given to you.  However, you must ignore words given in a stopword list, also to be given to you.  This can be done in a team of 2-3 students.

 

Good luck!