INF-42 Overview

Informatics Core II
INF-42
Winter 2011


Introduction This lecture will overview four topics related to this course:
  • Learning: what material will we cover in INF-42
  • Computing/Human Resources: what resources are available (and how we will learn to use them).
  • Perspectives on Programming: a short discussion of programming and education built around Quotes that I have collected on my web page (there are hundreds there)
  • Software Production: This is some "big picture" material that I lecture my introductory programming students on. Especially interesting is the table on Software Project Metrics
This lecture, like the ones to follow, has a problem set at the end. But instead of doing these problems with the reading -because this is the first day of class- we will spend time in class looking at and solving these problems. They mostly concern the precise use of a natural language: there are many parallels here to the precise use of a programming langauge.

Course Goals

A First+Second Course in Programming First and most importantly, INF-42 assumes no knowledge of Java programming. But, it does assume knowledge of Scheme (which I will refer to infrequently) and certainly knowledge about using computers and software. By the end of this course, you will have seen and practiced using all the Java topics covered in ICS-21 and ICS-22.

INF-42 introduces the concepts and skills needed to begin serious programming. It is taught in the Java language: although this language is harder to learn than many (including Scheme), it is an industrial strength language with a large library that you can spend years exploring and mastering. Some Java features are beyond the scope of even the ICS-21/-22/-23 sequence.

During INF-42 we will cover a wide variety of introductory and intermediate Java language features. Below I've tried to categorize the fundamentals of programming in Java What I think should be covered in ICS-21 part of this course (the first five weeks) includes:

  • how to read EBNF descriptions of Java's syntax,

  • how to parse Java programs into tokens (identifiers, keywords, operators, delimiters, literals, comments),

  • how to declare and picture variables (both primitive and references; the meaning of final for variables),

  • how to classify and understand operators (terminology; arithmetic, relational, logical, textual, state-change; implicit conversion)

  • how to analyze and synthesize expressions (precedence and associativity, short-circuit evaluation),

  • how to analyze and synthesize statements (including expression statements, if, while, do, for, break, switch, and the basics of try/catch and exception handling); how to analyze statements via hand-simulation and the debugger.

  • how to read Javadoc (constructors, methods, and fields; the meaning of access modifiers: final, static, public, private) and use pre-written Java classes (Math, Prompt, DiceEnsemble, BigInteger, Timer, ModularCounter, StringTokenizer, TypedBufferReader, and TypedBufferWriter), , understanding the difference between local variables, parameter variables, and instance variables.

  • how to write you own classes (constructors, methods, and fields from the inside),

  • how to declare and manipulate Java arrays (of one dimension), including how to use them to write classes storing simple collections,

  • how to use Java interfaces,

  • how to construct, test, and debug programs systematically
Basically you will learn the core of programming and Java; we hope that if you need to learn more, you will have the necessary skills to learn more advanced programming and Java, whether you learn it by yourself or take more courses.

Likewise, we will learn to use the Eclipse Integrated Development Environment (IDE), including its compiler, debugger, and browser. Finally, we will cover a variety of skill in programming material: topics such as program composition, analysis, testing, debugging, simplification, and style. Students will work on five programming assignments based on this material; most involve writing a few "small" programs, exercising combinations of the material being covered. During this time we will learn how to program and test our code incrementally, and understand the debugging leverage that we get from doing so (as well as formally studying the Eclipse debugger).

We will cover this material rigorously. I believe that even students with some background in Java will learn lots of little details (and maybe a few big ones) that we will exploit and build on as we cover new material later in the quarter. Do not get behind during the initial phase of this course; everything builds on it (especially the terminology); and if you know the early material, make sure you start paying attention when we get to the material you don't know.

What I think should be covered in ICS-22 part of this course (the last five weeks) includes:

  • Understand inheritance and how to use it in programming when modeling objects with similar properties (including casting and the generic Object class, as well as type-parameterized classes).

  • Understand interfaces, anonymous classes, wrapper classes, abstract classes, and various patterns (e.g., decorater), and how to use them when programming.

  • Analyze the resources (time/space) needed by programs, both asymptotically (big-O notation) and "for real" (by experiment and extrapolation).

  • Understand iterators and collection class interfaces (List, Map, Set, Stack, Queue, and PriorityQueue) and the performance of the classes that implement them; appreciate their power and be able to use them to model data/algorithms elegantly; understand how they are implemented.

  • Understand generic collections (new in Java 1.5).

  • Understand the details of exception handling in Java; be able to create appropriate exception classes (checked and unchecked), throw exceptions, and catch exceptions in standard circumstances.

  • Acquire experience using self-referential classes and implementing standard linked list and tree algorithms (iteratively and recursively).

  • Recognize beauty in programming (whether design or implementations) and strive to achieve it.

Here there are three majors areas of study.
  1. understanding abstraction (interfaces and advanced features of classes: e.g., inheritance)
  2. using collection classes (queue, stack, priority queue, list, set, and map) and analyzing their performance
  3. defining and manipulating objects constructed from self-referential classes (linked list and trees), often via recursive methods and as data structures to implement collection classes.
