Today: Last lecture, your future in CS, conclusions
Thanks To Ngoc and Iddah and Section Leaders
Thanks to Ngoc and Iddah and the section leaders! The only way this course can work is with their prodigious and generous efforts. The staff, working in the "CS198" program, are selected for technical skill and teaching generosity - a fantastic group of people and we are lucky to have them.
Final Exam
- Mon morning 9:30-11:30 am (arrive early)
- See course page for detail, including seat sign-up and rules for the final exam room
- Similar structure to midterm
More time and more questions
Enough time to write code, not extra time
- Covers the whole quarter, weighted towards post-midterm
- Improved final exam score can compensate for a poor midterm score
- Every exam as a range of medium to hard problems
- Exam problems look like homework functions
- Not on final exam:
Bit
Writing main()
JSON and calling AI
- See course page for review materials: final-prep, previous exams
Previous exams are a great source of practice problems
- Section this week - work some review problems
Python Guide
I'm gradually working on and expanding the Python Guide, aiming to keep it as a free resource on the web. If you want to find it in the future, it's linked from my home page and the CS106A page.
What is the Role of CS106A?
- CS106A is not about browbeating people into liking CS!
- CS106A should lay out CS honestly
See the nature of code
See how to solve this problem
- Many Stanford students take one or two CS courses, and that's it
- We're glad you made it this far, and you'll have to decide how far to go
CS106A First Day Claims vs. Today
- Things said on the first day you now know
- The computer just follows mechanical instructions
- There will be bugs
- Yet the results can be magic (under the programmers direction)
- We've done this so much, you know it in your bones
You will never not know this nature of the computer. Even if you never write another line of code.
The natural rest state of code is "broken". And yet you work on it iteratively a few times, and then suddenly it works, and there's that feeling of accomplishment.
Learned All The Programming Techniques?
Sadly, no.
Learned the Important Core
Here is the deal: Python and the space of all programming techniques is very large. A bigger space than you might think. The "Programming Python" book is over 1600 pages long. Fortunately, many of these features are for rare cases, you do not need to know them to get things done.
You have learned the most important 80% core: loops, lists, strings, functions, tests, files. There's a few more important techniques in CS106B, in particular, recursion.
In some AI-aided world, you will need to know these code fundamentals to work with the AI, so CS106A has set you up with those basics.
Building on these core concepts, you know enough to read about (or work with the AI), to solve more difficult problems.
AI and the Future of Programming
I talk about programmer shortage first, and then AI coming on the scene.
Historic Programmer Shortage 1990-2026
- There has been a longtime shortage of computer programmers
- Being at Stanford .. causes you to overestimate the number of programmers
- AI raises questions about this (next section)
- What percentage in the US work as programmers?
- Approximately 1% of the population work formally as programmers
Formal "programmer" jobs in the US statistics
There are additional programmer-adjacent jobs, but still a tiny number
- For comparison approximately 12% of population works in health care
- Lots of programming problems are not being solved due to lack of programmers
- In other words, there is a programmer shortage
Very high pay for programmers is another bit of evidence of the shortage
- You may notice this someday, trying to get an app built for your organization
- Not that we need to make any Stanford student's head any bigger...
- But by these numbers, knowing Python makes you a little special
Why is there a Programmer Shortage?
- Coding seems impossible, intimidating
- People are scared off before trying, weird syntax
- Don't see themselves as programmers, lack of role models
- Maybe they tried it and just don't like it! ("agency")
Nick Python T-Shirt Story
I was on a bicycle, wearing ratty clothes and a "Python" t-shirt stopped for a red light. A person walking in the cross-walk in front of me, stopped, turned to me, and asked if I was looking for work.
Not to disillusion you about graduating from Stanford, but that is not how hiring is normally done.
Like how desperate for programmers was that person? That is what an extreme programmer shortage looks like!
Free Breakfast Story
When I worked at Google, there was a nice free breakfast available at the office. The free breakfast would end at 10am. The funny part is that some people would complain .. the free breakfast cuts off too early, how am I supposed to get here by 10am?
What does this story tell you? That google cares about the morning nutrition of its team? Or that google is spending money on entitled nerds in the face of a desperate programmer shortage.
I suppose the other lesson is that it is human nature to grow accustomed to whatever blessings one has in life, and then risk seeing them as entitlements.
Let's talk about AI and programming, and the range of how it might work in the future.
Preface: AI Land Grab
Why is there so much hype and spending by companies to get into AI? I think there is a rush-to-occupy-new-land mentality, as by getting there first, they can dominate the space for the future. This suggests spending huge sums to be first. It is a valuable new space, but I'm skeptical that these vast sums will pay off.
Preface: Much Code is Formulaic
Much computer code is formulaic, resembling code that has been written before. Also running code often has tangible outputs, so this all makes code a suitable area for AI. Contrast to, say, writing a movie script. How does the AI know if the script is good? The domain is muddy and difficult.
Hybrid - Programmer Working With AI
Think about a human programmer working with an AI to solve problems more quickly.
1. AI Autocomplete - 2x
The AI could work as a fancy autocomplete, proposing and finishing work as the programmer works on each section of code. This works today, so this is the lowest estimate of speedup.
2. AI / Programmer Interactive Dialogue - 10x
Suppose the programmer suggests the problem space, then the AI suggests an outline of the code strategy. The programmer provides feedback suggestions. The AI write some code. The programmer surveys the code and provides nudges and corrections. The two go back and forth. If the AI is writing nearly all the code, this could be dramatically faster than the programmer writing all the code. The programmer is providing advice and corrections, but not looking at all the code lines in detail. We'll call this "10x" faster, more to give it a name than make an exact numeric prediction. AI systems today are approaching this level, but still making mistakes that require human oversight, looking at the code.
3. AI Maximalist - e.g. AI iPhone app
The maximum AI story is one where the programmer really does not need to look at the AI produced code. The defect rate in the code is so low, we just trust it. (This is not how things work today, but maybe someday.)
Suppose in his model a programmer wants an iPhone app, describing the app to the AI. The AI produces a prototype app, and the programmer runs it to see how it works. The programmer provides feedback about desired changes, and the AI does another version, and so on.
The role here of the "programmer" is as a source of "taste" and user needs, not the code. This is akin to a Hollywood director giving feedback to the actors and camera operators. The director does not run the camera, but is nudging the process with their high level vision of what they want for the final product.
Story: Less Demand for Programmers
It's possible that AI code writing will reduce demand for programmers. Programmer wages have been elevated for years, so the wages could come down. Society could still function fine without CS being more highly paid than other professions. Data point: the Stanford 2025 CS graduates got jobs, although anecdotally they had to work harder to get them.
Counter: AI Screwups
It's well known that AI models can make real mistakes. There are stories of the AI code including some big screwup - here is a recent Amazon example, but there is nothing Amazon specific about this pattern.
If a programmer needs to look at all the lines of code, the speedup will be limited. On the other hand, I expect the AI will gradually get better at avoiding screwups.
Counter: Jevon's Paradox
Jevon's Paradox. The AI is making the production of software cheaper. A well known effect of this is to increase the amount of software. So in effect, they increased productivity may be absorbed by making a greater volume of software.
Counter: Accountants vs. Spreadsheets
At one time, accounts did a lot of arithmetic, literally adding and balancing sums. With spreadsheets and software, computers now do the arithmetic .. and yet accountants still exist. Now accountants work on higher-level concepts of strategy and legal compliance. Like a computer system, their work is "on top of" the basic math done by the computer.
However, sometimes a job is truly automated away. There used to be lamplighters to light and manage flame lamps outside. But electric lighting has certainly caused that job to vanish. (See also: whale hunting).
Aside: the history of artificial light from prehistory to today is a neat example of the development and economics of technology over time. See: History of Illumination (20 minute podcast), and the book "Brilliant" by Jane Brox (amazon link)
Computers are Valuable
Nobody knows how this will work out. My gut is that computers are a very valuable technology, and so jobs working with computers in some way or another will continue to be numerous and important. That said, this is clearly a time of high variability, so we'll have to see how things work out.
Editorial - Choosing a Major
Think about choosing a major - Nick's hand-wavy editorial
- Choose a major where you feel an affinity to the topic, and the skills around it
- e.g. English Major - you should like the art of the written word, and the task of writing
Being skilled and practiced is generally useful, not because we're aiming for some English-major specific job
- You may well work post-college in a field that is not directly your major
- Thought experiment - your 10 year college reunion - many people will have switched to some unexpected field
A quirk of what jobs were available, shaped by their personal interests
- High school planning illusion
The high-school to Stanford pipeline involves a lot of planned steps
However post-college life has un-planned discoveries of interests and opportunities
Instead of knowing the future, you will be open to discover the steps as they appear
Background: Many Computer Languages
- There are many different computer languages
Python, C++, Javascript, Java, C, Rust
- Each language is good at different things
Python Niche - Programmer Efficient
- Python is great at letting the programmer express their ideas with minimal code
- At what cost?
- Python runs slow and uses more memory than code in other languages
- In some sense, shifting costs from the programmer to the computer
- That's a great tradeoff in many situations!
Code Ideas We've Seen in Python
- Code ideas we've seen in Python
- Storing data
ints, floats, strings, lists, dicts
- Language features:
functions, parameters, strings, loops, if-logic, lists, dicts
- Good programming style:
Divide and conquer, decomposition
Testing functions
Readability
Your Second Programming Language
- Your second computer language
C++ or Javascript or Java or whatever..
- Has those some features:
ints, loops, strings, if-statements, ..
- Computer languages are 80% similar to each other
- Different syntax - superficial
- Your second language is surprisingly easy to learn
(you may be skeptical)
- Python has a "light" syntax
other languages have more to type in
- C++ (CS106B)
Here is some C++ code
// comments start with 2 slashes
int i = 0; // declare var + type
while (i < 100) { // parens + braces
i += 1; // same as py + semicolon
if (is_bad(i)) { // parens + braces
return;
}
i += "Hello"; // error detected
// int/string types different,
// so above does not work.
// Error is flagged at edit-time:
// earlier than python, an improvement
}
- C++ code looks different
- Actually 80% familiar
- Picking up C++ will not be a big problem
- Advantage of heavier syntax: more automatic error detection
- Also C++ runs much faster than Python
- Disadvantage: more to type in
- Fun fact: the Python interpreter is itself written in the language C, related to C++
Possible Next Steps
Most Stanford students take 1 or 2 CS classes and keep with their chosen major. It's easy to imagine they use Python here and there as part of their work.
After CS106A ..
- Interested in more coding techniques and CS .. take CS106B
See how far you like going
- Hidden agenda:
Many students coming to Stanford don't see themselves in CS
CS106A tries to pick off a few was-not-planning-to-like-CS students
Next "CS106" CS106B
- The next step in CS - mixture of coding and CS
- Coding problems are harder and more impressive compared to 106A
- Has section leaders
- Many non-CS-majors take this
- More powerful algorithms
- Uses C++ language - don't worry about this
- Recursion (beautiful) .. e.g. solving a maze
A sort of jaw-dropping idea when you get it
- Really understand: hash table (dict), sorting algorithms
- Just more programs built - makes you a stronger programmer and debugger (reps)
- Recommend you take it within 1 or 2 quarters
Aside: Selecting A Major
Selecting a major, it's nice if you enjoy the sort of work that is a big part of that major.
CS106B plays this role a bit for CS.
How do you feel, finishing each CS106B project. There are many ways to pick a major. One angle is - you should enjoy the main topics that make up a major.
Think About Section Leading
- Few schools have this opportunity
- Section Leader program - amazing thing at Stanford
- Section leaders are drawn from students who have completed CS106B
Don't need to be a CS major
- Section leaders - not for everyone
like code, like helping people
- Open secret: SLs pick up fantastic skills
debugging, organizing ideas, public speaking, confidence
CS Major - Code and Math Tracks
CS has programming, as you would expect. There is also a parallel CS-math track, feature integer mathematics, proofs, and reasoning with probability distributions.
CS Major - Parallel Tracks
Programming Math
CS106A CS103
CS106B CS109
CS107 CS161
CS111
Next Course FAQ
- Programming courses tend to take in order
CS106B, CS107, CS111
- CS106B and CS103
You can take these at the same time, but they are hard
Don't take another hard class at the same time though
- CS103 and CS109
CS103 is basic integer mathematics
CS109 is more probabilistic structures
CS109 prerequisite is either CS103 or Math 51, so can take CS109 without CS103 if you like
- Nick editorial vs. 19 units
Every student is different and selects their own college strategy
Some students take 19 units, but they struggle to do a high quality job on all their courses. IMHO not the best strategy.
Alternative: student taking 15 units, but they are very on top of their courses
Aside: What is CS Integer Mathematics?
- CS Integer mathematics (vs. calculus real-number)
int div and mod (// %)
- Hash Table (dict) - how is this so fast?
- Not so much: integrals, differential equations
- Calculus is not the ceiling, it's a branch
- Integer mathematics is its own domain
- Relates to list/string algorithms we've done
- Personal take:
I was tired of Calculus, but integer mathematics seemed neat and applied
- CS106B goes down the path of integer mathematics a little
CS Major Tracks / Concentrations
- If interested in majoring in CS
- Don't have to pick an area at first
- Undergraduate CS concentration areas:
Artificial Intelligence (AI)
Human Computer Interaction (HCI)
Systems (operating systems, networks)
Graphics
Biocomputation
Theory
- Choose a concentration, take advanced courses in that area
- HCI - call this one out, since most don't realize this field exists (below)
- CS Minor is a good deal
Up through CS107 and CS109 + 2 electives
This gives a strong CS background
Double major at Stanford is often infeasible
The minor may be the better alternative
Some Select Courses
We'll just mention a few courses you could take, build the picture that there are many different areas of CS you might explore. Many of these require CS106B as the pre-requisite.
Scientific Python CME 193
- Python and scientific computing
- Prereq: CS106A basically
- 1 unit s/nc
- Applied Python (vs. CS fundamentals)
- See CME193
Applied Machine Learning CS129
- Machine Learning is the cutting edge AI technique
Drawing conclusions from data
- Prereq: CS106B, linear algebra / Math 51
- See CS129
Human Computer Interaction (HCI) CS147
- How to design systems to work well with humans
- Details below about HCI
- Prereq: CS106B
- See CS147 intro HCI
Graphics CS148
- 3d imagery
- Prereq: CS107, Math 51
- How does Mario Cart work?
- See CS148
Human Computer Interaction - HCI Design
- What if you don't want to write code all the time?
- An unexpected part of CS
- Human Computer Interaction Design
- Anyone working in management in a computer field should take this course
- You can do an undergrad or grad emphasis in HCI
- More info: CS147 intro HCI
- aka "interaction design" - product manager, designer
- Demo Image search: push pull handle HCI
- Door Push-Pull Handle
- The appearance communicates to the subconscious
- Great design works without the user thinking!
(analogy: film making to create an emotion in the audience)
- Mostly we notice HCI in the world when it is done badly
You click a control, and are surprised by what happens
- Nick's Open Question: what is the greater drag on human potential on Earth:
Missing software, not coded up yet (CS106B)
Software with bad HCI design (CS147)
Handle examples - the point here, is that the object communicates its function visually, and this connects to some low-level part of the brain, so you just know intuitively how to operate it. The best interfaces work this way, and the language of it is visual, not words.
This last one is wrong. It's a push door, but they have put a "pull" handle on it, so people keep using it the wrong way. Putting the "push" sign on their is not the right solution.
Symbolic Systems Major
A sibling to the CS major - similar intellectual domains but less focus on coding
An interdisciplinary major that uses the lenses of CS, Philosophy, Psychology and Linguistics to study systems that use symbols to represent information. In Symsys you can concentrate on AI, Neuroscience, Natural Language, Philosophical Foundations or design your own concentration.
Self-Driving Cars - Machine Learning
- Used to be research, getting close to just working
- A vision / radar problem - see all the possible collisions
- Machine Learning to try to recognize the things around the car
Needs to work for 100% of Cases
Part of getting code to work is that you need to chase down those rare, difficult cases as well.
Below is a difficult case for the self-driving logic, although all the people in the audience understands what they are seeing easily.
Where is the Magic in CS?
- The computer seems magic
- Such neat output
- But where is the magic?
Where is the Insight? The Power?
Where is the power in this story?
- You are the power in this story
- You have an insight about a problem to solve in the world
- Your idea makes the algorithm
- Python is just your instrument
- The computer solves a real problem, driven by your idea
- This is great story
Fare Well Python Programmers!
In closing, I'll say that teaching this class is very satisfying endeavor - it's great to see the light in someone's eyes when the power we know in CS starts working for that student.
Best of luck with your future projects!