1 of 142

1

2 of 142

Abstract: The C++ language has a reputation of being a very powerful, fast, and expressive, but hard to learn language for beginners. My opinion though, is that we can always be improving our learning materials for beginners--that's why I teach the C++ programming language one pixel at a time. What does a pixel have to do with the language? It's not so much the graphics (though that is a motivating domain to use the C++ language), but in the ability for beginning programmers to visualize and see what they are programming. In this talk I reflect on how to not just teach C++, but how to motivate, inspire, and get beginners to build cool graphical projects while learning the Modern C++ language.

2

3 of 142

Abstract: The C++ language has a reputation of being a very powerful, fast, and expressive, but hard to learn language for beginners. My opinion though, is that we can always be improving our learning materials for beginners--that's why I teach the C++ programming language one pixel at a time. What does a pixel have to do with the language? It's not so much the graphics (though that is a motivating domain to use the C++ language), but in the ability for beginning programmers to visualize and see what they are programming. In this talk I reflect on how to not just teach C++, but how to motivate, inspire, and get beginners to build cool graphical projects while learning the Modern C++ language.

3

If I’m successful, both you and I will have a system for course construction that’s effective for our students.

(At the very least, you’ll have some neat assignment ideas to build off of)

4 of 142

Abstract: The C++ language has a reputation of being a very powerful, fast, and expressive, but hard to learn language for beginners. My opinion though, is that we can always be improving our learning materials for beginners--that's why I teach the C++ programming language one pixel at a time. What does a pixel have to do with the language? It's not so much the graphics (though that is a motivating domain to use the C++ language), but in the ability for beginning programmers to visualize and see what they are programming. In this talk I reflect on how to not just teach C++, but how to motivate, inspire, and get beginners to build cool graphical projects while learning the Modern C++ language.

4

For folks attending online, please feel free to use the Q&A, I’ll answer questions at the end.

For folks in the room, ask questions at any time, and I’ll repeat the question.

5 of 142

Who Am I?�by Mike Shah

  • Assistant Teaching Professor at Northeastern University in Boston, Massachusetts.
    • I teach courses in computer systems, computer graphics, and game engine development.
    • My research in program analysis is related to performance building static/dynamic analysis and software visualization tools.
  • I do consulting and technical training on modern C++, Concurrency, OpenGL, and Vulkan projects
    • (Usually graphics or games related)
  • I like teaching, guitar, running, weight training, and anything in computer science under the domain of computer graphics, visualization, concurrency, and parallelism.
  • Contact information and more on: www.mshah.io

5

6 of 142

6

April 7, 2022 | 14:00 - 15:30

Mike Shah, Ph.D. | @MichaelShah

www.youtube.com/c/MikeShahwww.mshah.io

7 of 142

HOW I TEACH MODERN C++ ONE PIXEL AT A TIME

7

This talk is about teaching C++ in a semester long University Course

April 7, 2022 | 14:00 - 15:30

Mike Shah, Ph.D. | @MichaelShah

www.youtube.com/c/MikeShahwww.mshah.io

8 of 142

Before we begin...a video

8

9 of 142

9

10 of 142

This should not be your style of teaching...almost anything*

10

*This video is of course a comedy

11 of 142

This should not be your style of teaching...almost anything*

11

*This video is of course a comedy

So, let’s set the stage here for teaching

12 of 142

Some Context - Who is being taught?

My Pre-Course Survey to understand my students

(Pro Tip: Always survey your students)

12

13 of 142

My Programming in C++ Course

  • This is a course that I teach to students usually in their 2nd year at university
    • It is a semester long course
    • Caveat: This particular iteration is crammed into a 7 week summer session moving twice as fast
  • Most students have taken at least 2 semesters of programming prior to taking this course
    • Usually with experience in Python, Java or a functional language like Scheme
    • Most students have not seen manual memory management (malloc/free or new/delete)
    • A good subset of students are part of data science or game programming based degrees

13

14 of 142

My Course - Pre-Course Survey Data (1/6)

14

15 of 142

My Course - Pre-Course Survey Data (2/6)

15

16 of 142

My Course - Pre-Course Survey Data (3/6)

16

Not very comfortable

Very comfortable!

Average

17 of 142

My Course - Pre-Course Survey Data (4/6)

17

Not very comfortable

Very comfortable!

Average

18 of 142

My Course - Pre-Course Survey Data (5/6)

18

I’d say everyone is being brutally honest!

19 of 142

My Course - Pre-Course Survey Data (6/6)

19

Not very comfortable

Very comfortable!

Average

So here’s my audience. Folks who know some programming, but haven’t been exposed to C++

Not very comfortable

20 of 142

HOW I TEACH MODERN C++ ONE PIXEL AT A TIME