Students will work on three programming assignments based on this material; most involve writing a few "small" programs, exercising combinations of the material being covered.

Expectations for Learning As members of a course, working together in teaching and learning, we should share the following expectations.

Instructor:

  • Starts and stops class on time.
  • Assigns the minimal amount of homework, but enough so that students learn all the required material and are comfortable with it.
      INF-42 is a 6 unit course. A full-time student typical takes ~15 units/quarter. Assuming a 40 hour (full-time) work week, this means your time working on INF-42 should occupy about 16 hours/week. Of this 16 hours, 12 hours/week will be in-class lecture/lab time, leaving 4 hours/week for lecture prepartion and programming outside of the labs.
  • Distributes course materials in a timely manner.
  • Returns solutions/graded homework promptly.
  • Is available for providing individual help.
Student:
  • Attends class, is punctual, and participates (asking/answering questions).
  • Completes all homework, spending the requisite time to learn all the required material.
  • Studies course materials (READ! READ! READ!) and is prepared for class.
  • Examines solutions/graded homework to improve knowledge and rectify misconceptions about the course material (and promptly reports any possible grading mistakes).
  • Seeks individual help when it is needed.
The biggest source of problems for students taking INF-42 is skipping classes, not doing readings/homework fully, and poor time management on programming assignments (waiting too long to start them or not working diligently in lab). You are scheduled to spend about 160 hours in INF-42 (10 weeks of work at 16 hours/week); please allow for this much time in your schedule, and use this time wisely.

I believe that with the right attitude and work ethic, any UCI student can learn (and demonstrate that he/she has learned) the material required for this course, and pass it with a good grade.


Resources

Computer Labs
and Software
I expect that most students will be using their own computers for programming assignments. You are encouraged to use your own machine for all aspects of the course that it is capable of supporting. You can download all the required course software to your personal computer for free.

In addition to using their own machines, students can do their coursework on the machines in the ICS Labs. The main upside of using the ICS labs is that it will be easy to get INF-42 staff to help you there; the main downside is that you will not be using your own computer -unless you have a portable and bring it to the labs to get the best of both worlds. All labs are located in in the ICS building, in rooms 180, 189, 192, and 364.

ICS courses often schedule lab hours (to complement lecture hours), during which students can learn how to use software tools and work on their programming assignments, all under the supervision of INF-42 staff members. We will have 4 hours of lab scheduled each week.

The machines in the ICS Labs are Dell Optiplex computers running Windows XP and all the necessary course software: browsers, the Eclipse Integrated Development Environment (IDE), Java, and all the other course-related software. These labs provide a convenient space for students to work on their assignments where the course staff is available to answer questions immediately.

Debugging help will also be available via instant messaging (IM) and realVNC (screen-/keyboard-/mouse-mapping software): students will be able to locate staff online, describe/show their code to them, ask them questions about their code, and even have the staff manipulate the code directly on the student's computer (to run tests on it while helping to correct it).

The World Wide Web (WWW) I will place all materials for this course on the WWW: some are there now, others will become available later in the quarter. You will also use the web for submitting programs for grading. These materials are organized using the following index (the one illustrated below was built for ICS-21 in Fall 2008; ours will be similar).
Here is a brief description of these main entries
  • Fact Sheet: A short page providing information about course staff, getting help, and meeting times; this is the default page for the course.
  • Announcements: A page with messages to the students (updated almost daily, archived with the most current message at the top).
  • Email Archive: A page with all messages mailed to the email discussion group for this class.
  • Syllabus: A long page providing detailed information about how the course is run (print a copy and read it).

  • Lecture Schedule/Notes: A page indexing all lectures and labs, their on-line lecture notes, and their associated problem sets.
  • Programming Assignments: A page indexing all programming assignments.
  • Weekly Schedule: A page listing all readings and homework assignments (and their due dates), week by week.
  • Help Schedule: A page listing all the times help is available to students, both inside and outside of class.

  • Handouts (General): A page indexing a variety of handouts related to the course.
  • Online Resources: A page indexing various useful on-line files (some meant to be viewed, some meant to be downloaded).
  • Sample Programs: A page indexing various programs students can download, examine, and run.

  • Javadoc of Sun's API: Documentation of Sun's standard Java classes.
  • Javadoc of Course API: Documentation of Java classes written specifically for this course.
  • Java Language Reference: Documentation of the Java Language; see the (table of) contents for details (meant to be read by those knowledgeable about programming: not an introduction!)

  • Solutions: A page indexing my solutions to all course assignments (quizzes, exams, and programs); updated as appropriate
  • Grades: A zipped file you can download with all course grades (typically indexed by the last 5 digits of your UCI ID).

  • Anonymous Email: A page students can use to send the instructor anonymous email (when personal email might be awkward).
  • Homework Dropoff: A page students use to drop off homework (mostly weekly programming assignments and in-class programming exams; sometimes programming parts of quizzes).

  • Search ICS-21: Do a "google" search of the course web pages.
  • Search Javadoc 1.6 API: Do a "google" search of the Java API.
