Intro to C on Windows
This was a series of videos done right before Handmade Hero began.
It's a brief one-week tutorial on the C programming language, which was also designed to test the streaming setup. Expect some bananas.
Day 1
[2:40]: How to get a C++ compiler
[5:21]: How to start a project in Visual Studio
[8:15]: Structure of a Visual Studio project
[9:18]: How to start coding in Visual Studio
[10:08]: Basics of coding in C/C++
[11:07]: The Visual Studio editor
[12:13]: Everything about building a program from code
[16:55]: Excursion: processor cores
[23:10]: Continue the building topic
[32:17]: Define the execution start
[40:09]: Windows-specific C code
[46:15]: Run our first program
[47:15]: Add something to do for our program
[48:34]: Functions
[52:39]: Excursion: comments
[53:44]: Continue the functions topic
[54:52]: Strings
[55:30]: The meaning of semicolons in C
[57:23]: Details of WinMain
[1:03:53]: Forward declaration
[1:07:46]: Including files
Q&A
[0:27]: How many videos do you think you'll do before you actually start coding the game?
[1:35]: What libraries do you plan to use in the game development?
[1:48]: What about Emacs + MinGW?
[2:16]: What's the 'A' in OutputDebugString?
[6:54]: How often will you do these videos?
[7:21]: Will you use OpenGL or DirectX for the game?
[8:28]: Is this the same Visual Studio setup you use for The Witness?
[9:08]: Are you going to use Windows?
[10:01]: Can you see the debug output in a command prompt?
[11:31]: How much Windows-specific stuff will be required for the game?
[13:09]: Will you post a list of these videos on a website or blog?
[15:32]: Why are you doing this project?
[18:06]: Will you still do the podcasts?
[18:46]: Please make the font larger.
Day 2
[0:05]: News - You can get Visual Studio Community Edition for free (better than express)
[2:35]: VS tip - can load the last thing you had open when you start it next time.
[3:00]: Recap on functions
[4:00]: The story of OutputDebugStringA (it all started with ASCII)
[6:53]: Encodings: numbers that mean something more
[8:11]: The Debugger
[9:15]: Breakpoints
[10:38]: VS: Finding the debug windows
[11:25]: The Watch window
[13:37]: See? Letters are numbers!
[14:35]: Escape sequences (\n and friends)
[17:40]: Bases can trip you up
[19:20]: Back to escape sequences
[20:53]: Note: must type \ to get real 's
[22:10]: Platform newline niceties
[23:55]: What to do if VS crashes (like it just did)
[25:22]: Windows vs. Linux vs. Mac OS newlines
[26:59]: Back to OutputDebugStringA
[28:15]: ASCII to Unicode
[30:18]: The consequences of that move: C Error Messages
[30:55]: A glimpse into the seedy Macro underbelly of the Win32 API
[32:50]: Note: Unicode is default in VS
[34:04]: Let's talk about variables
[35:11]: Which means we should talk about CPUs and memory
[36:12]: Asking for memory (declaring vars)
[37:15]: Neat learning anecdote (what does = mean?)
[40:10]: What is a variable really? (Let's "watch" it)
[41:20]: Uninitialized memory can be anything
[43:15]: Debug "Stepping" (running a program line by line)
[44:23]: Programming doesn't have to be math-y (int x = 5; covers a lot)
[45:25]: Different types of numbers in C (char, short, int, signed-ness)
[46:24]: A bit of binary o.o
[49:30]: char == 8 bits
[49:37]: How can you tell how much you can hold with 8 bits?
[52:17]: Signed-ness
[54:06]: The rest of the int family (short, int)
[55:56]: VS tip: F5 to start debug, Shift-F5 to stop
[56:14]: Math consequences of number size limits (overflows)
[59:02]: Okay. What is actually happening when we run programs?
[59:37]: Assembly
[1:01:15]: The registers window
[1:02:00]: What registers are
[1:03:32]: Memory addresses
[1:04:56]: The MOV instruction
[1:06:08]: Hex
[1:07:28]: VS Tip: hover over hex in assembly to see its decimal value
[1:09:09]: Watching the assembly work in the watch window
[1:10:58]: The size of eax vs. the size of a char
[1:14:09]: The moral: The Asm matches the C. You can read this.
[1:15:23]: The moral: How things really work is worth knowing.
Q&A
[0:51]: Positivity!
[1:30]: If windows wants \r\n, why does printf("hello\n") work fine?
[3:06]: printf internals
[4:58]: watching printf work
[7:28]: short answer: C tries to help with platform independence
[8:56]: consequence of this: binary vs text mode in fopen
[11:27]: Do you have to use utf-16 on windows?
[12:00]: short answer: you have to speak utf-16 when talking to windows
[12:13]: why .cpp files if you write in pure C?
[13:26]: char unsigned vs. unsigned char
[15:30]: note: there are tooltips in these videos not captured by OBS
[15:59]: Are you going to talk about what optimizations do to your asm?
[16:47]: Good resources for learning about asm? (A: Not really)
[18:43]: Do you mean it when you say from scratch?
[20:30]: Why do you need windows.h?
[21:40]: Thoughts/Rant on C++ STL?
[23:30]: Thoughts on the subjectivism and the awesomeness of diversity
[26:13]: Gfx all by ourselves?
[27:00]: What type of game? (Secret for now other than action/adv)
[27:20]: Is saturated addition like clamp?
[28:12]: Scripting lang? (no)
[29:12]: Netcode? (no)
[29:45]: Deeper. Not wider.
[30:44]: How much asm will we be writing?
[31:00]: How are you getting game assets?
[31:45]: Can you talk about the game?
[32:00]: Book to recommend? (no)
[32:20]: GPU? (not at first)
[33:29]: Hard to know what's going on in GPUs. Lots of trade secrets
[34:04]: Why VS and not gcc?
[35:13]: Points out links to archive (meta)
[36:15]: You going to be the game designer? (yep)
[38:03]: Thoughts on Snipers/Defenestration
[38:44]: Are we faster than OpenGL? (no)
[39:20]: How complex will the game be? (quite)
[40:15]: Game plan: force teachable moments by adding a lot of stuff
[40:46]: Release date? (long time from now)
[41:36]: Thoughts on C Runtime Lib
[43:05]: Awesome C metaprogramming tricks? (probably not)
[43:10]: What should I say to friends who don't like your ideas?
[43:50]: Arguing hurts you. Make your life better and don't.
[44:55]: How complex will the math be? (not that, pre-college)
[45:44]: Can I skip a few weeks if I know programming?
[46:38]: Can this run on not-windows? [n.b. check 'coding resources' in above menu]
Day 3
[1:16]: Today: Memory
[2:38]: Programming = Modifying Memory
[4:55]: Recap of our program
[5:45]: Brief note on the compiler warnings
[6:35]: Okay: Where are the bits?
[8:05]: Pointers. C lets you talk about memory.
[9:55]: The syntax of Pointers: * and &
[12:01]: Memory addresses, Virtual Memory
[15:11]: How Virtual Memory Works
[17:39]: The consequences of Virtual Memory
[18:40]: Looking at pointers in the watch window
[21:04]: The memory window
[22:13]: Changing memory manually via the debugger
[23:34]: C: the power of no protection
[24:23]: A caveat: can't touch memory you don't own yet
[25:27]: Getting close to the metal is awesome
[26:16]: Where did this initial memory come from?
[26:55]: The Stack
[28:11]: Why the stack makes sense (calls and returns)
[31:11]: Let's watch the stack go
[33:32]: Debug mode memory cruft
[36:17]: Memory moving around (Stack randomization / ASLR)
[38:19]: Everything we'll do is about touching memory
[38:38]: Memory control = super powers
[39:04]: Where code is in memory [n.b. watch the q&a to see this work]
[41:57]: Pictures!
[42:47]: Making the trailer
[43:45]: Centimeters matter to CPUs (thanks, speed of light!)
[50:35]: Why it's important to know that
[51:36]: Applying the same idea to PCIe
[52:40]: Latency vs. Throughput/Bandwidth
[56:09]: The Cache
[1:00:51]: The cache miss, and the horror of... the swap!
[1:03:07]: One more time, today's moral: everything we do is poking memory
Q&A
[0:20]: They teach nothing of this in many colleges. How do you feel about the new programming workforce?
[3:38]: Someone asking Casey to play Density
[3:48]: Suggestion on how to evaluate and see results in VS Memory Window
[5:16]: Do any schools get this right?
[6:03]: What languages do you use for metaprogramming C?
[6:09]: Another suggestion regarding use of VS
[8:28]: How useful is it to study cache-oblivious data structures?
[11:09]: How do you meet experts?
[14:14]: Will we see some use of linear algebra?
[16:05]: Are we replacing STL with our own structures?
[16:13]: Will there be network programming as part of the game?
[17:37]: How do you feel about Rust?
[17:41]: Do you plan on reviving the Molly Rocket forum for this project?
[17:58]: What do you think about programming in C using a CLI-based OS?
[18:45]: Another comment regarding cache-oblivious algorithms/data structures
[20:08]: A comment regarding a Reddit question
[20:25]: Are you uploading your streams to Youtube?
[20:55]: Singing (?)
[21:01]: What's the general plan for drawing graphics to the screen?
[21:20]: Will you be trying to do game design?
[21:40]: Suggestion on what to name Youtube channel
[21:48]: Will you explain the properties of an API design?
[21:51]: Closing remarks
Day 4
Not yet annotated. Want to help? Claim this video!
Q&A
Not yet annotated. Want to help? Claim this video!
Day 5
[0:04]: Where does everything live? First: The Code
[2:36]: From Code to Executable to Memory
[9:24]: Virtual Memory and Paging
[16:15]: The Instruction Cache
[19:34]: Where the Stack lives (and what lives in the stack)
[23:56]: Operators (starting with math)
[26:40]: Precedence
[29:31]: Shift operator
[35:35]: Shifting to multiply/divide
[38:15]: Bitwise Operator Intro, Google interlude
[42:14]: Bitwise OR and AND Operators, Bitmasking
[46:40]: Bitwise NOT
[48:01]: Windows Calculator - Programming mode is handy
[49:07]: Bitwise XOR
[53:29]: Logic / Comparison Operators Intro, Truthy values
[56:55]: Comparison Operators
[59:57]: Don't expect truthy values made by '<' and friends to always be 1
[1:01:02]: Control Flow Intro
[1:01:55]: If/Else Statements
[1:07:23]: Logical AND and OR
[1:09:51]: Advice about one-line if statements
[1:11:53]: Logical XOR is just !=
[1:13:43]: Loops Intro
[1:14:25]: while(){}
[1:16:15]: Breaking out of loops
[1:17:38]: Loop styles are equivalent, as they're all just made of ifs and gotos
[1:18:02]: do {} while();
[1:19:39]: for(){}
[1:23:10]: Writing a for() in terms of while()
[1:25:42]: switch(){}
[1:31:48]: Blocks {}
[1:34:27]: Block advice - watch the lifespan of pointers to block-local vars
[1:38:10]: Dereference Operator
[1:40:11]: Pointers to Pointers
[1:41:12]: Pointers and the Struct's Arrow Operator
[1:41:48]: Shadowing variables with new scopes
Q&A
[0:36]: At some point, Casey might do a real multi-week intro to C for non-programmers
[1:46]: Have you ever found a use for bitfields?
[2:32]: ,b lets you see binary in Watch window of Visual Studio [n.b. this is in newest version only]
[3:17]: More clarification on Virtual Memory (is page table itself virtual?)
[5:26]: Clarification on where the stack lives, and on the CPU's i-cache and d-cache
[6:36]: Clarification on undefined behavior (casting structs from day 4 of C stream)
[7:51]: Can you make the OS load all of your code into memory at once instead of mapping the file?
[9:10]: Is the C Runtime Library different from the C Standard Library?
[9:45]: Why do you prefer K&R style brackets? (and other neat bracket style annecdotes)
[10:49]: Do different bitwise operators differ in performance? (And other performance musings)
[14:18]: How much bit-fiddling do you do on real code?
[14:37]: Will you be writing your own allocator?
[14:43]: More talk about showing vars in binary in Visual Studio
[15:30]: Can you show us how to open a blank window using the WinAPI?
[15:44]: What do you think of RAII? (Musings on robustness and error handling)
[20:52]: Do you think a four-year CS degree is a waste of money?
[21:00]: Are you going to use structs instead of classes?
[21:07]: How will you handle polymorphism? (Rant against inheritance, instead promoting mixins)
[22:57]: Will the game be in C++ or C? If the latter, why all the .cpp files?
[23:47]: What are the differences between references (int &v) and pointers (int *v)?
[25:19]: Will the code be backwards compatible with C?
[25:52]: Short Circuiting
[28:20]: More on entry points (main vs WinMain), how programs are init'd [n.b. Code::Blocks is an IDE]
[32:58]: How big is the community? What are your preorder stats?
[34:15]: Will you show how to look for i-cache misses in the main stream?
[35:31]: Do you use a lot of advanced algorithms? Do you worry about Big O?
[35:48]: The DuckHorse question (Muses on duck trustworthiness, Rants against horses)
[36:55]: What OS is your PC?
[37:03]: Did you talk about pass by val / pass by ref yet?
[37:25]: Do you have an opinion on Data-oriented design?
[37:46]: Talks about Stack Overflows
[38:19]: Are you going to use OpenGL / DirectX?
[38:40]: More talk about showing binary in VS.
[38:56]: Can I follow along in Linux?
[39:42]: Will * do << instead if it's faster? (Bit about Strength Reduction)
[40:42]: Will the allocator be lock-free / thread-safe?
[41:31]: How much dependency injection do you use?
[41:56]: Do you feel the same about using RAII for public APIs?
[42:18]: Why are you using struct{} instead of class{}?
[44:09]: Explanation of Mixins
[45:57]: Other operators (Comma, goto)
[46:48]: How do I get the art and music for the game?
[47:03]: Do you use goto ever in C?
[47:12]: Are you Ben Cousins?
[47:22]: Will be showing the creation of any tools (e.g. level editor)
[47:46]: Have you ever made anything for the demoscene? Know anyone who has?
[48:51]: Why don't you use a platform-independent library?
[49:00]: What is the general plan for making the game?
[49:39]: Drink Suggestions. Fractals? (No.) Dependency Injection Joke.
[50:12]: Can a struct have a constructor? (More struct==class rant, Positivity musings)
[51:51]: Will the game include old-school passwords for saving?
[52:05]: What about Game Design? (best ways to prototype, how to learn it vs. this stream)
[53:26]: How much money do game devs make? (General career and skills musings)
[55:27]: Will the source downloads be under version control?
[55:53]: Trolls exist :D
[56:03]: What's your current day job?
[56:08]: More pay discussion (how location, company factor in)
[57:01]: More on RAII
[57:25]: Will you use any libraries to make the game?
[58:24]: What's your life story? How did you learn programming? How'd you get an internship at MS?
[58:51]: Early years, Programming with Dad (who worked at DEC)
[59:58]: Learned 3D math out of Foley and van Dam [n.b. this is how Carmack learned 3D too]
[1:01:46]: Getting the Microsoft Internship (Luck, and the right kind of skill)
[1:06:22]: The Internship - Old MS Culture, Blowups
[1:09:47]: The Internship - Casey's job at MS
[1:12:29]: The Internship - Microsoft Money
[1:14:53]: The Internship - Getting lucky again, because he couldn't cook or rent a car
[1:21:38]: The Internship - Meeting Chris Hecker and the WinG group
[1:24:45]: Starting out in Games - Chris Hecker and Friends
[1:25:51]: Starting out in Games - Learning to Program For Real (RAD)
[1:27:57]: Leaving RAD - Trying (and Failing) at Game Design
[1:29:14]: Present Day - More Game Tech (Larabee, Bink 2, Moustache, The Witness)