You are on page 1of 46

CPSC 111

Introduction to Computation
May 4, 2009

Who I Am
Your instructor is Kurt Eiselt eiselt@cs.ubc.ca ICICS 233 office hours soon to be determined (but come on in anytime the door is open)

What This Course Is About


Calendar description: Basic programming constructs, data types, classes, interfaces, protocols and the design of programs as interacting software components. Prerequisites: Mathematics 12. Ignore the buzzwords for now. Youre going to learn about computers and how to put together sequences of instructions to make them do useful stuff.

Who this course is for...


Although it is expected that you will have used a computer prior to taking the course and that you are familiar with basic keyboard and mouse operations, no prior programming experience is assumed. This course will teach you basic programming constructs that will allow you to unleash your creativity and develop your own applications software. In other words, you can succeed here even if you have never ever written a computer program.

...but note this


If you have already received credit for CPSC124 and CPSC126 or for CPSC122 and CPSC128 then you cannot receive credit for CPSC111. If you have taken CPSC124 but not CPSC126 then you must take CPSC111 in order to advance through the computer science program. If you have taken CPSC122 but not CPSC128, please consult with a department advisor. This probably isn't relevant to any of you. The important thing to know is that you must have taken Mathematics 12 before now, or you'll most likely be dropped from the course.

Administrative Stuff
Your textbook is Big Java by Cay Horstmann (Wiley and Sons). The third edition is in the bookstore, plus some copies of the second edition.

Administrative Stuff
Your textbook is Big Java by Cay Horstmann (Wiley and Sons). The third edition is in the bookstore, plus some copies of the second edition. You should get a copy of either one. Seriously. Read chapter 1 and chapter 2 before Wednesday.

Administrative Stuff
Tentative schedule First midterm exam: Second midterm exam: Final exam: Friday, May 15 (in class) Friday, May 29 (in class) Friday, June 12 (in class)

Tentative grade calculation (subject to change) Quizzes 10(?) labs 5(?) assignments First midterm Second midterm Final exam 5% 10% 10% 10% 20% 45%

Administrative Stuff
I post all my PowerPoint slides on our WebCT page. We're using the new WebCT Vista (www.vista.ubc.ca). I post the slides sometime (not instantly) after class, not before. Our WebCT pages should be available today. Until you get up to speed with WebCT (in lab) you can find out more about CPSC 111 at http://www.ugrad.cs.ubc.ca/~cs111/. Note that the "outline" and "schedule" sections are not up to date yet -they describe the section that ended Friday. We'll try update those pages within the next 48 hours. But please read the "policies" section.

Administrative Stuff
No labs or tutorials today. Labs and tutorials begin on Wednesday of this week, then on Friday, then every Wednesday and Friday thereafter.* You should do Lab 0 (a take home lab) as soon as WebCT for 111 is ready. Typically well use the entire 2.5 hours every Monday, Wednesday, and Friday, with a ten minute break somewhere in the middle. That break is for me as well as you.
* Except possibly on exam days.

Administrative Stuff
Lab work is marked by your TAs at the lab. Those marks impact your final grade. Tutorial work is not marked, but skipping tutorials is not a good idea.

How intense is the summer version?


3 lectures per week x 6 weeks 3 exams: subtract 3 lectures 1 holiday: subtract 1 lecture = = = 18 lectures 15 lectures 14 lectures

In the winter, this class runs 13 weeks. So in the summer, we have 14 lectures to cover 13 weeks of material. One lecture in the summer is almost a week's worth of material from the winter session. Do not fall behind. Oh, did I mention that your first midterm exam is next week?

More Administrative Stuff


Please note that in order to pass the course you must: obtain an overall grade of at least 50% obtain a grade of at least 50% on the final exam obtain an overall grade of at least 50% on the combined lab and assignment grades If you fail to satisfy any of the above criteria, a grade no greater than 45% will be assigned in the course. The instructor reserves the right to modify this grading scheme as necessary throughout the term. Note that you will not pass the course if you are not enrolled in a lab section. More lab seats will be added very very soon. Thats enough administrative details for now. There will be more details to wrestle with in the days to come.

This is a first course in computer science...


...but what is computer science?
"Computer science is as much about computers as astronomy is about telescopes."
Edsger Dijkstra

This is a first course in computer science...


...but what is computer science?
Computer science revolves around computational processes.... A process is a dynamic succession of events.... When your computer is busy doing something, a process is going on inside it.
Oliver Grillmeyer