During this course you will be constantly reading web pages, and sometimes downloading materials from them onto your computer. Generally, it is critical to become an expert navigating the course web with a browser; specifically you should become familiar with the pages used repeated in this course (so that you can easily find all the materials you need).

If you run across any "missing links", please drop me a short e-mail so that I can correct them quickly.

Human Resources Students start INF-42 with a wide variety of aptitudes and skills. At times, even the best students run into problems, misconceptions, mental roadblocks, etc. It is imperative that you quickly determine that you have a problem, and then get it diagnosed and corrected as soon as possible. There are many different resources that you can elect to use:
  • Instructor: From my perspective, the best place to get help is from me. For simple problems, a short e-mail, phone call, or IM might suffice. For more complicated problems, I have office hours daily. These are open office hours: no appointment is necessary. I also attend labs. If you cannot see me during any of these times, please contact me (by e-mail or by phone) to schedule a special appointment.
  • TAs: The Teaching Assistants will be in lecture/lab daily. They will also offer consulting sessions online (via IM and realVNC) and in the ICS labs, during some non-class hours (afternoons, evenings, weekends). Your TA is responsible for grading your programs, so they the first person you should see if you have any questions about how your programming assignments were graded.
  • Lab Tutors: Lab Tutors will be in lab daily. They will also offer consulting sessions online (via IM and realVNC) and in the ICS labs, during some non-class hours.
  • Students: I encourage students in my courses to seek out each other if they have questions. The student answering the question will benefit as much as the student asking it. One beneficial reason to come to UCI is for the interaction with other outstanding students.
In addition, you may also email questions (and email answers to questions) by using the email discussion group for this course:
    inf42-W10@classes.uci.edu
Staff members will also read this email daily and post answers to whatever questions are asked (and left unanswered by other students). This forum is appropriate for questions relevant to all the students in class; use direct email to your instructor for questions of a more individualistic nature. In past quarters, a tremendous number of questions have been asked and answered here; the email discussion group has also hosted many interesting discussions of the course material.

Learning when and how to seek help from others is an important skill to acquire -one that you will use continually in your professional career. For example, if you encounter a programming problem that you cannot solve in 5 minutes (and see no further steps toward a solution), you should be able to explain the problem concisely (using all the programming terminology that you have learned) to someone else, and then understand and apply an informed answer, possibly collaborating to reach a solution.

Instructors, TAs, Readers, and Lab Tutors all have experience handling such questions, and are trained to help students learn to become more self-sufficient -while still answering their questions: for example, we might tell you a general technique for solving a collection of similar problems instead of just telling you "the answer". Sometimes this process is a bit frustrating for students seeking help (especially if they started the assignment late and are caught in a time-bind), but ultimately this approach makes them better programmers. The appropriate homily is, "Give a person a fish and you feed them for a day; teach a person to fish and you feed them for life."

Think seriously about using the human resources that UCI provides (which includes me, our TAs, and Lab Tutors, and your fellow students), just as you would think about using computational resources: the former resources are even more important than the latter.

Knowing when (and how) to seek help is a strength, not a weakness.

A Bit about Me I hope to get to know you all individually during the quarter. Here is some information about me.

I grew up on the North Shore of Chicago (in the town of Wilmette) and attended New Trier West High School. I was an undergraduate Mathematics major at Carnegie Mellon University (CMU) from 1972-1975, after which I taught a introductory programming there for a year. I went to graduate school in Computer Science at Stanford. While there, I wrote a book, Karel the Robot: A Gentle Introduction to the Art of Programming, and its associated software (since updated by Mark Stehlik and Jim Roberts at CMU). Over the years, my book has been revised and extended by Joe Bergin to C++, Java, and now Python, and it is still used in Colleges and High Schools around the world.

From 1985-1995 I taught introductory and intermediate programming at the University of Washington in Seattle (sending lots of my students to work at Microsoft; the times allowed many of them to become millionaires). From 1996-2007 I returned to teach at CMU; for the last two years there, I served as the Freshman Advisor for incomming Freshman in Computer Science (about 150/year) In 2007, I joined the Bren School of Information and Computer Science (with a joint appointment in Computer Science and Informatics), returning to teach in a public university (where my wife is heading the new Nursing program).

During my Freshman year in high school, I had a Math teacher named Mr. Lill. One class, during a test, my mechanical pencil broke. I asked Mr. Lill to borrow one of his pencils; but he said no. I asked him whether I could borrow a friend's pencil; but he said no to that too. He told me to always come prepared to class, and sat me back down at my desk (where I failed the test because I was unable to write any answers). I had a very low opinion of Mr. Lill for a long time -for years; but he taught me an important lesson that stayed with me much longer than the mathematics he taught. I hope I don't have to be anyone's "Mr. Lill", but I will assume that roll if necessary.

Student Feedback The most interesting short comment that I received on a Faculty/Course Evaluation form (FCE) was, "You teach a biased class." After some reflection, I had to agree with that student 100%. Almost everything I do in my class is highly biased: choosing which programming topics to teach, how to sequence these topics (which ones to emphasize, which ones to relegate as mere details), deciding programming assignments and test questions (and how to award credit for these problems), etc. You are sitting in my classroom because you have decided to obtain the UCI bias on how to learn programming.

