Lecture 1
Lecture 1
The Pasta
Theor y of
Programming Lasagna
– By Raymond J. Understandable. Layered.
Rubey
Ravioli
Modular. Nourishing
Source: https://www.gnu.org/fun/jokes/pasta.code.html
It Is Important to Write Good Code
• Easy to maintain
• If you need to change something you know where & how
• Gets the job done & done well
• Write working code effectively and efficiently
• Easy to share
• Reusable, adds value, engaging, and empowering
Source: https://xkcd.com/844/
What You Will Learn in This Course
4
What This Course Is Really About
5
How This Course Is Related to Your Labs
6
Lectures Labs
Lecture Over view
• Logistics
• Expectations
• How to do well in this course
• Concepts in Computing Science
• Introduction to C
7
Logistics – Your Course Instructor
• Victor Cheung
• PhD in System Design Engineering, University of Waterloo
• Research in interaction & interface design, tangible systems, emerging technologies
• [email protected]
8
Logistics – Course Info
• Lectures: Wednesdays 1:30p – 2:20p (SSCB 9200), Fridays 12:30p – 2:20p (SSCB 9200)
• Labs: Tuesdays 8:30a – 9:20a / 9:30a – 10:20a / 10:30a – 11:20a / 11:30a – 12:20p (ASB 9838N)
• Office Hours: TBA, check SFU Canvas
• Teaching Team
When sending your email:
• Instructor: Victor Cheung, PhD | Email: [email protected] • Use your SFU email
• In the subject line begin with "CMPT 125 D100:"
• Teaching Assistants:
and then topic of your message. For example,
• Kajori Roy | Email: [email protected] CMPT 125 D100: Missed Assignment 1
• In the body of your message, include your full
• Risheek Sood | Email: [email protected]
name, SFU ID, 9-digit student number and section
• Naina Thapar | Email: [email protected] number
• David Ricardo Wong | Email: [email protected]
• Help email that reaches all the teaching personnel: [email protected] 9
Logistics – Readings
*Instructor’s notes prevail when there is a conflict. Contact the instructor when in doubt 10
Logistics – Course Materials
• Tentative:
• Assignment 1/2/3/4 (30%) | due on Sep 29/ Oct 13/ Nov 10/ Dec 1
• Lab Attendance/Demo (10%): best 10 out of all available labs
• Midterm Exam (25%): cumulative and include all materials covered thus far | on Week 9 during the 2-hour lecture
• Final Exam (35%): cumulative and include all materials covered thus far | TBA
• Assignment late penalty: 10% per calendar day (each 0 to 24 hour period past due), max 2 days late
• The instructor will do his best to accommodate within reason, but will have the final say
• Contact the instructor as soon as possible
• More details as the due dates approach
12
Logistics – General Etiquette
13
Things That You Should Know (Doesn’t have to be in C)
• Variables
• Data types (integer, float, char, string, boolean)
• Lists/arrays
• Basic I/O
Don’t worry if you
• Conditionals (if/if-else/if-else if-else) only remember some,
• Loops (for, while)
• Functions, parameter passing
we’ll revisit them
• The design → test → debug cycle
14
Examples of Things You Should Know
• You should be comfortable solving the following problems (in Python, Java, …etc.)
• Write a function that gets a string and decide if it is a palindrome. For example:
is_palindrome(“ABCDCBA”) needs to return True
is_palindrome(“ABCDB”) needs to return False
• Write a function that gets a string and finds the longest substring that is a palindrome. For example:
longest_substring_palindrome(“ABCDBAABBA”) needs to return “ABBA”
longest_substring_palindrome(“ABCDB”) needs to return “A”
• Write a function that gets a list of digits, and outputs a string containing the largest number you can writing
using these digits. For example:
max_number([1,2,8,8,1,1, 0]) needs to return “8821110”
15
Should You Take This Course?
• If you want to learn about Computing Science and • If you are here only to learn C/C++
what it is about
• If you do not want to write code
• If you want to become better in designing and
• If you are looking for an easy A
writing your code
• If you have some programming background and
want to learn about C/C++
16
Who Will Do Well in This Course?
• No plagiarism
• All referenced work must be appropriately cited, including code, websites, images, figures, and graphs
• Never directly copy & paste and treat it as yours
• You must write your own code (we will use software, e.g., MOSS, to check)
• No cheating
• All assignments/exams must be your own work (team’s work if it is a team project)
• It is ok to discuss with others for assignments, but you have to write your own work. Mention whom you have talked to if necessary
• All incidents will be reported according to SFU policy
• http://www.sfu.ca/policies/gazette/student/s10-01.html
• Understand what is considered cheating and what is not at SFU’s Academic Integrity Tutorial (https://canvas.sfu.ca/courses/56136)
18
What about ChatGPT (or Other AI Tools)?
• I know they exist (and I use them sometimes), they work like helpers/tutors
• General rule-of-thumb: you can use them, but DO NOT copy (that’s academic dishonesty)
• Be aware of the risks:
• …
• Keep this in mind:
• You can’t use them in exam
• Not only you have access to them
• You are not a child anymore and you are responsible to your own decisions & actions
• Manage your time
• Plan ahead for deadlines, get enough rests, do stuff that you enjoy
• Be proactive
• Look up information beyond what’s in the slides, ask questions when in doubt
• We might not answer your questions if we have already provided answers to them
• Do honest work
• All the academic integrity information are available and you can’t claim you don’t know about them
20
Expectation Management
• 125 is very different and the pace is much faster than 120 or your other intro courses
• It combines programming, CS concepts, and labs all in one course
• You are expected to write a lot of code
• Expect to write multiple files, each about 200-300 lines of code
• You only have 2-3 weeks between each assignment, some build on top of the previous
• You are expected to do your own practice and read additional materials as needed
• We will provide some post-lecture activities, practice exercises, complementary readings, but in
the end you need to help yourself
21
Questions?
If you have questions later in the course, feel free to ask them in the Discussion on Canvas
22
Let’s start with Some Concepts
23
Some Core Concepts in Computing Science
24
The Compilation Process (1)
Interpreter
• Algorithm • Running program
• Source code
You Output
25
The Compilation Process (2)
Compiler Output
• Algorithm • Machine code
• Source code • Running
program
You Computer
26
Interpreted VS Compiled
INTERPRETED COMPILED
• Errors are caught only when the interpreter is • Some errors can be caught during compile time so
trying to run them they can be fixed earlier
• Can test the code quicker because the interpreter • Takes a bit longer to get the code running because
directly runs it of the compilation process
• Program is less optimized because the interpreter • Program often performs better because some
needs to convert the code into machine code optimizations for the operating system and
internally every time architecture can be done by the compiler
27
C is within the top 3 most popular (used/searched/taught) programming language
28
Something about C
• C was developed by Dennis Ritchie between 1972 & 1973 at AT&T Bell Labs
• Designed to map to typical machine instruction – so the source code can easily be compiled & optimized,
but also sometimes hard to understand
• Widely used to implement operating systems, computationally intensive programs, computer graphics
• Provides low-level access to system memory via pointers – highly flexible but can cause strange and
sometimes harmful impacts to the system
29
Let’s Take A Look at A C Program
What happens if
you want to print
Lines 3-7 is what we
more sentences?
call the “main function”,
which is the entry
point of a C program
30
*Refer to the “Accessing CSIL machines remotely” page on Canvas to learn about different ways to connect to CSIL
Homework!
31