lecture1_welcome
lecture1_welcome
1
Asking Questions
- We welcome questions!!
- Feel free to raise your hand at any time with a
question
- We’ll also pause periodically to solicit
questions
11
Asking Questions
- Welcome questions!!
- Feel free to raise your hand at any time with a
question
- We’ll also pause periodically to solicit
questions
- We’re not going to do audience “questions” in
lecture that are just showing off that you
know some jargon or advanced topic
12
Total Score
13
Community Norms
- Shame-free zone
- Treat your peers and instructors with kindness
and respect
- Be curious
- Communication is key!
- Recognize we are all in-process (humility,
question posing, avoid perfectionism)
14
Lecture
- C++ is a huge language. I want you to get
practice with some things, exposure to others,
and a lot is not covered.
17
Lecture
If you feel ill or are sick, for the wellbeing of
yourself and others please stay home, take care
of yourself, and reach out to us - we never want
you to feel that you must attend class if you
are not feeling well!
Similarly, if you have an emergency or
exceptional circumstance, please reach out to
use so that we can help
18
Learning Outcomes
- Practice using industry standard coding tools
such as ssh and VSCode
- Gain familiarity with powerful features of the stl
- Practice reading documentation to learn how to
use a new language feature
- Exposure to standard c++ syntax and norms
- Learn a few “advanced” features of classes
25
Questions?
26
Why C++?
30
C++ is still a very popular language
31
Many Cool Things Use/Were Made with C++
33
Why C++?
FAST Lower-level control
Ruby
Javascript
High
Level
Python
Java
C++
C
Low
Level Assembly
Machine Code
34
What is C++?
35
Some C++ Code
#include <iostream>
int main() {
std::cout << "Hello, world!" << std::endl;
return 0;
}
36
Also some C++ Code
#include "stdio.h"
#include "stdlib.h"
37
Also (technically) some C++
code
#include "stdio.h"
#include "stdlib.h"
38
C++ History: Assembly
section .text
global _start ;must be declared for linker (ld)
section .data
msg db 'Hello, world!' ,0xa ;our dear string
len equ $ - msg ;length of our dear string
39
C++ History: Assembly
Benefits:
- Unbelievably simple instructions
- Extremely fast (when well-written)
- Complete control over your program
Why don’t we always use Assembly?
40
Assembly looks like this
section .text
global _start ;must be declared for linker (ld)
section .data
msg db 'Hello, world!' ,0xa ;our dear string
len equ $ - msg ;length of our dear string
41
C++ History: Assembly
Drawbacks:
- A LOT of code to do simple tasks
- Very hard to understand
- Extremely unportable (hard to make work
across all systems)
42
Next in C++ History: Invention of C
Problem: computers can only understand assembly!
- Idea:
- Source code can be written in a more intuitive
language
- An additional program can convert it into
assembly
- This additional program is called a
compiler!
- Take CS143 to learn more!
43
C++ History: Invention of C
- T&R created C in 1972, to much praise
- C made it easy to write code that was
■ Fast
■ Simple
■ Cross-platform
- Learn to love it in CS107!
Ken Thompson and Dennis
Ritchie, creators of the C
language.
44
C++ History: Invention of C
- C was popular because it was simple.
- This was also its weakness:
- No objects or classes
- Difficult to write generic code
- Tedious when writing large programs
45
C++ History: Welcome to C++!
- In 1983, the beginnings of C++ were created by
Bjarne Stroustrup.
- He wanted a language that was:
- Fast
- Simple to use
- Cross-platform
- Had high-level features
46
C++ History: Evolution of We are here
C++
C with
C++98 C++11 C++17 C++23
Classes
47
Design Philosophy of C++
48
Design Philosophy of C++
- Only add features if they solve an actual problem
- Programmers should be free to choose their own
style
- Compartmentalization is key
- Allow the programmer full control if they want it
- Don’t sacrifice performance except as a last resort
- Enforce safety at compile time whenever possible
49
Design Philosophy of C++
- Only add features if they solve an actual problem
- Programmers should be free to choose their own
style
- Compartmentalization is key
- Allow the programmer full control if they want it
- Don’t sacrifice performance except as a last resort
- Enforce safety at compile time whenever possible
50
Design Philosophy of C++
- Only add features if they solve an actual problem
- Programmers should be free to choose their own
style
- Compartmentalization is key
- Allow the programmer full control if they want it
- Don’t sacrifice performance except as a last resort
- Enforce safety at compile time whenever possible
51
Questions?
52
But...What is C++?
53
C++: Basic Syntax + the STL
Basic syntax The STL
- Semicolons at EOL - Tons of general
- Primitive types (ints, functionality
doubles etc) - Built in classes like
- Basic grammar rules maps, sets, vectors
- Accessed through the
namespace std::
55
Standard C++: Basic Syntax + std library
Basic The STL
syntax
- Tons of
- Semicolons at general
EOL functionality
- Built
- Primitive in classes
types (ints, like maps, sets, vectors
- Accessed
doubles etc) through the namespace std::
- Basic- grammar
Extremely powerful and well-maintained
rules
56