I once read a book written about MIT. The author observed that everyone there majored in the same thing: MIT. Yes, they all learned a different vocabulary and facts, and practiced reasoning and problem solving in different disciplines, but what everyone really was doing there was learning to think like an MIT graduate. Along these lines, I want you to eventually acquire a Pattis simulator in your head. By running it, you can determine how I would approach a problem; how I would critique a solution, etc. You don't have to agree with the results it produces, but it is there for you to consult.

The most interesting long comment I received on a course evaluation form was labeled A Relevant Allegory:

"In order to teach someone to boil water, he would first spend a day giving the history of pots, including size, shape, and what metals work best. The next day he'd lecture on the chemical properties of water. On day three, he'd talk about boiled water through the ages. That night, he'd tell people to go home and use boiled water to make spaghetti carbonera. But never once would he tell you to put the water in the pot and heat it. That's what his programming classes are like -completely irrelevant to the task at hand."

I like this comment because it is witty, well-written, and true -although maybe not in the extreme that the author states. Teaching students to boil water is great for a high school class, but in college we are trying to achieve something deeper: we might, instead, study phase transitions in matter. That is, we don't just learn particulars (drill and practice); we learn general theories and -in spite of what this student says- how to apply them to particular cases. I want to teach programming in such a way that when students are exposed to new and novel situations, they will be able to use their general knowledge to fall back and analyze the problem, figure out what they know and what they need to learn to solve the problem, and ultimately synthesize a solution. I acknowledge that learning from first principles is tougher than memorization, and that sometimes students feel that the material covered is not "applied". But, I believe that everything that I teach has many concrete applications.


Learning a Programming Language

Learning In this section I'd like to work from the general to the specific, from education to programming, illustrated with various Quotes I have collected on my web page. Let's start with three interesting quotes: the first from a graduate student at the University of Washington, and the second from Jacob Bronowski, a distinguished philosopher of science, the third from Edward Teller, a physicist.

There is a division in the student population between those who go to college to learn and those who go to college to earn a diploma.

- J. Blau (letter to the editor, Chronicle of Higher Education, May 24, 2002)

It is important that students bring a certain ragamuffin, barefoot irreverance to their studies; they are not here to worship what is known, but to question it.

- J. Bronowski

I believe in excellence. It is a basic need of every human soul. All of us can be excellent, because, fortunately, we are exceedingly diverse in our ambitions and talents.

- E. Teller

You have to decide why you are attending UCI. Your choice will have a lot to say about what you do in this class and others. Here is a simple question that makes it concrete: which of the following students would you rather be? Student 1 attends UCI, but on graduation day is informed that all records of the student's performance at UCI have been lost; in the future, UCI will acknowledge only that the student attended for four years and graduated with a degree, but there are no more details to tell. Student 2 attends UCI, but on graduation day is hit on the head and develops amnesia; although UCI shows the student to have graduated with a 4.0, the student cannot remember any of the material learned through those four years.

I enjoy teaching because I am constantly challenged by students to think more deeply about what I know and how I can teach it. Teaching as best I can is my job; challenging what you hear -to better understand it and question my knowledge of the subject- is yours. Such challenges make me rethink and revise my opinions (more than you might imagine) and think about better ways of presenting and explaining complicated material.

Everyone can excel in Computer Science at UCI: different students will gravitate torwards different parts of the field, but it is a big field -with many connections to applications in other disciplines- and there is room for everyone to be excellent at something. Many of you will be excellent at programming; some of you will be good at it, and that will be enough for you. But, everyone should acquire a basic understanding and basic skills in programming.

Just as I question myself, a huge part of learning requires students to question themselves (and, as seen above, me as well). Learning is more about questions than answers, as the following quotes illustrate.

Good teaching is more a giving of the right questions than a giving of the right answers.

- J. Albers

A prudent question is one-half of wisdom.

- F. Bacon

Questions are the important thing, answers are less important. Learning to ask a good question is the heart of intelligence. Learning the answer---well, answers are for students. Questions are for thinkers.

- R. Schank (in "The Connosseur's Guide to the Mind")

The function of genius is not to give new answers, but to pose new questions which time and mediocrity can resolve.

- H. Trevor-Howard

When the physics nobel-laureate I. Rabi was a child, his mother would always ask him at the dinner table not what he learned in his classes that day, but what interesting questions he asked.

Neil Postman, a famous education, technology, and media critic tells the following story about the importance of asking the right question:

Two priests were arguing about whether it was appropriate to pray and smoke at the same time. They each resolved to ask their bishop for guidance. When they met again, each claimed that the bishop supported his position! They went on to explore their interactions with the bishop in a bit more detail. The first said, "I asked the bishop whether it was appropriate to smoke while praying, and he said that praying is a transcendant activity that should not be debased by smoking." The second said, "I asked the bishop whether it was appropriate to pray while smoking, and he said that praying was appropriate any time."
I know that some students enrolled in this course have already learned some Java programming, and that the first few weeks of the quarter might be a review for them. I urge them to use this time to attain a deeper, more integrated understanding of this material, as the following quote illustrates.

