- The winners of the 4120 Compiler Bakeoff have been announced.
- Course grades have been released.
An introduction to the specification and implementation of modern compilers. Topics covered include lexical scanning, parsing, type checking, code generation and translation, an introduction to optimization, and compile-time and run-time support for modern programming languages. As part of the course, students build a working compiler for an object-oriented language.
Instructor: Andrew Myers
Placeholder for staff
The best way to reach the course staff is normally by posting on Piazza. However, for private correspondence you can email individual staff members. Please do not ask multiple course staff memberes the same question privately via email. Piazza is the right way to ask questions about course content or assignments.
Computer Science 3110 and either CS 3410 or 3420. The practicum (CS 4121 or 5121) is a required co-requisite. You may not take CS 4120 without taking CS 4121 too, and similarly for CS 5120 and CS 5121. The reason for this is that the group project is part of the grade for both 4120 and 4121. Familiarity with programming in Java is also expected.
Lectures are MWF 2:30–3:20, in Hollister B14. Attendance at lecture is expected.
You are required to read the course notes posted on the web site. These will often contain more detail than what was presented in lecture.
There is no required textbook this semester, but the following textbooks will be helpful sources of information. All of these books will be available on reserve in Uris Library.
- Modern Compiler Implementation in Java, 2nd ed. Andrew Appel and Jens Palsberg, Cambridge University Press, 2002. ISBN 0-521-82060-X.
- Compilers—Principles, Techniques and Tools (The “Dragon Book”), 2nd ed. Alfred Aho, Monica Lam, Ravi Sethi and Jeffrey D. Ullman. Addison-Wesley, 2006. ISBN: 0-321-48681-1
- Engineering a Compiler. Keith Cooper and Linda Torczon. Elsevier/Morgan Kaufmann, 2004. ISBN 1-55860-698-8.
- Advanced Compiler Design and Implementation. Steve Muchnick. Morgan Kaufmann Publishers, 1997. ISBN 1-558-60320-4.
- The Java Language Specification. James Gosling, Bill Joy, and Guy Steele. Addison-Wesley, 1996. ISBN 0-201-63451-1
Another useful text, on linking and loading, is:
Here are a couple of useful books on coding and software engineering:
- Design Patterns: Elements of Reusable Object-Oriented Software. Gamma, Helm, Johnson, Vlissides, Booch. Addison-Wesley, 1995. ISBN 0-201-63361-2
- Refactoring: Improving the Design of Existing Code. Martin Fowler. Addison-Wesley, 1999. ISBN 0-201-48567-2.
Assignments and Grading
There are four written homework assignments. You may discuss assignments with other students, but the work must be done on an individual basis. The names of any students you discussed the problems with must be recorded with the corresponding problems.
The compiler project is divided up into seven programming assignments that are due at various points throughout the term. Compiler projects will be performed by groups of three or four students. The same groups will be maintained throughout the semester, if possible.
Except in unusual circumstances, you will receive the same grade in CS 4120 and CS 4121 (resp. 5120 and 5121), and all members of a group will receive the same grade on programming assignments. Exceptions to these rules are dealt with on a case-by-case basis.
The breakdown of points per assignment is as follows:
|Homework: 15%||Homework 1||4|
|Programming Assignments: 50%||Programming assignment 1||5|
|Programming assignment 2||6|
|Programming assignment 3||6|
|Programming assignment 4||7|
|Programming assignment 5||8|
|Programming assignment 6||8|
|Programming assignment 7||10|
|Prelims: 35%||Prelim 1||15|
Assignment late penalties:
We are flexible about submitting assignments late. Unless otherwise specified, assignments may be turned in late with the following penalties applied to the score received:
- 1 day late: −5%
- 2 days late: −15%
- 3 days late: −30%
- 4 days late: −50%
- >4 days late: we probably will not grade it
Homework and programming assignments will be accepted up to 4 days late, but at a penalty. The penalty is 5% for one day late, 15% for two days late, 30% for 3 days late, and 50% for 4 days late. Weekends are considered to be a single day when applying this formula. So turning in your assignment on Sunday night is no worse than turning it in on Saturday.
Late penalties may be avoided or reduced by obtaining an extension on the assignment. However, any extensions must be approved by the instructor at least two days before the due date—last-minute extensions will not be granted except in exceptional circumstances. Extension requests should be made via email; copying all group members on the request. They should include a description of why an extension is being requested.
The prelims will cover material from the textbook, lectures, and homework assignments. Both prelims will be evening exams. There will be no final exam, but your final report and demo will be due on the first day of finals.
We expect you to participate in class and elsewhere. 2% of the score will be for class participation (in-class, Piazza, course evals) and for in-class quizzes.
The Cornell Code of Academic Integrity will be strictly enforced in this class. A Cornell student's submission of work for academic credit indicates that the work is the student's own. All outside assistance must be acknowledged, and students' academic position must be truthfully reported at all times. We take cheating and fraud very seriously.
Placeholder for schedule
Course notes for individual lectures and recitations can be found on the course schedule.
The default programming language for this course is Java, though some project groups may choose to use other programming languages. Java is a fairly good programming language for building a compiler. Its strong static typing, automatic garbage collection, and modular data abstraction are all very helpful when building complex software such as compilers. The tool support for Java is also excellent.
• The Java API is very useful for learning how to use the many existing Java class libraries.
• The Java Language Specification is helpful if you want to really understand how Java works.
For students with limited Java experience, we recommend the online notes from CS 1130, Transition to Object-oriented Programming as a refresher. This is a self-paced course consisting of several modules that you can go through at your leisure.
Review the introductory chapters in the textbook and the Java reference books listed on the course info page.
See Oracle's official Java Tutorial.
For students with C++ experience, see this comparison of C++ with Java.
There are many valuable resources that can help you take your programming skills to the next level. Here are a few links:
Software Development Methodologies
Just for Fun
- How not to program
- Teach Yourself Programming in Ten Years
- Quines (Self-Reproducing Programs)
- Powers Of Ten
- Programming Quotes
- How To Become A Hacker
- How To Write Unmaintainable Code
- History of Operator Precedence
- Software Bugs & Glitches
- Doom for System Administration
- The International Obfuscated C Code Contest
- The Easter Egg Archive
- OOP Criticism
- Esoteric Programming Languages
If you are taking this course, you should have access to the Undergraduate Computing lab (formerly known as the CSUG lab) on the ground floor of Upson. This can be a convenient place to work with your group.
Cornell Information Technologies (CIT) runs several computer labs across campus for all members of the Cornell community. The JDK and Eclipse are installed on these machines. Check here for locations and times of operation.
You can also find the course software in the Academic Computing Center (ACCEL), located in the Engineering Library in Carpenter Hall. Any CS student may register for an account.
Academic Excellence Workshops
The Academic Excellence Workshops (AEW) offer an opportunity for students to gain additional experience with course concepts in a cooperative learning environment. Research has shown that cooperative and collaborative methods promote higher grades, greater persistence, and deeper comprehension. The material presented in the workshop is at or above the level of the regular course. We do not require joining the AEW program, but do encourage students to join if they are seeking an exciting and fun way to learn. The AEW carries one S/U credit based on participation and attendance. The time commitment is two hours per week in the lab. No homework will be given. This is a wonderful opportunity for students to seek extra help on course topics in a small group setting.
Your fellow undergraduate students, who are familiar with the course material, teach the sessions with material that they prepare. The course staff provide guidance and support but do not actually teach the AEW course content or any session. A representative from the AEW program will be speaking about the program and registration procedures in lecture.
Your AEW liaison for this semester is Jason Zhao.
See the AEW webpage for further information.
Other Support Services
|Student Resources For Engineering Students||This site has links to a variety of services.|
|Free Computer Training||CIT offers free computer training throughout the semester. Email firstname.lastname@example.org for an appointment.|
|Student Web Services||This website collects services that are more general.|
|Engineering Advising||Academic advising for engineering students.|
|Arts College Student Services||A listing of general support services for a variety of concerns students may have.|
|Tau Beta Pi||Tau Beta Pi Engineering Honor Society Tutoring Program. The members of Tau Beta Pi are selected for their academic aptitude and social commitment. They hold one-on-one tutoring sessions with students in courses that typically have a large enrollment of engineers.|
|Learning Styles||Not everyone learns the same way. If you are curious about how you learn, check out this collection.|
|Gannett||The Cornell University Health Service Center. For all health related concerns.|
|CAPS||If you are experiencing emotional distress, we urge you to contact CAPS, the Counseling and Psychological Services.|
|Dear Uncle Ezra||When all else fails, ask Uncle Ezra!|
- Homework 1: Lexical Analysis
- Homework 2: Syntactic Analysis
- Homework 3: Semantic Analysis
- Homework 4: Program Analysis
- Programming Assignment 1: Implementing Lexical Analysis
- Programming Assignment 2: Implementing Syntactic Analysis (released files) (pretty-printer documentation)
- Programming Assignment 3: Implementing Semantic Analysis
- Programming Assignment 4: Intermediate Code Generation (released files)
- Programming Assignment 5: Assembly Code Generation (released files)
- Programming Assignment 6: Optimization
- Programming Assignment 7: Object-Oriented Features (released files)
Other resources for programming assignments:
- How to lose in CS 4120
- Overview document requirements for group project assignments
- Xi language specification
- Simple Xi code examples
- Vagrant Virtual Machine
- xic test harness
- Xi syntax highlighting support for vim.
- Xi type system specification (source)
- Xi ABI specification
- oXi language specification