20

April 7, 2022 | 14:00 - 15:30

Mike Shah, Ph.D. | @MichaelShah

www.youtube.com/c/MikeShahwww.mshah.io

Now, I know how I teach. So I hope that will be interesting, but...

21 of 142

HOW I TEACH MODERN C++ ONE PIXEL AT A TIME

21

April 7, 2022 | 14:00 - 15:30

Mike Shah, Ph.D. | @MichaelShah

www.youtube.com/c/MikeShahwww.mshah.io

Now, I know how I teach. So I hope that will be interesting, but...

I want you to think about how you teach

22 of 142

HOW [YOU MIGHT] TEACH MODERN �C++ [NEXT] TIME

22

April 7, 2022 | 14:00 - 15:30

Mike Shah, Ph.D. | @MichaelShah

www.youtube.com/c/MikeShahwww.mshah.io

Now, I know how I teach. So I hope that will be interesting, but...

I want you to think about how you teach

23 of 142

HOW [YOU MIGHT] TEACH MODERN �C++ [NEXT] TIME

23

April 7, 2022 | 14:00 - 15:30

Mike Shah, Ph.D. | @MichaelShah

www.youtube.com/c/MikeShahwww.mshah.io

The talk will be more applicable if you reflect on your teaching--whether a teacher, professor, C++ trainer, manager, youtuber, etc.

24 of 142

Some Homework for the Audience

(Whether present, virtual, or in the future!)

24

25 of 142

Homework (Yes...I am a professor)

(Take a screenshot or take a few notes -- we’ll revisit this list today)

  • Will you (or are you currently) teaching with a common theme?
  • Are you willing to sacrifice 20% of your course so students have a chance to understand 99.9% of the remaining 80% of your course?
  • Do you discuss debugging early in the course?
  • Will you teach C++ without telling them the language is scary, and they must also know the ‘C’ language?
  • Your other notes: ____________________________________________________________________________________________________________________________________________________________________________________________________________

25

26 of 142

Homework (Yes...I am a professor)

(Take a screenshot or take a few notes -- we’ll revisit this list today)

  • Will you (or are you currently) teaching with a common theme?
  • Are you willing to sacrifice 20% of your course so students have a chance to understand 99.9% of the remaining 80% of your course?
  • Do you discuss debugging early in the course?
  • Will you teach C++ without telling them the language is scary, and they must also know the ‘C’ language?
  • Your other notes: ____________________________________________________________________________________________________________________________________________________________________________________________________________

26

Let’s begin!

27 of 142

Why do we need to think about how we teach C++?

27

28 of 142

(In my opinion) C++ Greatest Strength for a learner (1/2)

  • The #1 strength of C++ is that as a language it scales with you as you learn more computer science.
    • You can use it as a simple procedural language to start
    • You can use it as you learn different paradigms (i.e. functional, object-oriented, etc.) or different design patterns
    • You can leverage the language to work with the system as you learn about computer architecture
    • You can use C++ with large and small software
    • You learn over time the pros/cons of C++’s design which helps you understand other language design decisions
    • ...and many more skills you can scale into (parallel programming, networking, etc.)

28

29 of 142

(In my opinion) C++ Greatest Strength for a learner (2/2)

  • The #1 strength of C++ is that as a language it scales with you as you learn more computer science.
    • You can use it as a simple procedural language to start
    • You can use it as you learn different paradigms (i.e. functional, object-oriented, etc.) or different design patterns
    • You can leverage the language to work with the system as you learn about computer architecture
    • You can use C++ with large and small software
    • You learn over time the pros/cons of C++’s design which helps you understand other language design decisions
    • ...and many more skills you can scale into (parallel programming, networking, etc.)

29

Look at all of this cool stuff to learn!

30 of 142

(In my opinion) C++ Greatest Weakness for a learner

  • “Hmm, the language is so big--I’m overwhelmed! Where do I begin?”

30

31 of 142

(In my opinion) C++ Greatest Weakness for a learner

  • “Hmm, I’m overwhelmed. Where do I begin?”

31

32 of 142

(In my opinion) C++ Greatest Weakness for a learner

  • “Hmm, I’m overwhelmed. Where do I begin?”

32

33 of 142

(Bringing back the original question (1/2))

  • Why do we need to think about how we teach C++?

^ This is our job as educators (whether a professor, teacher, trainer, colleague giving a tech talk, etc.) to guide our learners on a journey for learning how to use a programming language to solve problems.

33

34 of 142

(Bringing back the original question (2/2))

  • Why do we need to think about how we teach C++?

^ This is our job as educators (whether a professor, teacher, trainer, colleague giving a tech talk, etc.) to guide our learners on a journey for learning how to use a programming language to solve problems.

34