The voyage of discovery is not in seeking new landscapes but in having new eyes.

- M. Proust

Remember too, that teaching and learning are two different, but cooperative activities. I'll do my best to teach, but you need to do your best to learn as well.

We think too much about effective methods of teaching and not enough about effective methods of learning. No matter how good teaching may be, each student must take the responsibility for his own education.

- J. Carolus S.J.

Learning results from what the student does and thinks, and only from what the student does and thinks. The teacher can advance learning only by influencing the student to learn.

- H. Simon

The truth is, when all is said and done, one does not teach a subject, one teaches a student how to learn it. Teaching may look like administering a dose, but even a dose must be worked on by the body if it is to cure. Each individual must cure his or her own ignorance.

- J. Barzun ("Begin Here", pp 35),

I have learned throughout my life as a composer chiefly through my mistakes and pursuits of false assumptions, not my exposure to founts of wisdom and knowledge.

- I. Stravinsky

Here is an old joke that illustrates this idea:

One day a mother comes home from work and asks her son, "What did you do today?" The son replied, "I taught our dog how to play the piano." The mother, incredulous, asked, "Our dog can play the piano?", to which the son laughed and replied, "Of course not mom. I said that I taught him; I didn't say that he learned how."
Finally, don't be afraid to "struggle" and "fail"; if learning were simple and effortless, we'd all be a lot smarter.

I, myself, have had many failures and I've learned that if you are not failing a lot, you are probably not being as creative as you could be -you aren't stretching your imagination.

- J. Backus (primary inventor of FORTRAN)

Learning is never done without errors and defeat.

- V. Lenin

You have to honor failure, because failure is just the negative space around success.

- R. Nelson (in Wired 06/2004 page 166)

Language Let's leave learning behind (but not for too long!) and talk a bit about language. This course is meta-lingual: we will use a language (English) to learn a language (Java). Some argue, as illustrated below, that language is what reality (and certainly education) is primarily about: independent of the subject material, thoughts are linguistic.

As a concrete example, we will learn lots of technical terms during the first few weeks of the course, and then use them repeated as levers to explore and describe advanced Java concepts. When it comes time to ask questions about the material, or questions about debugging a program that you are writing, knowing how to ask using these technical terms -and understand the answers given in these technical terms- makes the process more precise and concise. In an important sense, this course is concerned not only about doing programming, but just as much with how to talk about programs and doing programming.

It is wrong to think that the task of physics is to find out how nature is. Physics concerns what we say about nature.

- N. Bohr

That language is an instrument of human reason, and not merely a medium for the expression of thought, is a truth generally admitted.

- G. Boole

The real technology -behind all our other technologies- is language. It actually creates the world our consciousness lives in.

- A. Codrescu

Precise language is not the problem. Clear language is the problem.

- R. Feynman

We think only through the medium of words. Languages are true analytical methods. Algebra, which is adapted to its purpose in every species of expression, in the most simple, most exact, and best manner possible, is at the same time a language and an analytical method. The art of reasoning is nothing more than a language well arranged.

- A. Lavoisier

Knowledge of a subject means knowledge of the language of that subject, which includes not only what its words mean, but far more important, how its words mean. As one learns the language of a subject, one is also learning what the subject is. It cannot be said often enough that what we call a subject consists mostly, if not entirely, of its language. If you eliminate all the words of a subject, you have eliminated the subject. Biology is not plants and animals. It is language about plants and animals. History is not events. It is language describing and interpreting events. Astronomy is not planets and stars. It is a way of talking about planets and stars.

- N. Postman

Language serves not only to express thought but to make possible thoughts which could not exist without it.

- B. Russell

The limits of your language are the limits of your world.

- L. Wittgenstein

Programming Finally, let's talk about programming and programming languages. Most of the quotes below are lengthy, and come from emminent computer scientists (or just fantastic programmers) who are trying to communicate what programming is about and why it is so fascinating to them.

The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds castles in the air, from air, creating by exertion of the imagination. Few media of creation are so flexible, so easy to polish and rework, so readily capable of realizing grand conceptual structures. Yet the program construct, unlike the poet's words, is real in the sense that it moves and works, producing visible outputs separate from the construct itself. It prints results, draws pictures, produces sounds, moves arms. The magic of myth and legend has come true in our time. One types the correct incantation on a keyboard, and a display screen comes to life, showing things that never were nor could be. ... The computer resembles the magic of legend in this respect, too. If one character, one pause, of the incantation is not strictly in proper form, the magic doesn't work. Human beings are not accustomed to being perfect, and few areas of human activity demand it. Adjusting to the requirement for perfection is, I think, the most difficult part of learning to program.

- F. Brooks ("The Mythical Man Month", pages 7-8)