This is a first course in computer science...


...but what is computer science?
Computer science is the study of what computers do, not of what they are.
me

Processes, procedures, and programs


A process is what happens when a computer follows a procedure - its a procedure in execution. A procedure is a collection of instructions in some meaningful order that results in useful behaviour on behalf of the device that executes the instructions. When the instructions are written in a symbolic language that can be executed by a computer, the procedure is called a computer program.

Processes, procedures, and programs


What we do in CPSC 111 is think in terms of procedures use a programming language called Java to write the procedures as computer programs and execute the programs on a computer to generate useful processes

Procedures and algorithms


Computer people often use the words procedure and algorithm interchangeably...we will too.
An algorithm is a finite procedure written in a fixed symbolic vocabulary governed by precise instructions moving in discrete steps, 1, 2, 3, ... whose execution requires no insight, cleverness, intuition, intelligence, or perspicuity and that sooner or later comes to an end
David Berlinski in The Advent of the Algorithm

Procedures and algorithms


Lets dive right in and write a procedure or algorithm, just for fun. Well make a peanut butter and jelly sandwich. (Is anyone here allergic to peanuts? You should go way to the back of the room.) Form a small group with your neighbours. Grab some paper and a pen, and write down how to make a peanut butter and jelly sandwich as a sequence of steps. Number each step. Bring me your procedure when youre finished.

Procedures and algorithms


Was my interpretation of your instructions a little bit frustrating? If telling me how to make that sandwich had been really important to you, you might be quite upset right now. Getting other people to do what you want them to do isnt easy. Getting computers to do what you want them to do is less easy -- a lot less.

Procedures and algorithms


Heres why we get frustrated when we start to learn to write programs to make computers do stuff:
An algorithm is a finite procedure written in a fixed symbolic vocabulary governed by precise instructions moving in discrete steps, 1, 2, 3, ... whose execution requires no insight, cleverness, intuition, intelligence, or perspicuity and that sooner or later comes to an end We dont have a lot of practice at being precise!

Procedures and algorithms


Heres why we get frustrated when we start to learn to write programs to make computers do stuff:
An algorithm is a finite procedure written in a fixed symbolic vocabulary governed by precise instructions moving in discrete steps, 1, 2, 3, ... whose execution requires no insight, cleverness, intuition, intelligence, or perspicuity and that sooner or later comes to an end We dont have a lot of practice at working with stupid!

Why working with stupid isnt easy


The languages that computers understand are very different from the languages that humans understand, and for good reason. Unlike computers, humans bring enormous amounts of knowledge to bear on the simple problem of figuring out what just a single sentence means. You may not be able to articulate the knowledge that youre using, but you do have it, and you can apply it in real time, as you read or listen, even if the sentence is one you've never encountered before. (Like the one you've just read.)

Why working with stupid isnt easy


So why is that important to you, the budding young computer programmer? Because the natural language you use, whether English, Chinese, French, Klingon, or whatever, is highly ambiguous and you deal with it automatically and unconsciously. Every sentence you write, every utterance you speak, lacks precision (to say the very least) and you count on the understander on the receiving end to disambiguate it without even a glimpse of recognition that the disambiguation is happening. Its an inherent trait of natural language and the humans who understand natural language. Its what we do. It sets us apart from everything else.

Why working with stupid isnt easy


But imagine that youve been transported to a world where the other inhabitants cope with ambiguity even less well than I did when I tried to follow your instructions for making a sandwich. A world, in fact, where they dont cope with ambiguity at all, a world where they bring almost no knowledge whatsoever to bear on the problem of understanding what youre saying. How painfully tedious would that be? You dont have to imagine it -- youre going to be living in it for the next six weeks. Its the world of computer programming. Welcome to our world.

How to avoid frustration


Practice, practice, practice. This material isn't conceptually incomprehensible, but... It takes a lot of practice to learn to be precise enough to make a computer do what you want It takes a lot of practice to keep from assuming that the computer is smarter than it really is It takes a lot of practice to get good at this stuff

How to avoid frustration


Dont try to game the system. It wont work for most of you. Your presence at the big university means youve mastered the art of cramming for exams, writing term papers the night before theyre due, and so on. It works with subjects where you have years of experience, but it doesnt work so well where you have no previous experiencelike in this course.

How to avoid frustration