https://www.fluentcpp.com/getthemap/(Just for fun, a map of C++ STL Algorithms)

A good course, seminar, tech talk, etc. should guide the learner.

Our job, is to provide a ‘map’ that can be easily read and followed.

35 of 142

[Course Construction]

Where do we start?

What will students build?

What skills will students learn?

35

36 of 142

Here’s where I start (1/3)

  • First, I need a strong course mantra or theme
    • This gives you something to center a whole course around
      • Whenever I have a decision to make, I ask myself if it fits the course theme.
      • This constraint--helps me, and it helps keep students in the same domain
    • (Some folks will start with a series of learning objectives, but I think the theme comes first, then the learning objectives)
  • So as you know, my theme is....

36

37 of 142

Here’s where I start (2/3)

  • First, I need a strong course mantra or theme
    • This gives you something to center a whole course around
      • Whenever I have a decision to make, I ask myself if it fits the course theme.
      • This constraint--helps me, and it helps keep students in the same domain
    • (Some folks will start with a series of learning objectives, but I think the theme comes first, then the learning objectives)
  • So as you know, my theme is....

37

38 of 142

Here’s where I start (3/3)

  • First, I need a strong course mantra or theme
    • This gives you something to center a whole course around
      • Whenever I have a decision to make, I ask myself if it fits the course theme.
      • This constraint--helps me, and it helps keep students in the same domain
    • (Some folks will start with a series of learning objectives, but I think the theme comes first, then the learning objectives)
  • So as you know, my theme is....

38

39 of 142

Backstory

  • Now, I had this idea to do a course with this theme for some time.
    • 1.) Could possibly be cool to students
      • (I’ll get to why ‘cool’ and ‘inspiration’ are important to students)
    • 2.) Could help students better be able to *think* and *see* a real world problem they are solving
      • (The assignments could involve an algorithmic part, and have them solve real problems)
  • A single article inspired this idea of focusing on ‘pixel effects’

39

40 of 142

Here’s the article! (1/2)

  • The original inspiration for an early assignment and the theme of this course
  • Recreating the DOOM fire effect from the opening scene.
  • And I kept seeing this effect implemented over and over again on twitter!

40

41 of 142

Here’s the article! (2/2)

  • The original inspiration for an early assignment and the theme of this course
  • Recreating the DOOM fire effect from the opening scene.
  • And I kept seeing this effect implemented over and over again on twitter!
    • (And added my own)

41

42 of 142

Let there be fire!

  • Now from looking at the actual effect, it is really only a few lines of code.
    • A small enough problem for students to see the core idea in JavaScript
    • But I could see how to implement this, students would have to understand:
      • 1D-arrays and/or 2D-arrays
      • iteration
      • function calls
      • and a color palette (A 1D-array, but storing color data in a lookup table)

42

43 of 142

  • So I have a theme for my course-- graphical programs manipulating pixels
    • Students will write graphical programs to help them ‘see’ as they learn
    • Algorithmically interesting problems could be solved.
    • Theme feels inclusive (interesting to a wide variety of students)

43

44 of 142

  • So I have a theme for my course-- graphical programs manipulating pixels
    • Students will write graphical programs to help them ‘see’ as they learn
    • Algorithmically interesting problems could be solved.
    • Theme feels inclusive (potentially interesting to a wide variety of students)

44

Let’s do a quick check on the ‘homework’ I gave everyone (myself included)

45 of 142

  • So I have a theme for my course-- graphical programs manipulating pixels
    • Students will write graphical programs to help them ‘see’ as they learn
    • Algorithmically interesting problems could be solved.
    • Theme feels inclusive (potentially interesting to a wide variety of students)

45

46 of 142

  • So I have a theme for my course-- graphical programs manipulating pixels
    • Students will write graphical programs to help them ‘see’ as they learn
    • Algorithmically interesting problems could be solved.
    • Theme feels inclusive (potentially interesting to a wide variety of students)

46

47 of 142

  • So I have a theme for my course-- graphical programs manipulating pixels
    • Students will write graphical programs to help them ‘see’ as they learn
    • Algorithmically interesting problems could be solved.
    • Theme feels inclusive (potentially interesting to a wide variety of students)

  • Okay...what is the rest of the course going to look like?

47

48 of 142

[Course Construction]

Where do we start?

What will students build?

What skills will students learn?

48

49 of 142

What will students build? (1/2)

  • So I have at least one ‘neat’ pixel effect, but what about the rest of the course?
    • Maybe I could search some of the contents of C++ books table of contents?
      • Maybe I could retrofit some of the exercises to involve graphics.
      • But that doesn’t seem quite right--so I’m focusing on what students will build--cool 2D pixel graphics effects.
        • Again, guided my my ‘mantra’ or ‘theme’