It's [programming] the only job I can think of where I get to be both an engineer and an artist. There's an incredible, rigorous, technical element to it, which I like because you have to do very precise thinking. On the other hand, it has a wildly creative side where the boundaries of imagination are the only real limitation.

- A. Hertzfeld (original Mac programmer)

When I speak about computer programming as an art, I am thinking primarily of it as an art form, in an aesthetic sense. The chief goal of my work as an educator and author is to help people learn how to write beautiful programs ... My feeling is that when we prepare a program, the experience can be just like composing poetry or music ... Some programs are elegant, some are exquisite, some are sparkling. My claim is that it is possible to write grand programs, noble programs, truly magnificent ones! ... computer programming is an art, because it applies accumulated knowledge to the world, because it requires skill and ingenuity, and especially because it produces objects of beauty. Programmers who subconsciously view themselves as artists will enjoy what they do and will do it better.

- D. Knuth (Computer Programming as an Art. Turing Award Speech 1974)

A good programming language is a conceptual universe for thinking about programming. A language that doesn't affect the way you think about programming is not worth knowing.

- A. Perlis

A programming language is a system of notation for describing computations. A useful programming language must therefore be suited for both description (i.e., for human writers and readers of programs) and for computation (i.e., for efficient implementation on computers). But human beings and computers are so different that it is difficult to find notational devices that are well suited to the capabilities of both.

- R. Tennant (Principles of Programming Languages, Prentice Hall, 1981)

Now, I like to focus on aethetics, because at some level, the root of learning in all disciplines is learning their aesthetics: learning to separate the beautiful from the ugly. Central to this discussion is the dichotomy between complexity and simplicity in programming. As is illustrated many times below, what makes programming hard is complexity in the tools used and complexity of the final product: it is too easy to create overly complicated designs and implementations (which inevitably are incorrect). We must strive to keep everything simple: this is where creativity in programming lies. Programming is one of many human activities in which simplicity and beauty are bound tightly.

The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague.

- E. Dijkstra (in "The Humble Programmer", his 1972 Turing Award Lecture)

Beauty is more important in computing than anywhere else in technology because software is so complicated. Beauty is the ultimate defense against complexity. ... The geniuses of the computer field, on the the other hand, are the people with the keenest aesthetic senses, the ones who are capable of creating beauty. Beauty is decisive at every level: the most important interfaces, the most important programming languages, the winning algorithms are the beautiful ones. ... Good programmers know what is beautiful and bad programmers don't.

- D. Gelernter ("Machine Beauty", Basic Books, 1998)

Great software, likewise, requires a fanatical devotion to beauty. If you look inside good software, you find that parts that no one is ever supposed to see are beautiful too. When it comes to code I behave in a way that would make me eligible for prescription drugs if I approached everyday life the same way. It drives me crazy to see code that's badly indented, or that uses ugly variable names.

- P. Graham (in "Hackers and Painters" pg. 29)

Controlling complexity is the essence of computer programming.

- B. Kernighan (creator of the C programming language)

Fools ignore complexity; pragmatists suffer it; experts avoid it; geniuses remove it. ... Simplicity does not precede complexity, but follows it.

- A. Perlis

Computer Science is the first engineering discipline in which the complexity of the objects created is limited solely by the skill of the creator, and not by the strength of raw materials.

- B. Reid

Design and programming are human activities; forget that and all is lost.

- B. Stroustrup

Technical skill is mastery of complexity, while creativity is mastery of simplicity.

- E. C. Zeeman

I'd like to present the following quote last; it will provide an import perpective for many of our discussions about features in the Java language and the strictness of the Java compiler. It fully recognizes the psychological aspect of programming and is directly related to the complexity of the tools that we use when we build complex artifacts.

Millions for compilers, but hardly a penny for understanding human programming language use. Now, programming languages are obviously symmetrical, the computer on one side, the human on the other. In an appropriate science of computer languages, one would expect that half the effort would be on the computer side, understanding how to translate the languages into executable form, and half on the human side, understanding how to design languages that are easy or productive to use. Yet, we do not even have an enumeration of all the psychologicial functions programing languages serve for the user. Of course, there is lots of programming language design, but it comes from computer scientists. And though technical papers on languages contain mainly appeals to ease of use and learning, they patently contain almost no psychologicial evidence nor any appeal to psychological science.

- A. Newell and S. Card


Software

System Costs In the early days, computers were built by hand, which made them expensive. They were physcially large, consumed huge amount of power, were slow, and their memories were small; so they could run only small programs. As a result, the cost of developing a working computing system was mostly spent on hardware.

At present, computers are cheaply mass produced: they are small, consume minimal power, are fast, and have large memories. Now, the cost of developing a working computing system is mostly spent on software. To deliver new systems cheaply and on time, we must focus on improving the production of software. When implementing a computer system, a 5% improvement in developing software is worth about as much as a 50% improvement in developing hardware (because these latter costs are so minimal to start with).

