Princeton University
COS 217:  Introduction to Programming Systems

Precept 1:  Introduction

Purpose

Introduce people, the precepts, the computing environment, proper C program structure, and the C program preparation process

Reading

For this precept:  Loukides and Oram, Chapters 2,  3, 4 (lightly -- more complete coverage in later precepts)

For precepts over first 2 weeks:  Loukides and Oram, Chapters 2,  3, 4, 5 (lightly), 6, 7

The People

My background

Academic

Software development 

Teaching 

Your background

Complete questionnaire

Self-test to judge if you are underqualified or overqualified

The Precepts 

Purpose:

Complement lectures

Support your work on assignments

Types: 

Tool precept: describe a tool

Programming precept: describe an example program related to lecture or assignment

Assignment discussion precept: assignment briefing or debriefing 

Examination discussion precept: pre-examination review of material, or post-examination review of the examination itself

Schedule

Note assignment and test dates

Dr. Funkhouser is designing lectures as the course progresses =>

The precept topics and this schedule are likely to change throughout the course

Sources of information for precepts (and course)

Text books

Required:

Harbison and Steele: C programming language (reference)

Paul: SPARC architecture and assembly language (tutorial)

Recommended (but really required):

Hanson: programming style (tutorial)

Loukides and Oram: UNIX and bash (tutorial)

Others:

King (from COS 126 course): C programming language (tutorial)

Kernighan and Ritchie: C programming language (tutorial and reference)

Kernighan and Pike: UNIX programming environment (tutorial)

SPARC Architecture Manual

http://www.sparc.com/standards/V8.pdf 

Give URL later in course

SPARC assembly language manual

http://docs.sun.com/ab2/coll.45.13/SPARC/@Ab2TocView?Ab2Lang=C&Ab2Enc=iso-8859-1

Give URL later in course

UNIX man and apropos commands (described in a later precept)

Lab assistants

Newsgroup (described later in this precept)

Read frequently!!!

Teachers

My office and office hours

The Computing Environment 

Options

(1) Friend Center 016 Lab computer connected to arizona cluster

(2) Your personal computer, SSH to arizona cluster

There are other reasonable options (X Windows)

Experiment!

Instructions to establish a "greatest common denominator" computing environment for Microsoft Windows computer 

Instructions to establish a "greatest common denominator" computing environment for a Friend Center 016 computer 

C Program Structure (Part 1)

Suppose your task is to create a large C program

There are several ways to structure the program..

Some examples of C program structure (relevant to your Assignment 1):

Example 1:

Include header files

Draws declarations of functions into your file

In particular, printf

Define functions

If A calls B, then B must be declared or defined before A

Example 2:

Include header files

Declare your functions

Define your functions

Advantage:  Can define functions in any order

Example 3:

Define your program in multiple files

Use interface files (headers) (.h) and implementation files (.c) 

(You should do that for Assignment 1)

Advantage:  reuse, robustness (as described in lectures)

Advantage:  partial builds (as described now...)

The C Program Preparation Process 

An example of the program preparation process

Procedure (give demo):

Make a project directory

Later precept covers UNIX and bash fundamentals

Create source code

For now, can use pico

Later precept covers Emacs

Preprocess, compile, assemble, and link

Execute

Submit

C Program Structure (Part 2)

Returning to the previous question...  Why?

Allows partial builds

Example:  Change mystring.c => 

Preprocess mystring.c

Compile mystring.c

Assemble mystring.c

Link all .o files to form executable

But...  Need not preprocess, compile, or assemble testmystring.c

Significant when project consists of many files

Copyright © 2002 by Robert M. Dondero, Jr.