Learning to write computer programs is similar to learning to play a musical instrument or write stories. Its a skill. Skill requires practice. You wouldnt put off all your piano practice until the night before your recital. You dont want to put off all your programming practice until the night before a programming assignment is due or (worse yet) until the night before your exam. Practice, practice, practice.

How to avoid frustration


Study your book frequently, dont just read it. (Recent studies suggest you should read, then close the book and try to write a summary of what you've been reading.) Play with the programs from your book and from class. Type them in, run them, change them, run them, repeat. Go to the labs. Go to the tutorials. Ask questions. Do more than we require. Practice, practice, practice.

Dont wait until the last minute to get help

Hey, can I still pass if I can get enough partial credit?

Bad things happen while learning a new skill. Start homework early; give yourself time for mistakes.

Dont be too ambitious with your course load. You cant slack off in this class, even for a few days.

So what will you learn here?


How to get a computer to do your bidding: How to represent solutions to problems as procedures or algorithms How to represent those procedures as programs written in a programming language How to get the computer to turn your programs into processes that do useful stuff

Why should you learn it?


If youre one of the few computer science majors enrolled in this class right now, the answer should be obvious. But what if youre not a computer science major? As an informed citizen, the more you know about how these machines work, the better youll be able to weigh in on decisions that affect your life in a very technology-dependent future. Also, no matter what your chosen field of study

Thinking in terms of process is crucial


formulas are no longer sufficient for describing how our world works. For example, Economic systems are processes Political systems are processes How HIV invades cells is a process How pharmaceuticals interfere with HIV is also a process, and so on Being able to think about complex systems in terms of procedures and processes will be of value to you even if you never write another program after 111.

But wait, there's more*...


It's not obvious to you, but you're in the middle of a revolution. Think about the changes that have happened already...

This computer from the 1950s had roughly the computing power of today's musical greeting cards.
* most of the following examples have been stolen from Ed Lazowska's very inspiring 2008 SIGCSE keynote address. Thanks Ed.

But wait, there's more...


It's not obvious to you, but you're in the middle of a revolution. Think about the changes that have happened already...

The computing power that was aboard Apollo 11 on its flight to the moon in 1969 can be found in a Furby.

But wait, there's more...


It's not obvious to you, but you're in the middle of a revolution. Think about the changes that have happened already...

The power of my first computer in 1972 that served a university and its surrounding business community...

But wait, there's more...


It's not obvious to you, but you're in the middle of a revolution. Think about the changes that have happened already...

The power of my first computer in 1972 that served a university and its surrounding business community is exceeded by my iPhone.

But wait, there's more...


There are now roughly 1,000,000,000 PCs in the world (or 1 for every 6 people on the planet), yet that number represents less than 2% of all the processors in the world. Where are the others? Everywhere around you:
GPS systems cell phones DVD players compact disc players iPods calculators digital cameras automobiles household appliances children's toys and so on...

All 50,000,000,000 of these processors execute programs

But wait, there's more...


In 1995, a group of computer science experts tried to anticipate where computer science research was going. Here are some of the things they missed: entertainment technology data mining portable communications the World Wide Web speech recognition The ways in which people put computing technology to use continue to astound the experts.

But wait, there's more...


Advances in computing have already changed the way we live, work, learn, and communicate in ways most people couldn't have imagined. Advances in computing drive advances in nearly all other fields (see biology, for example). Advances in computing drive our economy (especially through the uptake of computing by traditional industries making them more efficient).

What's coming? Just imagine...


much greater understanding of our environment (e.g., wide-spread remote sensor oceanography) comprehensive energy management solutions automobiles that don't/can't crash individualized education neurobotics nanomachines in medicine robotic care-givers personalized pharmaceuticals based on individual genome mapping

It all starts here


While we love our computer engineering sisters and brothers for continuing to make computers smaller and more powerful at the same time, all the advances we just talked about depend on software: the computer programs that make the machines do something useful. And for almost everyone everywhere, the path to creating that software starts in introductory computer science classes in schools all over the world. You have to learn some of the boring stuff before you can start building the cool stuff. If you want to play an active role in the ongoing revolution, this is where you begin.

Data collection
In addition to turning you into incredibly powerful computer programmers, we'll also be using you as lab rats. We'll of course be using information from your quizzes, homework, and exams to inform us as to how to facilitate your understanding. But we'll also be asking you to participate in other data gathering efforts as well. We'll ask you to answer questions on various surveys, including the one we'll hand out now. This particular survey will help us determine how much programming experience you already have.

You might also like