In his Turing Award lecture, "The Humble Programmer", Edgser Dijkstra (a famous Computer Scientist) put it as follows: "As long as there were no machines, programming was no problem at all; when we had a few weak computers, programming became a mild problem, and now [1972] that we have gigantic computers, programming has become a gigantic problem. ...As the power of available machines grew by a factor of more than a thousand, society's ambition to apply these new machines grew in proportion, and it was the poor programmer who found his job in this exploded field of tension between the ends and the means. The increased power of the hardware, together with the perhaps more dramatic increase in its reliability, made solutions feasible that the programmer had not dared to dream about a few years before. And now, a few years later, he had to dream about them and even worse, he had to transform such dreams into reality! It is no wonder that we found ourselves in a software crisis."

In fact, Moore's "Law" (empirical) states that computer/communication hardware doubles in performance (speed, memory) and halves in resources (size, cost) about every 18 months. This exponential law has held for the past 30 years of computing, which has seen changes in computing technology by a factor of a million. PCs today perform a billion operations per second; if Moore's Law continues to hold for another 40 years, PCs will be performing a thousand trillion operations per second (about as many as the human brain performs; with many more logical elements, each operating at a much slower -than electronic- speed).

A Software Development Model Over the last 30 years the following model, called the Iterated Waterfall model, has proven itself an important one, for developing large software systems (direclty applying it to smaller projects is a bit cumbersome, but it is often applied in a modified way). Each higher phase must finish before a lower phase begins (like water falling), but there are opportunities to return to earlier phases: a problem at a later phase may back up to an earlier one; and all phases can be reached again (iterated) during maintenance. A more recent software methodology (better adapted for smaller projects that require fewer programmers) is called Extreme Programming. It shares the idea of incremental development with the iterated waterfall model, but reaches these objectives a bit differently.

In fact, maintenance is a curious term to appply to software, because unlike cars, for example,
  • Software has no parts that wear out and need to be replaced
  • Software has no fluids that evaporate and need to be replished
So what constitutes software maintenance?
  • Fixing errors
  • Improving performance
  • Increasing functionality
    • Writing new code to meet new specifications
  • Redesigning/Reimplementing/Recoding
    • Rewriting old code to simplify it for future (anticipated) changes
So software has organic features: it continues to grow and evolve. In fact, reliably working software continues to be used a long time. The current Air-Traffic controller system is decades old; there have been a few attempts to design and code a replacement, but after billions of dollars, little progress has been made (many say because the specification keeps changing: see the next chart).

Relative Costs to Fix Errors Review the Iterated Waterfall model of software development. The following chart shows the cost to fix an error, depending on when the error was discoved during this process. Notice that the sooner an error is discovered, the less expensive it is to fix.

When we write Java programs, we will learn about language features that allow us to detect errors more quickly (and thus, fix them earlier and save our time, which is the biggest cost of taking this course)

Software Lifetime Costs We have learned that reliably working software continues to be used a long time. Therefore, the following charts should come as no surprise (although it typically does).

The upshot of this chart is that software must be built initially in such a way that it is easy to maintain, because over the lifetime of a product, maintenance costs dominate. One easy way to remember this chart is that the maintenance cost looks like a Pac-Man icon, gobbling up the initial cost to build.

Software Project Sizes Although we will write only small software systems in this course, we should still keep the construction of large software systems in mind. As we have seen in industry, often small software systems grow into large ones. Software project sizes are roughly categorized as follows (where K means 1,000 lines of code and M means 1 million lines of code)
Tiny:< 1K
Small: 1K - 10 K
Medium: 10K - 100K
Large: 100K - 1 M
Huge: > 1M

Writing a very large software project is like building a skyscraper, in terms of workforce, cost, and timetable. But, it is notoriously difficult to predict software costs and schedules, compared to the building trades.

While most construction jobs can be estimated within 10% of time and budget, software jobs are lucky to be estimated with 300%. Something like 60% of all software projects fail to be completed or deployed. -many $100 million projects are abandoned, with no usable product produced. This is known as the software crisis, which many attribute to the relative newness of programming as a discipline (<60 years; civil engineering is thousands of years old); others say that the difference between two large programs is much greater than the difference between two large buildings, which is why constructing programs is harder than constructing buildings; still others ponder the nature of digital systems and the ability for small mistakes to cause large problems.

The area of Software Engineering is young, but quickly growing and maturing as software finds its way into everything that we produce.

Software Project Metrics Although software projects scale many magnitudes in sizes (the ones shown below are medium to huge), worker productivit rates fall into a much smaller range. The following data came from an article, "How to Break the Software Logjam" from Fortune magazine, Sept. 25, 1989 (pages 100-112).

CompanyProduct Lines
x1K
Time
worker-yrs
Cost
x$1M
$/LineLines
/Month
/Worker
FordContinental 843.51.8 21200
IBMCheckout Scanner 9058.03.0 33129
Lotus1 2 3 Spreadsheet 400263.022.0 55127
CitibankATM* 780150.013.2 17433
NASASpace Shuttle 25,60022,1001,200 4797
*The Citibank ATM project was considered to be very successful. Without it, all the other metrics would differ only by a factor of 2.

