10. Why a
workshop?
Programming has lots of complex
aspects
We want to be proficient at as many
aspects as possible
This can be achieved via practice and
discussion
A workshop is not completely freeform,
there are particular learning outcomes
in the workshop, I will guide/facilitate
your learning
11. How to get the most out of this
If I am vague, omitting detail, using unfamiliar terms, or you feel lost
Tell me
I can refine my explanation
We can diverge onto other necessary topic
If you disagree
Tell me
Could be a misunderstanding
It may be different trade-offs or priorities
I may be wrong
12. “This stuff is obvious”
It may be
Lets communicate (we can’t read minds)
Opportunity to share extra detail
Knowing something and articulating something are very different
Improve communication skill
Refine your understanding
Don’t ruin it for others
“Its not obvious to me”
Nothing to be ashamed of
Develop your understanding
This is a safe space
Through mistakes, we learn and gain new understanding
14. A simple code exercise
If it was too complex
not everyone could do it
the lessons learned may be hidden by the complexity
This is literally an interview question I found on the internet
we don’t care about if you can solve the puzzle
as a group we will all have the solution in less than a few minutes (I will tell you)
we are just using the exercise as coding practice
18. STL (July 1994)
Alexander Stepanov
Massive influence on the STL
“primary designer and
implementer of the C++
Standard Template Library”
Philosophy based on:
Mathematics
Category theory (regular types)
Performance (zero cost
abstraction)
19. Iterators
Controls
Access to item
Traversal to next item
Access and traversal are decoupled
Iterator pointing somewhere nonsense is fine, just don’t
access it
Access and traversal can be to whatever the iterator
wants
Transform iterator?
Filter iterator?
21. Iterators decouple
containers from algorithms
Generic programming
{vector, list, array, deque, string} x {find, copy, partition, nth_element}
9 implementations
20 combinations
Works because iterators are a customization point
Controlling access and traversal
All problems in computer science can be solved
by another level of indirection -- David Wheeler
22. Clickbait?
How do things with C#’s List?
x.Reverse(), x.Sort()
Just there “dot thing…”
How do things with Java’s ArrayList?
Collections.reverse(x), Collections.sort(x)
Elsewhere, but you can still apply it to a collection
How do things with C++ std::vector?
std::reverse(x.begin(), x.end()), std::sort(x.begin(), x.end())
Elsewhere, but done via iterators, and C++ iterators are not the same as C#/Java
24. https://godbolt.org/z/DzKkMz
Readability
STL algorithms/methods
find, reverse, next
Variable names
Variable scope
Small dedicated loops
Const variables
No exceptions
No error cases
No allocation
Not optimizing for the
unexpected case