49

50 of 142

What will students build? (2/2)

  • So I have at least one ‘neat’ pixel effect, but what about the rest of the course?
    • Maybe I could search some of the contents of C++ books table of contents?
      • Maybe I could retrofit some of the exercises to involve graphics.
      • But that doesn’t seem quite right--so I’m focusing on what students will build--cool 2D pixel graphics effects.
        • Again, guided my my ‘mantra’ or ‘theme’

50

So now, began my search for cool 2D effects (beyond the DOOM Fire) that would inspire and engage students while learning C++. Some inspired from my real world experience, others examples that look neat.

51 of 142

Edge detection and other Image Processing Techniques

  • So it started simple--image processing
    • Convert images to grayscale
    • Create filters
    • Edge detection
    • Blurring of images
    • (And eventually do these with std::thread)
  • And I liked that students could verify the output--keep their confidence up knowing when they’ve reached a solution!

51

52 of 142

Procedural Textures and Noise

  • If students are going to do image processing, then they should learn about ‘noise’ functions
    • Force students to further think algorithmically
    • Procedural textures are also very creative and may appeal to students with combined degrees in art taking the class.

52

53 of 142

8 Bit & '8 Bitish' Graphics-Outside the Box

  • Mark Ferrari’s Game Developer Conference 2016 Talk [link]
    • Various 8 bit graphics tricks
    • Palette Shifting shown on the right
      • (That’s one image--no frames of animation, just pixels in the palette rotating))
  • Again--another inspiring, and self-contained example of doing a cool 2D trick.
    • Something students could show off to students outside of the class!

53

54 of 142

Parallax Scrolling

  • Create the illusion of depth in a 2D scene
    • Another assignment students could be creative with, importing their own images (or using a default)
    • Lots of students interested in games!

54

55 of 142

Falling Sands Game

  • More gaming examples come to mind
    • I started thinking more about interacting with pixels
  • A falling sands game may be particularly interesting to students,
    • Eventually forces students to build a bigger project and think about software architecture
    • (A falling sands game has different materials follow different rules)

55

56 of 142

2D Lighting (Raycasting)

  • Now I’m thinking more about interaction
  • It’s fun to play with your program once you write something
  • Here’s a cool lighting techniques
    • Maybe this would be a fun way of creating the classic ‘implement a vector2 class so I can force operator overloading on you’

56

Daniel Shiffman The Coding Train - https://www.youtube.com/watch?v=TOEi6T2mtHo

57 of 142

2D Splines

  • Implementing Splines may be another cool custom data type.
    • May be interesting to incorporate STL data structures like std::list or std::vector to store each of the control points
    • Great, students can see how the STL can save them time

57

58 of 142

Quad Trees

  • What happens when a data structure does not exist in the STL?
    • C++ programmers have to build their own data structures, here come the Quad trees!
  • A data structure for optimizing the interaction of lots of objects
    • Felt like something that could be built on after having students implement a binary tree.

58

59 of 142

2D Game with lighting effects

  • Maybe I can have students start putting all of these effects together
    • This time creating a larger ‘game like’ environment with some cool effects.

59

60 of 142

Enough Ideas--Time to think about the execution

60

61 of 142

[Course Construction]

Where do we start?

What will students build?

What skills will students learn?

61

62 of 142

[Course Construction]

Where do we start?

What will students build?

What skills will students learn?

62

Wait...not so fast on that checkmark

63 of 142

Question to Audience (1/2):

  • Have you ever been part of a class where the instructor says:
    • “I’ll just quickly go through these last slides as time is running out”
    • “I’ll let you read the rest of the material after class”
    • “I won’t cover this in class, but here are some resources...”

63

64 of 142

Question to Audience (2/2):

  • Have you ever been part of a class where the instructor says:
    • “I’ll just quickly go through these last slides as time is running out”
    • “I’ll let you read the rest of the material after class”
    • “I won’t cover this in class, but here are some resources...”

^ Yeah, all of the above break my second item here.

64

65 of 142

Each idea here could be split to multiple assignments...

65

66 of 142

And I want the students to own each project (i.e. not give them starter code)

66

67 of 142

About half of these are going to go (they’ll be future assignments for a game programming class or rotated into this class in the future)

67

68 of 142

Now our course is more appropriately scoped

68

69 of 142

Now our course is more appropriately scoped

69

70 of 142

[Course Construction]

Where do we start?

What will students build?

What skills will students learn?

70

Okay, now I get my checkmark--now let’s think about the skills students are going to learn building everything

71 of 142

