Lect1 Introduction
Lect1 Introduction
COMP201
Computer
Systems &
Programming
Lecture #01 – Introduction
Aykut Erdem // Koç University // Spring 2023
2
A little about me…
Koç University
Associate Professor
2020-now
Hacettepe University
Associate Professor
2010-2020 • I explore better ways to
understand, interpret
Universitá Ca’ Foscari di Venezia
Post-doctoral Researcher and manipulate visual
2008-2010 data.
Middle East Technical University
1997-2008 • My research interests
Ph.D., 2008
M.Sc., 2003 span a diverse set of
B.Sc., 2001 topics, ranging from
MIT image editing to visual
Fall 2007 saliency estimation,
Visiting Student
and to multimodal
VirginiaTech
Visiting Research Scholar
learning for integrated
Summer 2006 vision and language. https://aykuterdem.github.io
3
Plan For Today
• Course Introduction
• COMP201 Course Policies
• Unix and the Command Line
• Getting Started With C
5
What is COMP201?
• The third course in the line of COMP’s introductory programming
courses (COMP100, COMP132, and COMP201)
– COMP100 teaches you the notion of computational thinking and how to solve
problems as a programmer (using Python)
– COMP132 introduces you object-oriented programming paradigm (using Java)
COMP201
Computer Systems
and Programming
COMP100 COMP132
Intro. to CS & Advanced
Programming Programming
7
What is COMP201?
Computer Systems and Programming
• How languages like C++ and Java represent data
under the hood
• How programming structures are encoded in bits and
bytes
• How to efficiently manipulate and manage memory
• How computers compile programs
• How cache memories work and how to exploit them
to improve the performance of your programs
• Uses the C programming language
• Programming style and software development
practices
8
COMP201 Learning Goals
The goals for COMP201 are for students
to gain mastery of
- writing C programs with complex use of memory and
pointers
- an accurate model of the address space and
compile/runtime behavior of C programs
to achieve competence in
- translating C to/from assembly
- writing programs that respect the limitations of computer
arithmetic
- finding bottlenecks and improving runtime performance
- working effectively in a Unix development environment
Jeff Goldblum’s character saving the Elliot creating a malicious PDF file, which
world by uploading a virus to contains some sort of shellcode that will
the alien mothership allow him to take over any Linux
Independence Day, 1996 computer that opens that file in Evince.
Mr. Robot, S3, Ep9 -
eps3.8_stage3.torrent (2017)
Source: https://www.geekwire.com/2017/mr-robot-rewind-pwning-dark-army-episode-9/
Course Overview
1. Bits and Bytes - How can a computer represent integer numbers?
2. Chars and C-Strings - How can a computer represent and manipulate more
complex data like text?
3. Pointers, Stack and Heap – How can we effectively manage all types of
memory in our programs?
4. Generics - How can we use our knowledge of memory and data representation
to write code that works with any data type?
5. Assembly - How does a computer interpret and execute C programs?
6. The Memory Hierarchy - How does the memory system is organized as a
hierarchy of different storage devices with unique capacities
7. The Heap Allocators - How do core memory-allocation operations
like malloc and free work? 11
Teaching Team
Aykut Erdem
12
Course Website
https://aykuterdem.github.io/classes/comp201.s23/
*lecture videos on Panopto – can be accesses through Blackboard or from the course webpage
13
Question Break!
14
Lecture Plan
• Introduction
• COMP201 Course Policies
• Unix and the Command Line
• Getting Started With C
15
Textbooks
• Computer Systems: A Programmer’s
Perspective by Bryant & O’Hallaron,
3rd Edition
– 3rd edition matters – important updates
to course materials
• A C programming reference of your
choice
– The C Programming Language by
Kernighan and Ritchie
– Other C programming books, websites,
or reference sheets
16
Course Structure
• Lectures: understand concepts, see demos
• Labs: learn tools, study code, discuss with peers
• Assignments: build programming skills, synthesize lecture/lab content
18
Grading
27% Programming assignments
28% Labs
20% Midterm exam
20% Final exam
5% Class participation
19
Assignments
• 5 programming assignments completed
individually using Unix command line tools
– Free software, pre-installed on linuxpool cluster
dedicated to COMP students
– GitHub Classroom
– We will give out starter projects for each
assignment
• Graded on functionality (behavior) and style
(elegance)
– Functionality graded using automated tools, given
as point score
– Style graded via automated tests and TA code
review,
– Grades returned via Blackboard
20
Late Policy
• Start out with 7 grace days: each late day allows you to submit an
assignment without penalty if you have free grace days left.
• Hard deadline: No submissions will be accepted 48 hours after the
original due date of an assignment
• Penalty per day after grace days are exhausted
– 1 day: 20% off
– 2 days: 40% off
• Submissions made on Blackboard at 00:01am after the deadline counts as late and are
considered as using 1 grace day
21
Grading
27% Programming assignments
28% Labs
20% Midterm exam
20% Final exam
5% Class participation
22
Lab Sections
• Weekly 100-minute labs led by a TA, starting next Friday.
• Hands-on practice with lecture material and course topics.
+ linuxpool.ku.edu.tr
• Graded on attendance + participation (verified by submitting lab work)
– Two graded part:
– In-class practice problem (40%)
– After-class problem (60%)
– Your lowest 2 scores will be dropped, hence there will be no make-up
24
Midterm and Final Exams
• Face-to-face exams
– Midterm: At week 7, exact date and time will be announced later
– Final: Date and time will be announced later
25
Grading
27% Programming assignments
28% Labs
20% Midterm exam
20% Final exam
5% Class participation
26
What foreign TV series
are you watching now?
Just specify the one
that you are enjoying
the most!
27
Question Break!
28
Getting Help
• Post on the Discussion Forum at Blackboard
– Online discussion forum for students; post questions, answer other students’
questions
– Best for general assignment questions (DON’T POST ASSIGNMENT CODE!)
29
Koç University Honor Code
• For assignments students should be required to digitally add and approve a
version of the agreement below.
I hereby declare that I have completed this examination individually, without support
from anyone else.
I hereby accept that only the below listed sources are approved to be used during this
open-source examination:
(i) Coursebook,
(ii) All material that is made available to students via Blackboard for this course, and
(iii) Notes taken by me during lectures.
I have not used, accessed or taken any unpermitted information from any other
source. Hence, all effort belongs to me.
30
Honor Code and COMP201
• Please help us ensure academic integrity:
– Indicate any assistance received on HW (books, friends, etc.).
– Do not look at other people's solution code or answers
– Do not give your solutions to others or post them on the web or to the forum.
– Report any inappropriate activity you see performed by others.
32
Lecture Plan
• Introduction
• COMP201 Course Policies
• Unix and the Command Line
• Getting Started With C
33
What is Unix?
• Unix: a set of standards and tools commonly used in software development.
– macOS and Linux are operating systems built on top of Unix
• You can navigate a Unix system using the command line (“terminal”)
• Every Unix system works with the same tools and commands
34
What is the Command Line?
• The command-line is a text-based interface (i.e., terminal interface) to
navigate a computer, instead of a Graphical User Interface (GUI).
• We’ll use Unix and the command line to implement and execute our programs.
37
Demo: Using Unix and the Command Line
38
Unix Commands Recap
• cd – change directories (..)
• ls – list directory contents
• mkdir – make directory
• emacs – open text editor Lab 1:
• vi – open text editor The Linux Shell
(next week)
• rm – remove file or folder
• man – view manual pages
See the Resources page of the course website for more commands, and
a complete reference.
39
Learning Unix and the Command Line
• Using Unix and the command line can be intimidating at first:
– It looks retro!
– How do I know what to type?
40
Question Break!
41
Additional Reading 1
https://spectrum.ieee.org/tech-history/cyberspace/the-strange-birth-and-long-life-of-unix
42
Lecture Plan
• Introduction
• COMP201 Course Policies
• Unix and the Command Line
• Getting Started With C
43
The C Language
C was created around 1970 to make writing Unix and Unix tools easier.
• Part of the C/C++/Java family of languages (C++ and Java were
created later)
• Design principles:
– Small, simple abstractions of hardware
– Minimalist aesthetic
– Prioritizes efficiency and minimalism over safety and high-level abstractions
44
C vs. C++ and Java
They all share: C doesn’t have:
• Syntax • More advanced features like
• Basic data types operator overloading, default
arguments, pass by reference,
• Arithmetic, relational, and logical classes and objects, ADTs, etc.
operators
• Extensive libraries (no graphics,
networking, etc.) – this means
not much to learn C!
• many compiler and runtime
checks (this may cause security
vulnerabilities!)
45
Programming Language Philosophies
• C is procedural: you write functions, rather than define new variable
types with classes and call methods on objects. C is small, fast and
efficient.
• C++ is procedural, with objects: you write functions, and define new
variable types with classes, and call methods on objects.
• Python is also procedural, but dynamically typed: you still write
functions and call methods on objects, but the development process is
very different.
• Java is object-oriented: virtually everything is an object, and everything
you write needs to conform to the object-oriented design pattern.
46
Why C?
• Many tools (and even other languages, like Python!) are built with C.
• C is the language of choice for fast, highly efficient programs.
• C is popular for systems programming (operating systems, networking,
etc.)
• C lets you work at a lower level to manipulate and understand the
underlying system.
47
Programming Language Popularity
Guess which one is
the C language?
https://www.tiobe.com/tiobe-index/ 48
Programming Language Popularity
Guess which one is
the C language?
https://www.tiobe.com/tiobe-index/ 49
Programming Language Popularity
Guess which one is
the C language?
https://www.tiobe.com/tiobe-index/ 50
Programming Language Popularity
https://www.tiobe.com/tiobe-index/ 51
Our First C Program
/*
* hello.c
* This program prints a welcome message
* to the user.
*/
#include <stdio.h> // for printf
52
Our First C Program
/*
* hello.c
* This program prints a welcome message
* to the user.
*/
#include <stdio.h> // for printf
53
Our First C Program
/*
* hello.c
* This program prints a welcome message
* to the user.
*/
#include <stdio.h> // for printf
54
Our First C Program
/*
* hello.c
* This program prints a welcome message
* to the user.
*/
#include <stdio.h> // for printf
58
Boolean Variables
To declare Booleans, (e.g. bool b = ____), you must include stdbool.h:
#include <stdio.h> // for printf
#include <stdbool.h> // for bool
59
Boolean Expressions
C treats a nonzero value as true, and a zero value as false:
#include <stdio.h>
// Example
char *classPrefix = "COMP";
int classNumber = 201;
printf("You are in %s%d", classPrefix, classNumber); // You are in COMP201
https://arstechnica.com/features/2020/12/a-damn-stupid-thing-to-do-the-origins-of-c/
62
Question Break!
63
Writing, Debugging and Compiling
We will use:
• the vi/emacs text editor to write our C programs
• the make tool to compile our C programs
• the gdb debugger to debug our programs
• the valgrind tools to debug memory errors and measure program
efficiency
64
Demo: Compiling And
Running A C Program
args.c
65
Working On C Programs Recap
• ssh – remotely log in to linuxpool computers (later)
• Vi/Emacs – text editor to write and edit C programs
– Use the mouse to position cursor, scroll, and highlight text
– :w / Ctl-x Ctl-s to save, :q / Ctl-x Ctl-c to quit
• make – compile program using provided Makefile
• ./myprogram – run executable program (optionally with arguments)
• make clean – remove executables and other compiler files
• Lecture codes are accessible at course webpage
66
Recap
• COMP201 is a programming class, which uses
C to teach you about what goes on under the
hood of programming languages and software.