2010 January 1 / j d a v i s @ c a r l e t o n . e d u

About CS 111

This course is an introduction to computer science. So what is computer science? Well, it is frequently defined to be the study of algorithms. An algorithm is a step-by-step procedure for solving a given problem. An algorithm can be expressed in plain English, or Cantonese, or Wolof, or any other language that people understand. When an algorithm is expressed in a language designed for a computer to understand, that expression of the algorithm is called a program.

Exercise: Give an algorithm for making a peanut butter and jelly sandwich. Are the steps in your algorithm utterly clear and unambiguous? Each step really consists of several substeps. Expand upon them. Also, you are probably assuming the availability of materials such as peanut butter. Who made the peanut butter, and how? What steps did they use? What basic standards do you expect the peanut butter to meet? What would you do if you opened the peanut butter jar to find it filled with raw, uncrushed peanuts?

The preceding exercise is intended to convey a few ideas about algorithms. There is an algorithm for making a sandwich. It is not unique; different people may come up with different algorithms; one algorithm may or may not be better than another. Each step in the algorithm potentially consists of numerous substeps; think of how many subtle muscle movements are involved in the simple task of spreading jelly on bread! The steps are themselves abstractions that hide or encapsulate complexity for us, so that we don't have to think about every detail of the larger algorithm all the time. A computer program is a swarm of abstractions that interact with each other according to agreed-upon rules, called specifications. When a professor or employer asks you to write a program to accomplish a particular task, she is giving you a specification; you write the program assuming that other parts of the system behave according to their specifications. However, it is desirable to write your program robustly, so that it gracefully handles errors in other parts of the system, such as a jarful of unprocessed peanuts.

In this course you will practice thinking algorithmically. You will practice the art of creating useful abstractions. You will practice expressing these algorithms and abstractions in the Python programming language. You will practice analyzing algorithms and quantifying their performance. You will learn a bit about how computers work, why they are designed that way, and how they might be designed better. In short, you will start to think like a computer scientist.

What is this course not about? Well, you will not learn how to use productivity applications such as a spreadsheet or word processor; that is for a computer literacy course. You will not learn how to set up a web server; that is for an information technology course. You will not learn how to join transistors together to form an integrated circuit; that is for an electrical/electronic/computer engineering course. You will not learn how to write large applications within a team of other programmers; that is for a software engineering course.

Finally, although you will learn how to write small programs in Python, learning Python is not the point of this course. The point of the course is to think about algorithms. In order to talk about algorithms precisely, we express them in a computer programming language. We could use any programming language for this purpose. Over the years, I have seen introductory computer science courses taught in BASIC, Pascal, C, C++, Java, and Scheme. Currently Carleton, like many other colleges and universities, teaches introductory computer science in Python, because it is a relatively user-friendly language that lets you accomplish interesting tasks without worrying about a lot of tedious details. That is, Python presents convenient abstractions. (Once you've learned Python it is not difficult to learn other programming languages. A serious computer programmer knows several languages and isn't afraid of learning new ones. In a recent project, I had to use four languages — Python, C, GLSL, and regular expressions — at the same time.)

What sort of things can Python do? The short answer is, "Anything that a computer can do at all." For starters, when you begin learning Python you typically work in the interpreter. This is a user interface in which you type textual commands and Python responds with textual answers.

However, Python programs are not limited to producing text. Here is a screenshot of a 3D graphics program I've been tinkering with.

Whenever you use a sophisticated, interactive web site, your web browser communicates with a program running on the web server. Python is one of the most popular languages for writing such server-side programs. For example, Google and YouTube use it heavily. For another example, a couple of years ago I wrote a little web application in Python, to help my calculus students practice differentiation; you can try it here.

Python is widely used as a scripting language for other software. One example is the circuit layout software made by Ciranova.

Another example is the high-end 3D animation application Autodesk Maya.

Another example is the geographic information system ArcGIS.

Python is available for many different platforms (Windows, Mac OS X, Linux, etc.). Here's a picture of Python running on a Nokia mobile phone.

Here are some other examples of companies and products that use Python.