What skills will students learn? (1/2)

  • Now that we’ve got the assignments, I need to think really carefully about what skills students will learn in each assignment.
    • I need to figure out some specific skills
      • “Hmm, what have I actually used in the real world”
    • I need to figure out which assignments exercise those skills in a reasonable way
    • I need to figure out a reasonable progression
      • (both in terms of difficulty, and revisiting the same skills in different contexts)

71

72 of 142

What skills will students learn? (2/2)

  • Now that we’ve got the assignments, I need to think really carefully about what skills students will learn in each assignment.
    • I need to figure out some specific skills
      • “Hmm, what have I actually used in the real world”
    • I need to figure out which assignments exercise those skills in a reasonable way
    • I need to figure out a reasonable progression
      • (both in terms of difficulty, and revisiting the same skills in different contexts)

72

So I spent some time thinking, and inspiration would arrive...from Twitter!

73 of 142

73

74 of 142

74

75 of 142

75

  • This idea I recalled from Kate Gregory’s 2015 CppCon talk
  • And to be honest...I don’t recall a single lecture in my undergrad dedicated to debugging
    • (I dedicate a lecture in my software engineering course--why not offer more immersion here!)

76 of 142

Kate Gregory’s talk in 2015 -- inspires me to teach debugging (1/3)

  • I thought about this for a few minutes
    • What do I do in the real world? I’m debugging half the time.
      • Debugging is how I get myself out of trouble.
      • If I don’t teach my students how to get out of trouble
        • They don’t learn a very critical real world skill
        • They come to office hours and I teach them one at a time--and that’s not efficient at scale.

76

77 of 142

Kate Gregory’s talk in 2015 -- inspires me to teach debugging (2/3)

  • (Spoiler Alert) So here’s the findings--
    • (next slide)

77

78 of 142

Kate Gregory’s talk in 2015 -- inspires me to teach debugging (3/3)

  • (Spoiler Alert) So here’s the findings--
    • I did teach at least 1 debugging skill at the end of every lecture (often relevant to the topic)
      • Most students figure out std::cout on week 1 and use that anyway
    • Were my efforts a waste of time?
      • (next slide)

78

79 of 142

Kate Gregory’s talk in 2015 -- inspires me to teach debugging (3/3)

  • (Spoiler Alert) So here’s the findings--
    • I did teach at least 1 debugging skill at the end of every lecture (often relevant to the topic)
      • Most students figure out std::cout on week 1 and use that anyway
    • Were my efforts a waste of time?
      • No -- students did use GDB or LLDB
      • No -- I was able to help them in office hours without ‘GDB’ being a mysterious or magical tool (They’d often ask -- ‘how did you do that again’ and try themselves).
      • No -- several students email me 6-8 months later while at their first C++ internship thanking me for teaching them GDB.

79

80 of 142

So...what skills will students learn (1/5)

  • Debugging (in theory)
    • Every lecture they’re exposed.
      • Some fully embrace it, some don’t, and that’s fine.
      • When the projects get larger, they’ll embrace debugging more.

80

81 of 142

So...what skills will students learn (2/5)

  • Debugging (in theory)
    • Every lecture they’re exposed.
      • Some fully embrace it, some don’t, and that’s fine.
      • When the projects get larger, they’ll embrace debugging more.

81

82 of 142

So...what skills will students learn (3/5)

  • Debugging (in theory)
    • Every lecture they’re exposed.
      • Some fully embrace it, some don’t, and that’s fine.
      • When the projects get larger, they’ll embrace debugging more.

82

And not just ‘discuss’, but actually practice!

83 of 142

So...what skills will students learn (4/5)

  • Debugging (in theory)
    • Every lecture they’re exposed.
      • Some fully embrace it, some don’t, and that’s fine.
      • When the projects get larger, they’ll embrace debugging more.
  • (next skill)

83

84 of 142

So...what skills will students learn (5/5)

  • Debugging (in theory)
    • Every lecture they’re exposed.
      • Some fully embrace it, some don’t, and that’s fine.
      • When the projects get larger, they’ll embrace debugging more.
  • The Standard Template Library
    • (why? Next slide)

84

85 of 142

Embracing the STL - Containers

  • I tell students C++ is a ‘batteries included’ language.
    • I tell students we have data structures available in a library--similar to the way Python has a built-in List and Dictionary data structures.
  • No need to implement these from scratch
    • That may be an interesting exercise, but for now I want students building software.
    • Again, in the real world (and from my experience), students will use libraries like the STL

85

86 of 142

Embracing the STL - Algorithms

  • Embracing the STL also gives me an advantage as a teacher!
  • I can also show students quick examples like this
    • “Here’s a collection of data, and we can sort it”
    • This makes C++ *so beautiful* as a language and not something so scary.
  • So students are exposed to both STL containers and STL Algorithms libraries

86

87 of 142

