Chapter 1 and Sections 2.1-2.2 of Problem Solving With C++.

Course Logistics

Who is your instructor. Who is your section leader. Role of the website. Course Policy and CS Department Honor Policy. Computing resources and course VM.

What is this course about?

This course is an introduction to programming. C++ is the language we use, but this course is not about learning C++. It is about learning to program! "How to program" is bigger than "C++" or any other language. Programming is a creative process, in which you construct a model world inside the computer that interacts with the real world via keyboards, mice, monitors, speakers network connections, and so forth. It's very rewarding, exciting and - very often - frustrating. We are going to start slow and focus on solid understanding of foundational concepts, so please be patient wth the fact that your programs will usually be reading and writing text and not interacting with all the fancy peripherals mentioned above. You'll apply your programming skilz to fun graphicsy stuff next semester: this semester we focus on programming itself.

Compiled vs interpreted, and why C++ is different than Javascript

You really should review the computer architecture section of SI110. Here's a link to an archived si110 site.
In SI110 last year all of you got exposed to Javascript programs. You'll noticed that what we do here feels a lot more low-level, and requires a lot more discipline. The main reason is that Javascript programs are executed by the browser, whereas C++ programs are actually executed by the physical machine. That fundamental fact leads to a lot of the differences you'll observe. Javascript is an interpreted language. This means that the code you write is read and processed by the browser, which then executes the steps demanded by that code. C++ is a compiled language. This means that the code you write is read and processed by a special-purpose program called a compiler, which translates it into the zeros and ones that the CPU speaks, and stores it in an executable file. At some later point, the OS is told to start the program stored in the executable file running, and the CPU initiates its fetch-decode-excute cycle on the code contained in that file.
Use an editor to create the file hello.cpp containing the source code for the program. Use a compiler (g++ in this case) to translate the human-readable C++ source code into machine-readable object code hello.o. Use a linker (g++ does this as well) to combine our object file hello.o with other object files (like those that take care of input/output) to create the executable program hello. Use the OS to initiate execution of (i.e. start te fetch-decode-execute cycle on) the program hello.
All these steps are kind of a pain in the neck, but remember: we're writing a program that is executing on "bare metal", i.e. directly on the CPU.


At the end of the notes for almost every lecture will be a couple of example problems with solutions. Everyone likes to see examples of code, so that's what we give you!