\documentclass[12pt]{article}
% \usepackage{fullpage}
\advance \textheight by \topmargin
\advance \textwidth by \oddsidemargin
\topmargin 0pt
\oddsidemargin 0pt
\evensidemargin 0pt

\newcommand{\unix}{\(\mbox{Unix}^{\!\textsc{tm}}\)}

\begin{document}

\title{Computer Science 270 \\
Survey of Programming Languages}

\author{Dr. Stephen Bloch \\
office 114 Alumn\ae\ Hall \\
phone 877-4483 \\
email \texttt{sbloch@adelphi.edu} \\
Web page \texttt{http://www.adelphi.edu/sbloch/} \\
Class Web page \texttt{http://www.adelphi.edu/sbloch/class/270/} \\
office hours MThF 1:00-2:15, T 9:00-2:15}

\maketitle

\section{Who Should Take This Course}
Students taking this course are expected to have successfully completed
CSC 171 (``Introduction to Computer Programming'') and CSC
172 (``Introduction to Algorithms and Data Structures''), or their
equivalents at another college.  (If you took these courses at another
college, please contact me privately, tell me what language(s) you used,
and we'll discuss what you and/or I need to do to adapt.)
This is
largely a programming course, so students should expect to spend a lot
of time designing, writing, testing, and debugging programs.  If you
don't meet these prerequisites and aren't already a hot-shot hacker, I
strongly urge you not to take this course.

\section{Subject Matter}
If you're taking this course, you are already comfortable with the
notion of writing a program, and you've learned some of the techniques
and data structures most often used in computer programs, especially
Scheme and/or Java programs.  But those are only two of literally hundreds of
computer languages, each with its own strengths and weaknesses.  A
programmer who approaches every problem thinking about how to solve
it in, say, Java is like a carpenter who uses a hammer on everything, even
when a saw or a screwdriver would be more appropriate.  A competent
programmer must be able to \emph{select} the most appropriate language
for any given problem.  Furthermore, a competent programmer must be able
to \emph{write idiomatically} in each language, \emph{i.e,} to write in
the style to which that language is suited: don't be like a carpenter who
chooses a screwdriver as the appropriate tool, but still uses
it like a hammer.  Finally, a competent programmer must be able to
\emph{learn} a new language and its idiom quickly.

We'll spend the first half of the semester learning the C++ language.
Java, which most of you learned last semester, was intentionally modelled
after C++, but with a number of simplifications and safety measures, and
with some useful features removed.  The syntax will look extremely similar,
and most of the concepts are the same, so all we need to learn is how to
live without the simplifications and safety measures in C++.  In brief:
\begin{itemize}
\item C++ allows functions and variables that are not associated with any class
(sorta like Scheme functions and variables).
\item C++ allows local variables to be allocated automatically on the stack, rather than on the heap
with ``new'' (if you don't know what this means, just wait....)
\item C++ allows the explicit use of pointers and references
(in Java, almost everything is a reference, and you seldom need to think about what is and what isn't).
\item C++ arrays are less sophisticated than Java arrays, and are not bounds-checked (so you can easily
refer to the 15th, or even the -15th, element of a 10-element array).
\item C++ requires you to deallocate any memory that you allocated (Java does this automatically
for you using a ``garbage collection algorithm'').
\item C++ strings are just arrays of characters, so they can't do as many tricks as Java Strings
(but there's a standard C++ String class as well).
\item A C++ subclass can override a method of its superclass, yet calling the method on an object
of that subclass may still invoke the superclass's method rather than the subclass's method unless
the object is referred to with a pointer.
\item In C++, you can redefine the built-in operators like +, -, *, /, <, =, ==, ++, etc. to mean
just about anything you want, depending on the types of their operands.
\item A C++ class can declare other specific classes to be its trusted ``friends'',
allowing those other classes to access the internals of this class.
(Or, to put it more lewdly, ``in C++, your friends can play with your private members.'')
\item C++ allows you to define methods and classes parameterized by a type.  (That sounds weird, but
it turns out really useful, and I wish Java had it.)
\item C++ makes it much easier to do simple text I/O.
\item There are lots of niggling little syntactic differences to memorize between C++ and Java.
\end{itemize}

After the midterm exam, we'll spend about a month on the C language, the (much simpler)
ancestor of C++.  C, and to a lesser extent C++, is widely used
in connection with the \unix\ operating system, which most
of you are studying concurrently in CSC 271.
We'll also discuss how to use a debugger, an immensely valuable
program that helps you see where your C and C++ programs are going wrong and
how to fix them.

After Thanksgiving, we'll switch to a very different language named
Prolog.  Prolog was developed in the 1970's for applications in
artificial intelligence, particularly expert systems, and it is still
widely used in that area.  If switching between Scheme and Java required
you to ``shift mental gears'', Prolog will require you to shift into reverse,
as most Prolog programs basically say ``I could solve this problem if only
I could first solve those three other problems.  I could solve those other problems
if only \ldots''.
Nonetheless, those of you who miss Scheme will find Prolog somewhat similar. 
Prolog requires completely different ways of thinking about
programming:  some of the problems you would work hard to solve in C++,
Java, or even Scheme are
trivial in Prolog, while other problems you wouldn't have even thought
of from those mindsets become serious and reasonable questions in Prolog.

\section{Texts}
This semester we'll use several ``textbooks'': 

\begin{itemize}
\item Timothy Budd's \emph{C++ for Java Programmers}.  'Nuff said.
\item Bjarne Stroustrup's \emph{The C++ Programming Language}.  Stroustrup invented
C++, almost single-handedly, in the early 1980's, and his book is still the definitive
reference on it.  He also included a lot of good advice on object-oriented programming
and design.  This book, however, is \emph{optional}.
\item On-line documentation and tutorials for Prolog at \verb|http://www.amzi.com|.
\end{itemize}

\textbf{You are responsible for everything
in the reading assignments, whether or not I discuss it in a lecture.}
You are also responsible for checking my class Web page and the WebBoard
at least once a week or so for assignments, corrections to assignments,
solutions to assignments, \emph{etc.}.

\section{Grading}
I expect to give ten small programming assignments, one every week or two.
Most assignments are to be turned in by email, and will be considered late
if the time stamp on the email is after midnight on the assigned due
date.  Assignments turned in up to a day late lose 30\% credit; those up
to two days late lose 60\% credit; and beyond that, they'll lose 90\%
credit (\emph{i.e.} the best grade you can hope for is 10\%.)
Any homework assignment turned in after midnight, Friday, Dec. 15 (the 
last day of class) will get a zero, so that I have time to grade them all
before the final exam.

There may also be a few brief in-class quizzes (say, 15 minutes each)
on the details of whatever language we're studying at the time.
Each quiz will count for 2\% of your semester grade.  Quizzes cannot be made
up; if you're not there the day I give the quiz, you get a zero on it.

% These numeric grades will be converted to letter grades as follows:
% I'll draw a curve showing the distribution of numeric grades, and look
% for naturally-occurring ``clumps''.  For each clump, especially the
% top and bottom ones, I'll examine some exam and
% homework papers to decide what letter grade seems appropriate.  This
% method corrects for excessively hard or excessively easy assignments
% while not penalizing anybody for having genius classmates.

We'll also have a two-hour final exam on Dec. 22,
weighted like one or two programming
assignments; more details to come.

The final exam must be taken at the scheduled time, unless arranged in advance
or prevented by a documented medical or family emergency.  If you have
three or more exams scheduled on the same date, or
a religious holiday that conflicts with an exam or assignment due date,
please notify me in writing within the first two
weeks of the semester in order to receive due consideration.
% (and I'd
% prefer it if you let me know earlier --- you should know within the
% first week of class when all your exams are).
Exams not taken without one of
the above excuses will be recorded with a grade of 0.


\section{Program standards}
Every program must contain, in the first few lines, a comment indicating the name(s)
of the student(s) working on it and which assignment it is.  Programs not containing
this information, clearly visible, will get a zero.

Every program must be accompanied by a session log (I'll show you how to do this)
showing how the program works on test cases.
Programs with inadequate or poorly-chosen test cases will lose points;
programs turned in with no test runs at all will lose
\emph{lots} of points.

Every program must be adequately and accurately commented, as appropriate in the current language.

Having done my share of programming, I know that sometimes you hit a brick wall and cannot
get the thing to work for love or money.  If this happens, turn in the program together with
a concise description of how the program fails, what you've tried in your attempts
to fix it, and how those attempts didn't succeed.  You won't get full credit, but if I'm
convinced that you're working on it diligently, you'll get some partial credit.
Note that ``how the program fails'' does \emph{not} mean saying ``I got an error message'';
you need to tell me \emph{which} error message you got, \emph{when} you saw it, and
\emph{what} you think the error message means.  Similarly, if the program fails by producing
wrong answers, you need to tell me \emph{when} it produces wrong answers
(are they \emph{all} wrong, or just in a few cases?),
\emph{how} they are wrong (\emph{e.g.} are all the numbers consistently higher than you expected,
are they the negatives of the correct answers,
or are they all over the place with no apparent pattern?), and your speculations on \emph{how}
such an error might have arisen.  I'm requiring all this not because I'm mean and horrible, but
because by the time you've written all this down, you may have enough information to actually
\emph{fix} the problem, which is much better than turning it in incomplete.

For those of you who used PSP in CSC 171 and 172 last year, I've set it up (and improved it
somewhat) for this class's use too.  You are invited to use it to record your time, program
size, and defects encountered, but I don't plan to grade it this semester.
This year you'll get to it by logging into WebBoard and reading the announcement entitled
``PSP Forms''.

% Programs are not abstract works of art,
% they are supposed to run and solve real problems.  So if I get a program
% that doesn't compile or run, or a program that has little or nothing to do
% with the problem I assigned, I will give it a zero, no matter how much
% time you put into it.  Don't bother turning in a program you haven't
% tested yourself.
 
\section{Ethics}
Most homework assignments in this course involve writing, testing, and
debugging a program.  For most of these assignments, you are to work in
teams of two students (switching teams from one assignment to the next);
for other assignments, I may ask you to work individually.

When I say
``teams of two students'', I don't mean ``you write the first half of the
assignment, and I'll write the second half''; I want \emph{both} students
working \emph{together} on \emph{all} of the assignment, using the techniques
of Pair Programming: two people using one workstation, with one typing and
the other ``looking over the first one's shoulder''.  If you haven't
encountered this approach before, I'll point you to a good article about it.

It's hard to define what constitutes ``cheating'' in this sort of
course.  Students are encouraged to help one another with mechanical and
linguistic difficulties (``how do I save this file?'', ``how do you declare
a static instance variable?'', \emph{etc.}), regardless of whether
they're on the same team, but designing, coding, testing, and debugging 
should be done by team members.  It's remarkably easy for a professor to
notice when three different teams have turned in nearly-identical
programs; if that happens, I'll grade it once and divide the credit
among the three, so the best any of them can hope for is 33\%.

All work on quizzes and the final exam must be entirely the work of the one
person whose name is at the top of the page.  If I have evidence that
one student copied from another on an exam, \emph{both} students will be
penalized; see above.

% \pagebreak

\section{Schedule}
This class meets every Monday, Wednesday, and Friday from 11:00-11:50 PM;
the final exam is from 10:30--12:30 on Dec. 22.

All dates in the following schedule are tentative, except those fixed
by the University; if some topic listed here as taking one lecture in
fact takes two lectures to cover adequately, or \emph{vice versa},
the schedule will shift.

% In no case will an assignment be due earlier than indicated in the
% following schedule, but some may be due later; this will be announced
% in class a reasonable time in advance.  I'll try to keep an updated
% version of this schedule available online.  

I expect you to have read the reading assignments 
\emph{before} the lecture that deals with that topic.  
This way I can
concentrate my time on answering questions and clarifying subtle or
difficult points in the textbook, rather than on reading the textbook
to you, which will bore both of us.  \textbf{Please read ahead!}

When I say ``read'' above, I
mean an active process, involving not only the textbook but
pencil, scratch paper, and a notebook for writing down key points.
Finally, and perhaps most importantly, you'll need a computer for trying
out the new ideas you find in your reading.  Just as you cannot learn
to drive a car or to cook just by reading about it, you cannot
learn about programming just by reading about it.  In short,
\emph{every} time you read about a new programming idea, \emph{try it!}
% Each chapter of the \emph{Thinking in Java} book contains several
% self-test exercises, which you are encouraged to do as you come to them,
% whether assigned as homework or not.


% \begin{tabbing}
% {\bf Date(s)} \=
% {\bf Assignment \hskip1.5em} \=
% {\bf Reading \hskip4em} \=
% {\bf Subject} \kill
% {\bf Date(s)} \>
% {\bf Assignment} \>
% {\bf Reading} \>
% {\hskip3em \bf Lecture Subject} \\
% %
% 25 Jan
% \> HW1 \> \> Using Java; arithmetic, variables, 
% \\* \> \> \> spaces, punctuation \\
% 27 Jan
% \> \> TiJ 5--66 \> Built-in types, variable declaration,
% \\* \> \> \> using methods; the String type \\
% 1 Feb
% \> HW1 due; HW2 \> TiJ 67--77, 86--90 \> Classes for compound data types;
% \\* \> \> \> instance variables; \texttt{javadoc} \\
% 3 Feb
% \> \> TiJ 77--86, 91--94 \> Defining methods and constructors;
% \\* \> \> \> \texttt{this}, \texttt{return}, \texttt{toString}, \texttt{equals} \\
% 4 Feb \> \> \> Deadline to add (Adelphi) classes \\
% 8 Feb
% \> HW2 due; HW3 \> TiJ 95--132 \> Built-in operators, types, and conditionals \\
% 10 Feb
% \> \> TiJ 147--178 \> More on constructors \\
% 15 Feb
% \> HW3 due; HW4 \> TiJ 217--226 \> Mixed data, interfaces,
% \\* \> \> \> abstract and concrete classes, class diagrams \\
% 17 Feb
% \> \> TiJ 226--249 \> Composition \emph{vs.} inheritance \\
% 18 Feb \> \> \> Deadline to drop (Adelphi) classes \\
% 22 Feb
% \> \> TiJ 251--278 \> More on mixed data and polymorphism \\
% 24 Feb
% \> HW4 due; HW5 \> TiJ 306--321 \> More on inheritance hierarchies \\
% 29 Feb
% \> \> review HtDP \> Self-referential data structures \\
% 2 Mar
% \> \> review HtDP \> More on self-referential data structures \\
% 7 Mar
% \> HW5 due \> \> Catch-up and review for midterm \\
% 9 Mar
% \> \> \> Midterm exam \\
% 13--19 Mar \> \> \> Spring Break \\
% 21 Mar
% \> HW6 \> \> Methods as parameters, sorta \\
% 23 Mar
% \> \> TiJ 278--305 \> Inner classes \\
% 28 Mar
% \> \> \> Visitor classes \\
% 30 Mar
% \> HW6 due; HW7 \> \> Visitor classes \\
% 4 Apr
% \> \> HtDP chaps. 25--26 \> Generative Recursion \\
% 6 Apr
% \> HW7 due; HW8 \> HtDP chaps. 27--28 \> Generative Recursion \\
% 11 Apr
% \> \> HtDP chaps. 29--30 \> Accumulative Recursion \\
% 13 Apr
% \> HW8 due; HW9 \> HtDP chaps. 31--32 \> Accumulative Recursion \\
% 17--23 Apr \> \> \> Snow Days, Passover, Easter \\
% 25 Apr
% \> \> TiJ 179--186 \> Arrays \\
% 27 Apr
% \> HW9 due; HW10 \> TiJ 132--146 \> Loops \\
% 2 May
% \> \> TiJ online chap. 8 \> Predefined Collection classes \\
% 4 May
% \> HW10 due; HW11 \> TiJ online chap. 13 \> Applets and event-driven programming \\
% 9 May
% \> \> TiJ online chap. 13 \> Applets and event-driven programming \\
% 11 May
% \> HW11 due \> \> Catch up and review for final \\
% 18 May \> \> \> Final Exam \\*
% \> \> \> section 1, 10:30-12:30 \\*
% \> \> \> section 2, 1:00-3:00 \\
% 21 May \> \> \> Commencement \\

% 28 lecture periods

% \end{tabbing}
\end{document}

HW1: write several expressions of varying complexity (types: int, double,
and String; various operators and built-in methods) in Java syntax.
HW2: write a class with instance variables, constructor, access methods,
and some more interesting methods
HW3: ditto, adding conditionals and multiple constructors
HW4: mixed data: CartesianPoint and ManhattanPoint, or animals and cages,
or something like that
HW5: something involving self-referential data structures
HW6: Java analogues to "map", "filter", etc.
HW7: Same thing (and more) with Visitors
HW8: Some generative-recursion assignment from HtDP
HW9: Some accumulative-recursion assignment from HtDP
HW10: Arrays and loops
HW11: An applet, using Swing classes and event-handling 