pssst -- and sometimes I show them in Godbolt!

  • I want them to learn how to ‘play’ and try out new things.
  • That it’s okay to prototype small snippets of code to learn
    • Pro tip: It’s also nice to save the compiler explorer snippets for students to quickly run

87

88 of 142

So...what skills will students learn (1/2)

  • Debugging (in theory)
    • Every lecture they’re exposed.
      • Some fully embrace it, some don’t, and that’s fine.
      • When the projects get larger, they’ll embrace debugging more.
  • Embrace the STL
    • C++ is a ‘batteries included’ language.
  • Play and Prototype with Code
    • Godbolt is an example tool that you can quickly prototype in

88

89 of 142

So...what skills will students learn (2/2)

  • Debugging (in theory)
    • Every lecture they’re exposed.
      • Some fully embrace it, some don’t, and that’s fine.
      • When the projects get larger, they’ll embrace debugging more.
  • Embrace the STL
    • C++ is a ‘batteries included’ language.
  • Play and Prototype with Code
    • Godbolt is an example tool that you can quickly prototype in
  • (Next Skill -- compiling and linking)

89

90 of 142

SFML Library - Compiling and Linking

  • A subtle bonus of doing a graphics themed course means we depend on an external graphics library
    • Students thus early on get experience with compiling and linking
      • Always starting on the command line
      • Then eventually they get a build script (and eventually make)

90

91 of 142

So...what skills will students learn (1/2)

  • Debugging (in theory)
    • Every lecture they’re exposed.
      • Some fully embrace it, some don’t, and that’s fine.
      • When the projects get larger, they’ll embrace debugging more.
  • Embrace the STL
    • C++ is a ‘batteries included’ language.
  • Play and Prototype with Code
    • Godbolt is an example tool that you can quickly prototype in
  • Compiling and Linking
    • Learn how to work in C++

91

92 of 142

So...what skills will students learn (2/2)

  • Debugging (in theory)
    • Every lecture they’re exposed.
      • Some fully embrace it, some don’t, and that’s fine.
      • When the projects get larger, they’ll embrace debugging more.
  • Embrace the STL
    • C++ is a ‘batteries included’ language.
  • Play and Prototype with Code
    • Godbolt is an example tool that you can quickly prototype in
  • Compiling and Linking
    • Learn how to work in C++
  • (next skill -- Modern constructs versus old constructs)

92

93 of 142

Modern C++ versus old constructs

  • So throughout this process, where do I stand on teaching C++11 and beyond (i.e. C++23) versus C++98
    • I still see universities teaching old school C++ courses.
  • The modern stuff is what makes the language more approachable in my opinion
    • Teach them C++20 <algorithm> using ranges
      • Show them lambda functions (explain the captures as needed)
    • Teach them new containers (e.g. string_view)
    • Show them how nice it is to use std::function
    • Show them smart pointers
  • BUT...

93

94 of 142

I do choose a few ‘old’ constructs first

  1. raw pointers before smart pointers
    • Students first need to understand that a pointer holds an address
      • Students need to experience the pitfalls of pointers first
      • Then, I can shift students mental model of a pointer, to think more about ‘ownership’ of memory.
    • ( Further justification: Students can’t avoid learning raw pointers forever, as they’ll eventually need to interface with C libraries)
  2. raw arrays before std::array
    • Same reason as above--a little too much abstraction.
      • Students are okay understanding raw 1D and 2D arrays
      • Much less abstraction in the debugger as well
        • (Initially easier to examine a 1D array)
      • Note: Students see std::vector well before they see a raw array however!

94

95 of 142

Summary - So...what skills will students learn

  1. Debugging (in theory)
    1. Every lecture they’re exposed.
      1. Some fully embrace it, some don’t, and that’s fine.
      2. When the projects get larger, they’ll embrace debugging more.
  2. Embrace the STL
    • C++ is a ‘batteries included’ language.
  3. Play and Prototype with Code
    • Godbolt is an example tool that you can quickly prototype in
  4. Compiling and Linking
    • Learn how to work in C++
  5. Modern C++
    • Teach the ‘new’ stuff--mostly

95

96 of 142

[Course Constructed]

Where do we start?

What will students build?

What skills will students learn?

96

So we know where to start, what to build, and the skills students should acquire. Let’s see the course

97 of 142

Course Modules

97

98 of 142

What is being taught

(The curriculum and assignments)

98

99 of 142

99

  • A quick tour of the C++ language showing some features of the language
  • Goal is to get students to be excited!

100 of 142

100

The first lecture is 100% inspired by CppCon 2015: Kate Gregory “Stop Teaching C" [in a C++ class]

101 of 142