Note that Code Lines/Month is a bad metric to measure programmer productivity. This is because a poor programmer may quickly produce many lines to do a simple task; while a good programmer will carefully write fewer lines of code to accomplish the same task, often producing simpler and easier to modify code, reproducing the same functionality in fewer lines of code. Here are two relevant quotes from my homepage (there are lots of other interesting and relevant quotes there).

We flew down weekly to meet with IBM, but they thought the way to measure software was the amount of code we wrote, when really the better the software, the fewer lines of code.

- W. Gates (discussing the writing of the original DOS operating system)

Once the engineers find out that this is how they're being evaluated [by how many lines of code per day they are writing] they'll revert to cut-and-past programming to optimize their productivity rating. They'll repeat the same code logic in as many places as possible in an effort not to look lazy. Long-term benefits like maintainability and portability will be sacrificed on account of a poorly chosen metric.

- B. Blunden (in "Cube Farm", page 140)

But Code Lines is a good metric to measure maintenance cost (which we have seen overshadows by a large fact the original cost to build software). So, the cost of maintaining a program is roughly proportional to its size.

This leads to an interesting anomoly: A programmer may exhibit what appears to be negative productivity by working to shrink the size of a program; but, the result is reduced maintanence cost over the lifetime of the software.


Problem Set Mastering programming starts with mastering the syntax (form) and semantics (meaning) of a programming language. Before we begin our study of computer languages, we can investigate these topics in a natural language. Although these are not questions about programming, answering them requires thinking like a programmer.
  1. Interpret each of the following (real) headlines in two ways; rewrite each in a longer but less ambiguous form.
    1. Police Squad Helps Dog Bite Victim
    2. Milk Drinkers Turn to Powder
    3. Kids Make Nutritious Snacks
    4. Stolen Painting Found by Tree
    5. Red Tape Holds Up New Bridge
    6. Old School Pillars are Replace by Alumni
    7. Hospitals are Sued by 7 Foot Doctors
    8. Earthquake! Buildings Sway from San Francisco to LA
    9. Tuna Biting Off Coast of Washington
    10. Teacher Strikes Idle Kids
    11. Local High School Dropouts Cut in Half
    12. UCI Graduates Blind Senior Citizen
    13. White House Ducks Report on Pornography
    I'm sure lots of these are available online. Here is one URL for Headlines from 1997

  2. Assume that a state originally had no litter laws (so it was legal to litter). A newspaper reports, "Legaslature Voids Judge's Reversal of Governer's Veto of Anti-Litter Law." Is it now legal or illegal to litter?

  3. A man is looking at a photograph; he says of it.
    • "Brothers and sisters have I none, but this man's father is my father's son".
    What is the relationship between the speaker and the person in the picture? What is the simplest, most convincing arguments for your answer?

  4. What would be a good metric to assess the productivity of letter carrier working for the US Post Office? Think about why a simple metric, like letters delivered per day, has flaws; what other kinds of data should be taken into account?

  5. Assume that Company X builds a software system that comprises 250,000 lines of code for $1,000,000: they spent extra time to make it compact and easy to maintain. Assume that Company Y builds a software system that comprises 1,000,000 lines of code for $250,000: they wrote it quickly and cheaply. Finally, assume that it costs 20 cents/year to maintain a line of code (here we won't distinguish between well-/poorly-written code, just code size. What is the 10 year cost for each of these companies to build and maintain their software product? What other important issues for success are not covered in this simple analysis? Which software company is likely to thrive?

  6. Assume white clothes are best washed in hot water, but colored clothes must be washed in cold water (so the colors don't run). You have a large pile of laundry to do, which will fit in one white and one colored load. You want everything reasonably clean. Which load do you do first? Think about robustness in the face of errors.

  7. If you have a washing machine and dryer that each take 30 minutes to run, and you have 10 piles of laundry that you must wash and dry, how long will the entire process take (disregard the time to load/unload)?

  8. What is the difference between precision and accuracy (look these words up in a dictionary if you need to)? Write a precise statement that is not accurate. Write an accurate statement that is not precise.

  9. The bottom of an escalator has two signs
    • Shoes must be worn!
    • Dogs must be carried!
    Although these signs read similarly (syntax), they have very different interpretations (semantics), about which no native English speakers would give a second thought. Carefully examine these two sentences and explain their difference, possibly by restating the intent of these signs using more words. Hint: "Shoes must be worn!" does not refer to shoes being old/worn-out.

  10. Repunctuate the following sentences (you may add or remove punctuation marks) to reverse their meanings
    • The republicans say the democrats will win.
    • A woman without her man is nothing.

  11. Repunctuate the following paragraph (you may add or remove punctuation marks) to make the letter more one of loathing than admiration.
      Dear Jack: I want a man who knows what love is all about. You are generous, kind, and thoughtful. People who are not like you admit to being useless and inferior. You have ruined me for other men. I yearn for you. I have no feelings whatsoever when we're apart. I can be forever happy -will you let me be yours? Jill.

  12. Write two different interpretations for the statement, "You cannot put too much water in a nuclear reactor." Write three different interpretations for the statement, "I saw the man on the hill with a telescope."