$ cat welcome.
c
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("Welcome to COS 217\n");
printf("Introduction to Programming Systems\n\n");
printf("%s %d\n", ”Spring", 2023);
return 0;
}
$ cat Makefile
CC=gcc217
welcome: welcome.o
$ make
gcc217 -c -o welcome.o welcome.c
gcc217 welcome.o -o welcome
$ ./welcome
Welcome to COS 217
Introduction to Programming Systems
Spring 2023
Agenda
Course overview Our computing environment
•Introductions •Key software / terminology
•Course goals •Navigating the filesystem
•Resources •Demo (time permitting)
•Grading
•Policies
3
Introductions
Instructor of Record
• Christopher Moretti [email protected]
Faculty Preceptor
• Donna Gabai [email protected]
Graduate Preceptors
• Samuel Ginzburg [email protected]
• Guðni Nathan Gunnarsson [email protected]
• Jianan Lu [email protected]
• Wei Luo [email protected]
• Ashwini Raina [email protected]
4
• Wei Tang [email protected]
Agenda
Course overview Our computing environment
•Introductions •Key software / terminology
•Course goals •Navigating the filesystem
•Resources •Demo (time permitting)
•Grading
•Policies
5
Goal 1: Programming in the Large
Learn how to compose
large(r) computer programs
Topics
•Modularity/abstraction, information hiding, resource management,
error handling, testing, debugging, performance improvement
•Tools: ssh, bash, shell utilities, git, gcc, make, gdb, gprof, valgrind, splint
6
Along the Way: Learn Linux
Question: Why use the Linux operating system?
Answer 1: Linux is the industry standard for servers, embedded devices,
education, and research
Answer 2: Linux (with GNU tools) is good for programming
(which helps explain answer 1)
8
Goal 2: Lower-level Languages
int main(void) {
while ((iChar = getchar()) != EOF) {
lCharCount++;
if (isspace(iChar)) {
if (iInWord) {
lWordCount++;
iInWord = FALSE;
}
}
main:
.LFB0:
.cfi_startproc
stp x29, x30, [sp, -16]!
.cfi_def_cfa_offset 16
.cfi_offset 29, -16
.cfi_offset 30, -8
add x29, sp, 0 RELOCATION RECORDS FOR [.eh_frame]:
.cfi_def_cfa_register 29 OFFSET TYPE VALUE
b .L2 000000000000001c R_AARCH64_PREL32 .text
Contents of section .text:
0000 fd7bbfa9 fd030091 39000014
9 00000090 .{......9.......
Along the Way: Learn C
Question: Why C instead of Java?
Answer 1: A primary language for
“under the hood” programming in
real code bases.
Answer 2: A variety of experience
helps you “program in the large”
10
Goals: Summary
Help you to gain ...
Jungwoo Hong
11
Programming Maturity
Agenda
Course overview Our computing environment
•Introductions •Key software / terminology
•Course goals •Navigating the filesystem
•Resources •Demo (time permitting)
•Grading
•Policies
12
Lectures
Describe material at a mix of levels
• Some conceptual (high) overview
• Some digging into details
Slides on course website
Recordings of live lectures will be posted
Videos from some previous offerings are available on Youtube
Etiquette
• Ask questions as they come up!
• Use electronic devices primarily for taking notes or annotating slides
• Limit your SnapFaceInstaRedGooTok, please -- for yourself and your neighbors
13
iClicker
Occasional questions in class, graded on participation not correctness.
• Using an app on your phone or the web client
• Setup is "iClicker Cloud", integrated with our course's Canvas.
• Register, select Princeton University, and find course "COS 217 – Spring 2023"
14
iClicker Question
Q: Can you answer this iClicker question today?
A. Yes
B. No, but I’ve been practicing my mental electrotelekinesis and
the response is being registered anyway
C. I’m not here, but someone is iClicking for me
(don’t do this – it’s a violation of our course policies!)
Precepts
Describe material at the “practical” (low) level
• Support your work on assignments
• Hard-copy handouts distributed in precept
• Handouts also available via course website
Etiquette
• Attend your precept: attendance will be taken
• Use TigerHub to move to another precept if timing is a problem
• Must miss your precept once or twice? ⇒ inform preceptors & attend another
Precepts begin today!
16
Websites
https://www.cs.princeton.edu/~cos217
(Course website)
•Home page, schedule page, assignment page, policies page
https://princeton.instructure.com/courses/9659
(Canvas)
•Links to Ed, Library reserves and other readings, NameCoach
17
Ed
https://edstem.org/us/courses/36005/discussion
•Also available as a Canvas link from the course website
•Q&A – post here instead of emailing staff when possible
Etiquette
•Study provided material before posting question
•Lecture slides, precept handouts, required readings
•Read / search all (recent) Ed threads before posting question
•Don’t reveal your code!
•See course policies
•Click “private” if in doubt – we can make it public after-the-fact
18
codePost
We will use codePost.io to
annotate your assignment
submissions with feedback and
grades.
More information on this when we
get ready to return Assignment 1.
19
Books
C Programming: A Modern Approach (Second Edition) (required)
•King
•C programming language and standard libraries
ARM 64-bit Assembly Language (required / online)
•Pyeatt with Ughetta ‘21
The Practice of Programming (online)
•Kernighan *69 & Pike
•“Programming in the large”
20
Help!
Office Hours
• 3+ hours per day 7 days per week: some in-person, some Zoom
• "Concepts" office hours after lecture: focus on course material, not debugging
• Schedule is on the course website
• Zoom office hours links to queue form and status page are on Canvas
Intro COS Lab Hours
• Intro Lab TAs are your peers who have already completed this course.
• Available 4+ hours per day, every single day (some days in-person, some online):
https://introlab.cs.princeton.edu/
• These sessions are specific to debugging your assignments.
22
Go to (regular or concepts) office hours for conceptual help with course materials
Agenda
Course overview Our computing environment
•Introductions •Key software / terminology
•Course goals •Navigating the filesystem
•Resources •Demo (time permitting)
•Grading
•Policies
23
Grading
Course Component Percentage of Grade
Assignments * 60
Midterm Exam ** 10
Final Exam ** 20
Participation *** 10
* 6 assignments ´ 10% each. Late assignments 20% off per day; 4 late days free.
** During midterms week and final exam period, respectively.
*** Did your involvement benefit the course?
• Lecture/precept attendance and precept/Ed participation
24
Programming Assignments
Regular (every 1.5-2.5 weeks) assignments
Pedro da Silva
0. Introductory survey
1. “De-comment” program
2. String module
3. Symbol table module
4. Debugging directory and file trees *
5. Assembly language programming *
6. Buffer overrun attack *
*(partnered assignment)
Assignments 0 and 1 are available now: start early!!
25
Agenda
Course overview Our computing environment
•Introductions •Key software / terminology
•Course goals •Navigating the filesystem
•Resources •Demo (time permitting)
•Grading
•Policies
26
Policies
Learning is a collaborative activity!
• Discussions with others that help you understand
concepts from class are encouraged
But programming assignments are graded!
• Everything that gets submitted for a grade
must be exclusively your own work
• Don’t look at code from someone else, the web,
GitHub, etc. – see the course “Policies” web page
• Don’t reveal your code or design decisions to anyone except
course staff – see the course “Policies” web page
Violations of course policies @jdent
• Typical course-level penalty is 0
• Typical University-level penalty is suspension
27
Mental Health
COS 1xx/2xx courses are hard under the best of circumstances
• Information-dense
• Programming is a new skill, or “craft”: not like writing essays or doing problem sets
These are not the best of circumstances
• We all feel stressed, anxious, uncertain at times – but when these veer into panic or depression…
Say something, and get help
• Reach out to CPS, your residential college dean, course staff
• No judgment! Many of us have been there!
28
Questions?
Agenda
Course overview Our computing environment
•Introductions •Key software / terminology
•Course goals •Navigating the filesystem
•Resources •Demo (time permitting)
•Grading Sai Kiran Anagani
•Policies
30
ssh! While I bash this shell…
A quick COS217 ⟷ English dictionary so that we’re on the same page
avcj.com
What’s an Operating System?
Narrow definition: Looser definition:
A piece of software that controls The kernel plus a variety of
the interaction between programs libraries and tools built upon it,
and hardware (CPU, memory, that provide a specific experience
storage, peripherals). to users (e.g., GUI).
Modern OS Examples
Also called a “kernel”.
• Linux kernel: Linux/GNU, Android
• XNU kernel: macOS, iOS
Modern Kernel Examples • Windows NT kernel: Windows
• Unix lineage: Linux, XNU
32 • VMS lineage: Windows NT
What’s a Command Line?
Graphical User Interface (GUI): Command Line Interface (CLI):
Graphical “point and click” or Text-based paradigm for
“swipe and tap” paradigm for interacting with programs.
interacting with programs.
Programs usually designed to
Programs usually designed to accept typed (text-based) input
respond to “events”, and and produce text-based output.
display output via “widgets”.
Easier to code, more flexible, and
Often more user-friendly. easier to execute remotely.
33
What’s a Terminal and a Shell?
Terminal Emulator: Shell:
GUI program that relays typed CLI or GUI program for managing
input to a CLI program and files and running other programs.
displays its output on the screen.
GUI examples:
Mac finder / dock,
Windows file mgr / start menu
CLI example: bash
34
What’s ssh?
ssh: sshd:
Stands for “secure shell” but Program that runs continuously
it’s not a shell! on a server, accepts network
connections from ssh clients,
CLI program that connects to and relays text back/forth to
sshd on another computer and a local shell (e.g., bash).
relays text back/forth securely.
35
Programming Environment – The Illusion
Server Client
ArmLab Cluster Your Computer
SSH
Linux OS
GNU
tools
Your
Program
armlab01
armlab02
36
Programming Environment – The Reality
Linux OS MacOS
ssh GUI
bash sshd
bash Terminal
armlab Your Mac computer
(Windows would be similar)
37
What’s a Text Editor?
Text Editor: Integrated Development
Allows editing plain text: Environment (IDE):
just a sequence of characters.
Examples: TextEdit, Notepad,
Text editor optimized for code –
emacs
usually integrates syntax coloring,
compiling, searching for errors,
sometimes suggesting variable
Word Processor:
names or code snippets.
Allows editing text with formatting
Examples: IntelliJ, Visual Studio,
(various fonts, paragraphs, etc.)
emacs with the appropriate
Does not output plain-text.
configuration
38 Examples: Word, Pages
Filesystems
Directories
(“folder” metaphor in GUIs)
u usr
…
you bin
hi.c
ls
#include <stdio.h>
int main(void)
Files
{
...
} Machine code …
39
Filesystems
Root directory
Name: ls
(Absolute) Path: /usr/bin/ls
u usr
…
you bin
hi.c
ls
#include <stdio.h>
int main(void)
{
...
Home directory Machine code …
}
40
Filesystems
Current directory / working directory
• Any name not starting with /
is interpreted starting at
the current directory: u usr
relative path
…
you
• Change current bin
directory with
hi.c
cd command e.g., if /u is current: ls
#include <stdio.h>
int main(void)
{
Relative: you/hi.c
...
}
Absolute: /u/you/hi.c Machine code …
41
Filesystems
Special names
• . (single dot) is “here”
• .. (double dot) is parent
u usr
• ~ (tilde) is home
…
you bin
hi.c
ls
#include <stdio.h>
int main(void)
{
...
} Machine code …
42
Next steps …
@tateisimikito
Check out course website soon
• Study “Policies” page
Upcoming lectures: Git, C programming
43 • In preparation for assignments 0 and 1