101

  • Again, stolen from Kate Gregory -- I lean on the C++ STL.
    • I make the C++ language feel like a language ‘with batteries included’
    • Students coming from a Python/Java background are used to this.
    • Just give your students std::vector on day 2--explain arrays later.

102 of 142

102

  • Now we get into functions
    • Still no real graphical ‘output’ yet (coming soon!)
  • Students have to use ‘GDB’ if they want to inspect any values
    • I have them implement some math functions to do this
    • It’s neat to show students pass-by-value and copies being made with GDB. Also neat to simply show breakpoints on functions

103 of 142

103

  • Finally we can output and read in text
    • Students can also start working with files, to read/write data.
  • Just enough for them to do some their first real graphical exercise.

104 of 142

104

  • First real graphical assignment
    • An image to ascii image convertor.

105 of 142

105

  • Now we start learning a bit more about memory
    • Again, I’m teaching raw arrays and pointers here first.
  • Notice the GDB exercise on debugging.
    • Usually I’m targeting GDB exercises for where I think students will run into trouble.

106 of 142

106

  • I continue with more on memory allocation and memory layout
    • Starting to prepare students for 2D image processing tasks.
  • (Explicit GDB exercise not listed on outline anymore, it’s assumed)
    • GDB exercise examining arrays, and addresses of heap vs stack memory

107 of 142

107

  • Foundational ideas about creating new data types
  • Teach RAII emphasizing it’s “nice to clean up your memory/resources after you are finished with them”
  • Using GDB to observe callstack with constructors/destructors

108 of 142

108

  • More topics on building custom data types
  • At this point we’re diving a little more into the SFML library
    • Can actually show students some code in a library
    • Goal is to make reading others code and documentation less scary early on
  • GDB exercise finding copies of objects passed into functions

109 of 142

109

  • Students start doing some image processing examples

110 of 142

110

  • Students start focusing more on object oriented programming

  • Along the way implementing Fire

��

  • And the Falling Sands game for OOP experience

111 of 142

111

  • Students begin working on splines and eventually quad trees

112 of 142

112

  • Color Cycling and working with pallets
  • Assignment descriptions start allowing more more freedom in how task is achieved.

113 of 142

113

  • Revisiting old assignments using concurrency and asynchronous I/O
  • More tools on iterators and algorithms

114 of 142

114

  • Course starts to wrap up
  • Auxiliary topics that are of interest to students, what I think is important, and what will get students for next courses that use C++ (e.g. computer graphics)
    • This is where future assignments may get incorporated

115 of 142

So here’s a subset of what students end up with!

115

116 of 142

Summary so far

116

117 of 142

So far in this talk... (1/2)

  • I’ve tried to capture to you my process to course creation
    • How I try to provide a solid foundation for building a class
      • (From idea to implementation)
  • Some concrete examples of what skills my learners will develop
    • A subset of the assignments students learn from
      • (Several smaller assignments/in-class exercises not shown)

But there’s something missing, something very important, a key ingredient I believe to teaching...

117

118 of 142

So far in this talk... (2/2)

  • I’ve tried to capture to you my process to course creation
    • How I try to provide a solid foundation for building a class
      • (From idea to implementation)
  • Some concrete examples of what skills my learners will develop
    • A subset of the assignments students learn from
      • (Several smaller assignments/in-class exercises not shown)

But there’s something missing, something very important, a key ingredient I believe to teaching...

Maintaining the excitement and enthusiasm of your students!

118

119 of 142

Excitement!

119

120 of 142

Here’s was Last Pre-Course Survey Question I asked (1/2)

120

121 of 142

Here’s was Last Pre-Course Survey Question I asked (2/2)

121

122 of 142

Teaching Wisdom #1

  • I think this wisdom from some other great teachers is useful!
    • See the late Richard Feynman to the right ---------->

122

123 of 142

Teaching Wisdom #2

  • (Or if you’d prefer the words of a computer scientist)

123

124 of 142

Teaching Wisdom #3

  • You can’t fake passion and enthusiasm when teaching
    • That’s why I picked examples I was excited about (and you’ll have to replicate this for your own use case)
    • My honest enthusiasm helps keep my students excited when for 28 modules of C++ they see how excited I am getting.
      • My job is to teach C++ in a fun and encouraging way so students will pursue further self-study and courses in C++

124

125 of 142

A Few Teaching Notes as we Wrap Up

125

126 of 142

A Few Strategies for Teaching (1/2)

  1. First identify your audience
    • Is this for an undergraduate, a professor, a professional, or someone who has never programmed?
  2. Speak in plain terms
    • Explain as if a ten year old could understand.
      • I put Resource Acquisition is Initialization (RAII) every single time to avoid the additional cognitive load it takes for students to avoid jargon.
    • Then, progressive discuss a topic deeper eventually hitting your target audiences skill level
    • Note; If you use metaphors or analogies to the real world, think globally (e.g. ask yourself if everyone will understand an American Football references?)

