## Official UCSB Catalog Description

CMPSC 8: Introduction to Computer Science

Not open for credit to students who have completed Computer Science 16 or Engineering 3.

Introduction to computer program development for students with little to no programming experience. Basic programming concepts, variables and expressions, data and control structures, algorithms, debugging, program design, and documentation.

## What this course is about

This course is an introduction to Computer Science, and programming.

Computer Science is the study of abstractions and algorithms.

• In Computer Science, an abstraction is a useful representation of something from the real world that allows us to work with it more easily or efficiently.

• An algorithm is a well-defined, step-by-step sequence of instructions that can be used to mechanically determine the solution to some well-defined problem.

You probably use abstractions and algorithms every day—for example:

• If you pick up any textbook, you’ll probably find an index in the back of the book. The index is an abstraction—whether the book is about biology, modern art, political science, or computers, the "way the index works" is the always the same. It is composed of the same pieces (topics and page numbers), and organized in the same way (alphabetically by topic, then lists of page numbers in numerical order from smallest to largest.)

• If you are looking in the index of a U.S. history textbook for "Gettysburg" you’ll probably use an algorithm to find the entry quickly. Here the input to the algorithm is some topic, and the output is a list of pages on which that topic appears.

• If you are looking for a parking lot on campus, you might use an abstraction called a "map" to locate the parking lot. You know the features of a map, and how it corresponds to the reality of a college campus, and parking spaces. The way a map can work to help you find a parking lot (or garage) is the same whether it’s a map of UCSB, Downtown Santa Barbara, or the Staples Center in LA.

• If you are searching through a parking lot (or garage) to either (a) find a parking space, or (b) determine that there are no spaces left, you probably use an algorithm to do that—again, without even thinking about what you are doing.

## What are Algorithms anyway?

An algorithm is a recipe for solving a problem. Algorithms have to be both designed, and "coded" so the computer can carry them out

In the case of using an index, this is probably an algorithm you may have learned in grade school, and it has been so long since you learned it, that now you don’t even think about it—you just do it. Finding a space in a parking lot—and knowing when to give up and look elsewhere—is "just common sense"; this probably isn’t something you were ever "taught", or even have to think very much about. You just do it.

Computers don’t currently have this capability—i.e. the capability to "pick up things by common sense"—and it seems unlikely that they will within our lifetime—unless there are major breakthroughs in the field of Artificial Intelligence. Such breakthroughs have been predicted for a while, but they haven’t happened yet. (Maybe you’ll be the one to figure out how to achieve this!)

So, for the time being at least, it falls to humans to design algorithms that computers can use to solve problems. In many cases, these algorithms are "just common sense"—the computer equivalent of looking for an empty parking space in a parking lot (and knowing when to give up). Algorithms like this are easy to design. Many of the algorithms we’ll see in this course are like that.

In other cases, the algorithms are very complex, or very subtle, and coming up with them is a deep intellectual challenge. Furthermore, the impact of a better algorithm on society can be very large. For example, new algorithms in the field of computational science—modeling chemical and biological reactions with computer simulations—can lead to breakthroughs such as new drugs to fight disease, or renewable sources of energy.

And often, what goes along with finding a good algorithm is finding a good abstraction of the real world concepts we are interested in: cells, molecules, oil fields, words, sentences, students, courses, GPAs, etc. Algorithms and abstractions really go hand-in-hand.

## Coding, or Writing Software, or Programming

Coding is expressing algorithms in a programming language.

Human languages such as English and Spanish are not very well suited for expressing algorithms—at least not for expressing them to a computer (they have their problems for communicating with humans too!). So, special languages are used. In this course, we’ll learn the Python programming language. We choose Python rather than Java or C++ because:

• If you are learning your first programming language, Python is easier to learn than the others
• Learning Python provides a good foundation for learning C, C++ or Java
• If you only learn one programming language, Python is a good choice—in spite of being easy to learn, it is not a "toy" language by any means. It is widely used by scientists and web application developers just for starters. Many internal systems at Google are based on Python code.

This course provides you with the opportunity to become a pretty good beginning programmer, and be well prepared for an intermediate programming course such as CS16 (the first course that counts towards the CS major at UCSB, and which requires at least one quarter of prior programming experience.)

I say that the course "provides an opportunity," because you will only become a good beginning-level programmer if you put a lot of time and effort into this course—that is true no matter how much thought and attention I put in my lectures, assignments, and exams

## The swimming/guitar/painting analogy

You cannot learn to swim, play guitar, or paint from a textbook or a lecture. You can only:

• learn to swim by spending many hours in the pool
• learn to play guitar by spending many hours playing the instrument
• learn to paint by spending many hours putting brush to canvas

The same is true of programming. Programming is not a series of facts to be memorized—you cannot "cram" for a computer science exam. You must practice, practice, practice.

(Image credit: Randall Munro http://xkcd.com/353/)