CS 450 Structure of Higher Level Languages

advertisement
CS450-Spring15-Campbell - home
http://cs450-spring15-campbell.wikispaces.umb.edu/home?f=print
home
CS 450 The Structure of Higher Level Languages
Bill Campbell[1]
Spring 2015
Hi, my name is Bill Campbell. This course, as taught at UMB is a story of computation based on the
text by Ableson and Sussman, Structure and Interpretation of Computer Programs. This is both a
beautiful story and a challenging story. It requires a lot of reading, a lot of thinking, a lot of programming
and a lot of writing. I speak from recent experience.
This is my first time teaching this course. True, a long, long time ago I read the Ableson and Sussman
text, I wrote Lisp programs and I wrote the UMB Scheme interpreter. But I've only recently sat down to
do the the exercises in the manner that I will ask you to do them. They are no walk in the park -- I found
them challenging. But there is beauty in doing these exercises. I think you will find this work worthwhile.
I can honestly say that learning Lisp programming many years ago has greatly influenced my
programming, no matter what language I work in; and it still does.
I will follow the course as designed by Professor Carl Offner. Professor Offner has designed an
excellent set of exercises and has written up some terrific notes for the course. We shall use these. Of
course, while the exercises and handouts are due to Professor Offner, I take responsibility for any
errors on the wiki postings and in the handouts.
Prerequisites
CS 310: Advanced Data Structures and Algorithms
CS L320: Applied Discrete Mathematics
These prerequisites are important. If you haven't completed these satisfactorily you will have difficulty
with this course. Really. This is a difficult course. You will spend many hours each week doing the work.
You will succeed only if you are sufficiently prepared. Working hard is necessary but not sufficient (all of
us will be working hard); you must be prepared.
Textbook and Readings
Harold Abelson and Gerald Jay Sussman with Julie Sussman,
Structure and Interpretation of Computer Programs, Second Edition (paperback),
MIT Press, 1996, ISBN: 978-0-262-51087-5.
Certainly one of the best CS books ever written. Buy it and read it.
This text is a narrative, meant to be read from beginning to end. It's not an encyclopedic
reference that we refer to each time we have a question. It tells a story. We must read the
story to enjoy it. It's a beautiful story.
If you like reading on line, you may find it at http://mitpress.mit.edu/sicp/full-text/book
1 of 6
2/6/15, 7:16 PM
CS450-Spring15-Campbell - home
http://cs450-spring15-campbell.wikispaces.umb.edu/home?f=print
/book.html .
A Scheme reference manual. One of these:
IEEE Standard for the Scheme Programming Language. (IEEE Std 1178TM-1990
(R2008)) . You will need to log into the UMB Healy Library to get access to this.
This is the reference against which I originally implemented UMB Scheme.
Revised5 Report on the Algorithmic Language Scheme, available on line at
http://www.schemers.org/Documents/Standards/R5RS/r5rs.pdf .
This is very close to what is implemented on UMB Scheme and describes a
version available on DrRacket (see below).
A brief tutorial on using emacs with Scheme at http://community.schemewiki.org/?emacstutorial . Not an emacs turorial -- it has its own; inside emacs type C-h t. But it shows us how
we can use emacs with Scheme.
Paul W. Abrahams and Bruce R. Larson. Unix for the Impatient (Second Edition), AddisonWesley, 1997. The book comes with a CD that you might find useful as well. It covers the basics
of the typical Unix environments, and also gives a nice short introduction to the Emacs editor,
which you should absolutely learn now if you haven't yet—see the note above. To find the best
price for this book, go to http://www.addall.com and search for it.
Syllabus
We will cover Chapters 1 and 2 of the text very quickly. Then we will spend a major amount of
time on Chapters 3, 4, and 5. Chapters 1 and 2 cover functional programming, data abstraction,
and the duality between data and operations on data.
Chapter 3 covers imperative programming, programs with mutable state, delayed operations,
and some remarkable programs that can be built with these capabilities.
Chapter 4 describes a Scheme interpreter written in Scheme. We will modify that interpreter in
order to study different ways in which languages behave and how they can be implemented so
as to behave in those ways.
Chapter 5 discusses three programs:
1. An abstract register machine simulator. This simulator reads programs written in an
assembly language. Each such program describes a special-purpose register machine.
The simulator "assembles" such a program into a model of the machine and then runs
the machine.
2. An explicit-control evaluator that is similar to the Scheme interpreter from Chapter 4,
except that it is itself a register machine, rather than a Scheme program, and so is
executed by the register machine simulator.
3. A Scheme compiler, which like the interpreter of Chapter 4 is itself a Scheme program
that takes as input a Scheme expression or program, but instead of interpreting the
Scheme source code, it generates register machine code out of Scheme input. This code
can itself be executed by the register machine simulator.
Course Work and Grading
There will be no exams. All the work in this course will be homework. There will be 10 assignments,
each involving some written work and also some programming. Each assignment will involve an
2 of 6
2/6/15, 7:16 PM
CS450-Spring15-Campbell - home
http://cs450-spring15-campbell.wikispaces.umb.edu/home?f=print
extensive amount of work.
Assignments 1, 2, and 3 will be somewhat easier than the others (and will count for somewhat
less when I calculate grades). The assignments will be handed out with ample time allowed to
finish them. I will not accept late assignments.
All Scheme code that you write in this course must work under UMB Scheme as installed here
at UMB. The sources for UMB Scheme are publicly available, and so you may install this also on
your own machine at home or elsewhere if you wish. (If you are on a Linux system and you are
trying to compile from the sources and you are having problems, try using the modified sources
in ~offner/tools/src/scheme-3.2-for-Linux.tar.) But if you do this, please be sure to double-check
by running your code here at UMB before it is due.
UMB Scheme has very minimal support for debugging. There is one other Scheme interpreter
that is much more useful in that respect and that you may want to make use of:
DrRacket (formerly called "DrScheme"): Available for Linux, Mac OSX, and Microsoft
Windows. If you use DrRacket, set the language to "R5RS". (Ask me if you can't figure
out how to do this.) This will probably be pretty close to what UMB Scheme supports. But
be careful: you still have to test this on UMB Scheme as installed here.
Once again: if you use DrRacket (or any other Scheme interpreter) make sure your code
continues to work here under UMB Scheme.
A Note About Written Work
An important part of this course is for you to begin to learn how seasoned engineers design and
implement projects. To do this, they have to communicate clearly with each other. In almost every
assignment, I will ask you to write down some explanations, some thoughts on design, or something
similar. I expect these essays to be written clearly, so that I can understand what you are saying.
Remember—it is not my job to guess what you mean, any more than it is the computer's job to guess
what your programs mean. A significant part of your grade in this class will be determined by this
written work.
In particular, you should always run a spell-checker on your written work, and you should look it over
for proper grammar and usage. I am going to be pretty serious about this. Spelling errors are easy to
catch with a spell checker, and I expect you to use one.
Also, this is written work, not text messaging to your buddies. "u" is not how you spell "you". "2" is not
how you spell "to". "thanx" is not how you spell "thanks". You want to be a professional; here is the time
to start writing like one.
I understand that there may be students in this class whose first language is not English. Whether or
not this is true in your case, I am quite willing to help each of you in any problems you may have
expressing yourself clearly—just come to my office hours or send me email, and I'll be glad to help as
much as I can.
The work you hand in must be in plain text. It can't be in Microsoft Word format or anything else with
embedded control characters. And it can't have any lines longer than 80 characters. I really mean this.
It won't print out right if it has long lines. Unfortunately some students don't tend to take this seriously,
3 of 6
2/6/15, 7:16 PM
CS450-Spring15-Campbell - home
http://cs450-spring15-campbell.wikispaces.umb.edu/home?f=print
so let me just say that I plan to take points off for lines that are over 80 characters in length.
Here are some suggestions for how to produce acceptable text files:
1. If you prepare plain text on a Microsoft platform, then when you transfer it to the Unix system at
UMB the line endings will most likely be all wrong. You many not notice this, since many editors
and text viewers are forgiving about this. But it will definitely screw up my printing scripts.
Fortunately, it's quite easy to fix. On Unix at UMB, just run
dos2unix your_original_file and it will fix up your file.
2. You can configure emacs so that it will help you keep your lines to a maximum of 80 characters
by creating (if you don't already have) a file named .emacs (note the initial dot) in your home
directory, and putting the line
(setq-default fill-column 80) in it. (setq is the emacs lisp version of set! in Scheme, and
setq-default is a variant which seems to be needed here.) Then if you place the point (i.e.,
the cursor) anywhere in a paragraph and type M-q (i.e., "meta q", which you can always do by
typing the escape key and then q, although often the "alt" is bound to "meta", and it acts as a
shift key—you hold it down while typing the q), then the paragraph will get adjusted so that no
line is more than 80 characters long.
3. Another useful thing to put in your .emacs file is this line:
(setq ispell-check-comments t) This will cause the built-in spell checker in emacs (which is called
"ispell") to check spelling of words inside comments as well as everything else. This is probably
what you want.
4. And here is a third line for your .emacs file:
(setq-default indent-tabs-mode nil) This stops emacs from using TAB characters when
performaing automatic indentation. This is almost always what you want—TAB characters tend
to screw things up, and you want to avoid them.
A Note About Emacs
Learn it. If you haven't learned it yet, learn it now. It will be very useful to you in your whole career. In
this course you can't use any sort of WYSIWIG editor like Microsoft Word, and simple-minded editors
like notepad and such are going to cause you all sorts of problems. Believe me, I've seen this again
and again. I know that students are under all sorts of time pressure, and I have seen too many
students who just figured they didn't have time to learn emacs and so would just struggle through using
vi or notepad or whatever. They invariably ended up making a lot more work for themselves than if they
had just spent some time and learned emacs. And in almost all cases, the work they handed in was
extremely sloppy and caused a lot of headaches for both me and the grader.
So learn emacs. You'll thank me for this some day.
Asking Questions
Many students shy away from asking questions. Sometimes they think it will make them look stupid.
Often they think I will have a low opinion of them.
Exactly the opposite is true. I expect you to ask me questions. Asking me questions does not lower
your grade. It does not indicate to me that you are ignorant. What it does tell me is that you are taking
4 of 6
2/6/15, 7:16 PM
CS450-Spring15-Campbell - home
http://cs450-spring15-campbell.wikispaces.umb.edu/home?f=print
this work seriously. That's a very good thing. My lectures go better when students ask questions; I think
that's my style.
As this is my first time teaching this course, I'll have lots of questions myself. Let's see if we can
answer them together.
If you don't ask questions, I worry that you are not really understanding this material.
Even if you think your question is "stupid", please ask it anyway. In the first place, I've never really been
asked a stupid question. In the second place, my job is to answer your questions. You are paying good
money for this course. You are entitled to get your questions answered, and I'm very happy to do this.
Finally, I guarantee you that if you ask a question in class, there will be several other students with the
same question, and they will be so grateful to you for asking it. So don't be afraid. Many times I have
found that it is the very best students in the class who ask the most questions.
Reaching Me
My office is S-3-183; it is just behind the department office. My office hours are in my .plan . My office
telephone number is 617-287-6449; my home telephone number is 617-547-2738. Please do not
telephone me at home before 9am or after 10pm. My email address is william.campbell@umb.edu ; I
read my email regularly.
If you have a question about something you don’t understand outside of class, use the discussion
group associated with the particular assignment. Perhaps one of your classmates will answer it.
Perhaps I will. If your question is of a strictly personal nature, e.g. about a grade or a request for a
face-to-face meeting, by all means use email. But beware: should your question be of the sort that the
entire class may want the answer to, I’ll ask you to repost it on the discussion page. Get used to this
site; it’s a good way to hold discussions over the Internet.
Some University Policies
Student Conduct and Plagiarism: Students are required to adhere to the Code of Student
Conduct.
Accomodations for Students with Disabilities
Section 504 of the Americans with Disabilities Act of 1990 offers guidelines for curriculum
modifications and adaptations for students with documented disabilities. If applicable, students
may obtain adaptation recommendations from the Ross Center for Disability Services, M-1-401,
(617-287-7430). The student must present these recommendations and discuss them with each
professor within a reasonable period, preferably by the end of Drop/Add period.
1. ^
The material on this page is due to Professor Carl Offner.; much of it is taken verbatim. Of
course, I take responsibility for any errors.
! Add Discussion
5 of 6
2/6/15, 7:16 PM
CS450-Spring15-Campbell - home
6 of 6
http://cs450-spring15-campbell.wikispaces.umb.edu/home?f=print
2/6/15, 7:16 PM
Download