126

127 of 142

A Few Strategies for Teaching (2/2)

  • Tell a Story
    • This is the part that will make folks care
    • Why are they learning this subject matter? Why does it matter? Can you motivate with history? Can you motivate to students in another way?
  • Identify your own knowledge gaps, and keep refining
    • Sometimes your own knowledge gaps will be points you’ll want to take note of--probably a good idea to break down those gaps into smaller pieces (for yourself and your student)

127

128 of 142

A Few Strategies for Teaching (3/3)

  • Anyone hate how many words I put on my slides? :)
  • I stand by breaking that powerpoint rule
    • Students want to review the slides later on and not guess what I was trying to say.
    • (Note: You do need to have thoughtful transitions to guide a student in your slides however!)

128

https://medium.com/taking-note/learning-from-the-feynman-technique-5373014ad230 More ideas on teaching and ‘the Feynman Technique’

129 of 142

Live Coding

  • Delivery -- I do live coding about 40% of the time in my class
    • In my personal University experience as a student this was very rare.
    • At my current University many instructors spend a portion of class doing this or sharing recordings.
      • I think this is a good thing
      • I keep my mistakes in my lectures or lecture videos for others to learn from
      • It also gives students a chance to ask ‘what if we change this’

129

130 of 142

Couple more ground rules when you’re teaching students

  • Students want to know you’re competent (i.e. the expert)
  • Students do want you to be organized
  • Students do want to feel supported.
  • Students are not impressed by technical jargon
  • Students should not be given ‘the language standard’
    • It’s find to point them to the core guidelines later on--some students just like to know a more definitive answer.
    • But I would not teach directly ‘from the guidelines text’, teach instead from the inspiring projets you want them to learn from.

130

131 of 142

What is Next?

(Next iteration of the course)

131

132 of 142

What’s next

  • Next iteration of course will be supported by lots of supplemental youtube videos
    • *Key word* ‘supplemental.
      • Not required for students to watch, not even encouraged, but there as a definitive resource so students don’t have to hunt.
      • Overloading students on resources (especially video) can be detrimental -- especially during pandemic.
  • 1 or 2 new assignments
    • Rotating in new assignments that did not make the cut.
    • A 14 week semester versus Summer half semesters allow students to soak in material at a more reasonable pace.
      • (Remember, don’t keep adding content if students can’t absorb the current contents!)

132

133 of 142

Things I want more of in the next iteration

  • Reading more good (by my standard) C++ code
    • From my own samples, or C++ open source projects)
    • I will have to think carefully about this though--honestly this may belong in a follow up course (e.g. I teach a software engineering course in C++)

133

134 of 142

For Non-Academics | How would I compress this into a one or two day workshop?

  • Pick one or two of these topics
    • image processing is likely one that scales well from beginner to advanced.
    • A small game may also be more appropriate to show higher level thinking when writing code and selecting C++ features.
  • I’m actively thinking about this for a next workshop as we speak!

134

135 of 142

Final Check

135

136 of 142

Final Check on our Homework

  • Did I tell my students C++ was scary or hard anywhere?
    • (A quick search with ctrl+F tells me I did not)

136

137 of 142

Final Check on our Homework

  • Did I tell my students C++ was scary or hard anywhere?
    • (A quick search with ctrl+F tells me I did not)

137

138 of 142

Post Class Survey

138

139 of 142

Post Class Survey

139

140 of 142

140

Thank you for listening to my talk!

April 7, 2022 | 14:00 - 15:30

Mike Shah, Ph.D. | @MichaelShah

www.youtube.com/c/MikeShahwww.mshah.io

141 of 142

141

142 of 142

Rough Outline

  • Why we need to think about teaching C++ to beginner programmers
  • My Key Philosophies in Teaching C++
    • C++ is not the C Language
    • Pick a motivating domain (e.g., 2D graphics)
    • Every lecture ends with a debugging example
    • Unveil the details--slowly (i.e., don't pretend it's all magic)
      • It’s easy as a teacher to get excited about the super advanced parts--slow down. Opt for 20% less material if it means students will retain more.
  • University Student background
    • Semester long course for a range of student abilities
  • How I Build a Course/Training Material
    • Start with the Assignments
    • What Assignments do I use?
      • Overview of the 9 Assignments
        • What are students supposed to learn
      • What tooling is used and what tools do students use
        • What c++ tools are students learning.
    • How do I teach modern constructs versus old constructs
      • raw pointers versus smart pointers
      • function pointers versus std::function
      • (maybe other topics of allowed (e.g., modules)
  • Conclusions
    • Feedback from students
    • How to compress this course into a day workshop

142