Tips and tricks for reading unfamiliar code

Ants Are Everywhere
29 Aug 202424:30

Summary

TLDRThe speaker discusses strategies for reading and understanding code, emphasizing the importance of being fearless and comfortable with confusion. They advocate for multiple 'passes' through code, akin to how one might read a book, to gradually build understanding. The talk touches on the psychological aspects of learning, such as the brain's pattern recognition and the value of familiarity over deep understanding. Technical advice includes having a strong foundation in data structures and algorithms, and using an algorithmic approach to exploring code. The speaker also discourages starting with 'Main' when reading code, suggesting instead to focus on the human-facing aspects of code organization.

Takeaways

  • ๐Ÿ˜Œ **Embrace Fearlessness**: To understand a codebase, especially large ones, one must be fearless and accept that it's often too large for a single person to fully grasp.
  • ๐Ÿง **Accept Confusion**: It's crucial to be comfortable with not understanding everything immediately and to move on without getting stuck on minor details.
  • ๐Ÿ” **Multiple Passes**: Reading and understanding code often requires multiple passes, similar to how one might approach reading a complex book.
  • ๐Ÿง  **Understand the Brain's Learning Process**: Recognize that the brain processes information in a probabilistic and pattern-matching way, akin to machine learning algorithms.
  • ๐ŸŽฏ **Have a Clear Objective**: When exploring code, it's important to know what you're looking for, which helps focus your attention on relevant parts of the codebase.
  • ๐Ÿค **Familiarity Over Understanding**: Sometimes, being familiar with code is more practical than striving for a deep understanding, especially when time is limited.
  • ๐Ÿ’ป **Technical Proficiency**: Having a solid foundation in data structures, algorithms, and programming languages is essential for effectively reading and understanding code.
  • ๐Ÿ“š **Balanced Learning**: Balance reading code with writing code and studying related materials to reinforce learning and understanding.
  • ๐Ÿ” **Algorithmic Exploration**: Develop a systematic approach to exploring code, such as iterative deepening, to efficiently find the most relevant parts of a codebase.
  • ๐Ÿ› ๏ธ **Focus on Human-Facing Artifacts**: Prioritize understanding the organization and structure of the code as presented to humans, rather than getting lost in machine execution details.

Q & A

  • What is the main challenge when trying to understand a large codebase?

    -The main challenge is that most codebases of interest are too large to be fully understood by a single person, as they are often worked on by multiple teams and broken down into specialized components.

  • Why is it important to be fearless when reading code?

    -Being fearless is important because it allows you to approach complex codebases without being intimidated by their size or complexity, and to engage with the code without fear of not understanding every part.

  • What does the speaker suggest about being comfortable with confusion when reading code?

    -The speaker suggests that being comfortable with confusion is essential because you won't understand everything at first glance, and accepting this fact allows you to move forward and learn over time.

  • How does the concept of 'doing several passes' help in understanding code?

    -Doing several passes over the code allows you to gradually build understanding, as each pass may reveal new insights or clarify previous confusions, much like how repeated exposure helps in learning and pattern recognition.

  • What role does the brain's pattern recognition play in reading code?

    -The brain's pattern recognition is crucial in reading code because it helps in identifying common structures and algorithms across different codebases, much like how machine learning algorithms learn from data.

  • Why is it beneficial to have a clear idea of what you are looking for in a code repository?

    -Having a clear idea of what you are looking for helps focus your attention on relevant parts of the code, making the process more efficient and targeted, rather than getting lost in irrelevant details.

  • How does familiarity differ from understanding in the context of learning to code?

    -Familiarity refers to becoming comfortable and accustomed to certain coding patterns and structures, which is often more achievable and practical than deep understanding, especially when dealing with complex topics or large codebases.

  • What background knowledge is necessary to effectively read and understand code?

    -Background knowledge such as data structures, algorithms, and programming language fundamentals is necessary to recognize patterns and understand the logic within the code.

  • What is the speaker's approach to exploring code within a repository?

    -The speaker's approach involves an algorithmic mindset, starting with identifying the root folder, then progressively exploring subfolders, and focusing on the parts of the code that match their interests or goals.

  • Why does the speaker recommend not starting with the 'Main' function when exploring new code?

    -Starting with the 'Main' function is often not useful because it typically involves command line parsing and branching that leads in multiple directions, which can be complex and not representative of the core logic or structure of the program.

  • What is the importance of being honest with oneself about what is understood and what is not when reading code?

    -Being honest with oneself is crucial to avoid self-deception and to ensure that the learning process is genuine and effective, as it helps in identifying areas that require further attention or clarification.

Outlines

00:00

๐Ÿ˜Ž Mental Game for Reading Code

The speaker begins by addressing the complexity of reading code and how it relates to their views on education and learning. They emphasize the importance of being fearless and comfortable with confusion when trying to understand a codebase. The analogy of having a conversation with a computer is used to illustrate the process of understanding code. The speaker also discusses the idea of making multiple passes through the code to gradually build understanding, much like how one might approach reading a book. The mental game involves accepting confusion and the fact that complete understanding of a large codebase is often unattainable and not necessarily beneficial.

05:00

๐Ÿง  Psychological Insights on Code Comprehension

This paragraph delves into the psychological aspects of learning and understanding code. The speaker suggests that the brain operates similarly to a machine learning algorithm, processing information probabilistically and recognizing patterns. They recommend approaching code as one would approach training an AI, focusing on recognizing patterns across multiple repositories rather than trying to understand every detail of a single one. The speaker also stresses the importance of knowing what you are looking for in a codebase, using the differences between repositories as a guide to focus your attention. Lastly, they touch on the idea that familiarity can be more valuable than a false sense of understanding, advocating for practical engagement with code over theoretical comprehension.

10:02

๐Ÿ’ป Technical Foundations for Navigating Code

The speaker discusses the technical knowledge required to effectively read and understand code. They highlight the necessity of having a background in data structures, algorithms, and programming languages. The paragraph emphasizes the importance of practical programming experience and suggests a balanced approach to learning that includes reading code, writing code, and studying related information. The speaker also recommends having an algorithmic approach to exploring code, starting with a broad overview and gradually delving deeper into specific areas of interest. They advise against starting with the 'Main' function, as it often leads to complex branching and initialization routines that can obscure the core logic of the program.

15:05

๐Ÿ” Practical Strategies for Code Exploration

In this paragraph, the speaker focuses on practical strategies for exploring code. They advocate for an iterative deepening approach, similar to depth-first search, to navigate through the file system and understand the organization of the code. The speaker suggests starting with the root folder and progressively examining subfolders to identify areas of interest. They also discuss the importance of being honest with oneself about what is understood and what is not, warning against the pitfall of overestimating one's comprehension. The paragraph concludes with a reminder to focus on the human-facing aspects of code, such as the file system and organization, rather than the machine-facing aspects like execution traces.

20:05

๐Ÿ•ต๏ธโ€โ™‚๏ธ The Value of Honesty in Code Understanding

The final paragraph reinforces the idea of being honest with oneself about the level of understanding when reading code. The speaker relates this to the earlier point about being comfortable with confusion, suggesting that self-deception can hinder true learning. They emphasize the importance of recognizing one's limitations and the emotional barriers that can prevent a clear understanding of complex topics. The speaker concludes by acknowledging that while they have covered many points, there is always more to learn and that the process of reading and understanding code is an ongoing journey.

Mindmap

Keywords

๐Ÿ’กFearlessness

Fearlessness in the context of the video refers to the mental attitude one must adopt when approaching complex codebases. It implies a willingness to engage with large and potentially overwhelming amounts of code without being intimidated. The speaker emphasizes that most codebases, especially those from large companies, are too large for a single person to fully understand. Therefore, fearlessness is crucial for navigating these complexities and for maintaining the motivation to explore and learn from the code.

๐Ÿ’กMental Game

The 'mental game' is a concept introduced to describe the psychological approach one should take when reading and understanding code. It encompasses being fearless, accepting confusion, and making multiple passes over the code. The video suggests that this mindset is essential for dealing with the challenges of code comprehension, as it allows for a more iterative and less overwhelming process of learning and understanding.

๐Ÿ’กPattern Recognition

Pattern recognition is a key process in both machine learning algorithms and human learning, as discussed in the video. It involves identifying commonalities and differences across various pieces of code or information. The speaker likens the brain's approach to learning to that of a machine learning algorithm, which improves its understanding through repeated exposure and pattern recognition across a dataset. This concept is central to the video's theme of how to effectively read and understand code.

๐Ÿ’กIterative Learning

Iterative learning is a method of learning where understanding is built up over multiple passes or exposures to the material. The video speaker suggests that instead of trying to understand everything in one go, it's more effective to review code multiple times, each time gaining a deeper understanding. This aligns with the concept of iterative deepening depth-first search in computer science, where one explores a problem space in layers of increasing depth.

๐Ÿ’กFamiliarity vs. Understanding

The video distinguishes between the concepts of 'familiarity' and 'understanding'. Familiarity is presented as a more pragmatic and achievable goal when dealing with complex technical topics like code. It suggests that while deep understanding can be elusive and sometimes overemphasized, familiarity with the tools, functions, and structures of a codebase is a more tangible and useful skill to develop.

๐Ÿ’กBackground Knowledge

Having a solid foundation in computer science and programming is referred to as 'background knowledge' in the video. It's the prerequisite knowledge that allows one to effectively read and comprehend code. The speaker mentions data structures, algorithms, and programming languages as essential components of this background knowledge, which are necessary for recognizing and interpreting patterns in code.

๐Ÿ’กCode Exploration Algorithm

The 'code exploration algorithm' is a strategy the speaker uses for systematically navigating and understanding codebases. It involves starting with a high-level overview, identifying the most relevant files or folders, and then progressively delving deeper based on what seems most promising or important. This methodical approach is akin to an algorithm, providing a structured way to explore and learn from code.

๐Ÿ’กHuman-facing vs. Machine-facing Artifacts

This concept contrasts the organization of code for human comprehension (human-facing) with the execution of code by machines (machine-facing). The video argues for focusing on the human-facing aspects, such as the file system and directory structure, as these are designed to help developers understand and maintain the code. In contrast, machine-facing aspects like execution traces and assembly code are less relevant for the initial understanding of how the code is organized and intended to be used.

๐Ÿ’กHonesty with Self

Being honest with oneself about what one understands and what one does not is a psychological point made in the video. It's crucial for effective learning and avoiding the pitfall of assuming comprehension where there is none. The speaker suggests that this self-awareness is part of the mental game required to learn from code and to avoid being misled by superficial familiarity or partial understanding.

๐Ÿ’กEgo and Learning

The video touches on the role of ego in the learning process, suggesting that personal pride or the desire to prove oneself can sometimes interfere with genuine understanding. It's important to set aside ego and focus on the actual process of learning and comprehension. This is linked to the broader theme of the video, which encourages a humble and iterative approach to reading and understanding code.

Highlights

The necessity of being fearless when attempting to understand a large codebase.

The analogy of understanding a codebase to having a conversation with a computer about its behavior.

The importance of being comfortable with confusion when reading code.

The strategy of making multiple passes through code to gradually improve understanding.

The brain's processing likened to a machine learning algorithm, focusing on pattern recognition.

The concept of focusing on what is different between codebases to understand unique aspects.

The psychological insight that familiarity often matters more than deep understanding.

The advice to have a background in data structures and algorithms to effectively read code.

The recommendation to practice reading, writing, and learning about programming languages simultaneously.

The approach of using an algorithmic mindset, similar to iterative deepening depth-first search, to explore code.

The suggestion that starting at the 'Main' function is often not the most productive way to understand a program.

The preference for focusing on human-facing artifacts of code over machine-facing artifacts.

The importance of being honest with oneself about what is understood and what is not, to avoid self-deception.

The idea that the emotional response to understanding complex topics can sometimes hinder true comprehension.

The emphasis on the practicality of code understanding over theoretical knowledge.

Transcripts

play00:00

so I've gotten a lot of questions about

play00:02

you know how do I recode as in how do I

play00:05

personally read code but also like what

play00:08

can people

play00:10

do to get better at reading code or

play00:13

understanding code or writing code and

play00:15

uh initially I had started writing out a

play00:18

a whole script uh for for this and I

play00:21

started kind of spiraling out of control

play00:24

because the reality is that the the way

play00:26

that I read code is pretty um dependent

play00:29

on and embedded in the my ideas about

play00:33

how Education Works how Learning Works

play00:36

in

play00:36

general and that's something that we are

play00:39

going to focus on in this

play00:42

channel uh soon now that we're leaving

play00:45

this old regime but we haven't really

play00:48

talked about it yet and I didn't really

play00:50

want to put the the cart before the

play00:51

horse and it was getting into a

play00:54

situation the the script was getting

play00:56

into a situation where um I felt like I

play01:00

was perhaps raising more questions than

play01:02

I was answering so what I want to do

play01:05

here is just give a few like tips and

play01:08

tricks about heris how I think about

play01:11

reading code and um they are the

play01:15

following so I guess we might as well do

play01:17

this as an org buffer

play01:19

uh

play01:21

so here's how I'll set it out so

play01:25

psychological um

play01:32

uh computer science these will be just

play01:35

like little headings just to hang things

play01:36

on

play01:38

um

play01:42

and is there a last one I don't

play01:46

know we'll start here maybe this will be

play01:51

technical so uh how about mental game

play01:55

mental game will be first so the first

play01:57

mental game point is uh

play02:01

you have to be you have to be relatively

play02:03

Fearless uh if you want to do something

play02:05

like um trying to understand a codebase

play02:08

is kind of a foolish thing to do most

play02:11

code bases that are of Interest are too

play02:13

large to uh to understand even for one

play02:17

person if you take something uh that

play02:21

like you know a large company like

play02:22

Google put out puts out or meta or

play02:26

Twitter or Netflix often times those big

play02:30

projects are going to be worked on by

play02:33

several teams and if you're really lucky

play02:37

a small number of the team leaders on

play02:39

those teams will understand like One

play02:42

Directory um that's maybe exaggerating a

play02:44

little bit but

play02:47

um really things are broken down and

play02:50

specialized and you don't really have

play02:52

someone whose job it is to understand

play02:54

the whole code base because it's not

play02:56

clear that uh even if were possible that

play02:58

there would be a whole lot of a whole

play03:00

lot to gain from that instead what the

play03:03

codebase does is you've written down

play03:05

into the

play03:06

computer uh how the how the machine will

play03:10

act and so that's really the record of

play03:13

the code base and then in terms of

play03:14

understanding it your job is to sort

play03:16

of

play03:19

um figure be able to have a conversation

play03:23

about with the computer in some sense

play03:26

about about how you want it to act so

play03:27

it's maybe a little bit like uh

play03:30

I have kids uh you may not have kids but

play03:33

it's a little bit like having a kid it's

play03:34

not really my job to understand

play03:36

everything that goes on in my kid's

play03:38

brain because literally nobody does but

play03:42

um it is my job to like if my kid is

play03:44

having a hard time be able to have a

play03:45

conversation with them and help them

play03:48

have a better time and it's kind of the

play03:49

same with code and in order to do that

play03:52

and you have to be uh you have to be

play03:56

also willing to be confused

play04:02

and

play04:03

not these are related right so you have

play04:06

to be willing to like as you're looking

play04:08

at something uh be comfortable with the

play04:12

fact that you don't understand what's

play04:14

going on and you see that a lot in this

play04:16

channel um and you know very often I'll

play04:20

just say I don't know what's going on I

play04:21

don't know what this variable is for I

play04:23

don't know what this piece of syntax is

play04:25

and I I typically just move on rather

play04:27

than trying to drill down and that's a

play04:29

that's a strategy I think like earlier

play04:32

in my life it would have really bothered

play04:34

me that I didn't understand something

play04:36

because I was very good at understanding

play04:37

things and so I learned over time that

play04:40

it's vastly better to do a pass where

play04:44

you're accepting of the fact that there

play04:46

are things that you don't understand

play04:49

even if you know they are silly and

play04:51

you've made some sort of mistake and you

play04:53

would understand it if you had not made

play04:55

some simple mistake or whatever um and

play04:57

then

play05:00

just being okay with that uh is really

play05:03

powerful and then uh I guess relatedly

play05:06

is like um think in terms

play05:09

of of doing

play05:11

um

play05:13

several

play05:15

passes is how I'll put it there's a good

play05:18

book here

play05:23

um I uh I think Mor J Adler is the guy

play05:29

uh this is not like a like life-changing

play05:32

book but I think it's a book that's

play05:33

worth maybe getting and looking at and

play05:36

the idea uh the idea of how to read a

play05:39

book is just like it's a you know um a

play05:43

lot of kids like go to go to college and

play05:47

they

play05:48

don't have a relationship with uh with

play05:52

literature the way that you know from

play05:54

High School the way that you do in

play05:56

college and uh when you're faced with

play06:01

like a huge library of

play06:04

literature uh on on your field like you

play06:06

may be an engineer there's an

play06:08

engineering literature you may be a

play06:09

philosopher there's a philosophy

play06:10

literature you have to have some

play06:13

strategy for for dealing with all of

play06:15

that and the strategy can't really be

play06:16

like depth first search where you're

play06:18

going to like pick up uh n and

play06:22

understand everything that's in it

play06:24

instead what you want to do is you want

play06:26

to read books and passes you want to

play06:27

make a pass through each individual book

play06:29

you probably also want to make a pass

play06:31

through several books at the same time

play06:33

so maybe you want to pick up the N book

play06:35

also pick up a Play-Doh book pick up a

play06:37

book on Classics of philosophy and kind

play06:40

of work through them sort of

play06:44

simultaneously and so that's a little

play06:46

bit of how I've I've done things in this

play06:49

um in this stream it's been rare

play06:52

recently that I've Revisited a

play06:54

repository many times and that's really

play06:57

an artifact of uh of my trying to get

play06:59

through the

play07:01

backlog uh but if it were me left to my

play07:04

own devices I would revisit the same

play07:06

repository that I was trying to

play07:08

understand multiple times doing multiple

play07:10

passes and that's useful because when I

play07:12

don't understand something uh almost

play07:15

always I find I eventually understand it

play07:18

with little effort just by doing more

play07:19

passes I may not understanding the next

play07:21

pass it may take a couple of passes um

play07:25

but that in my experience is like the

play07:28

least effort approach to getting the

play07:30

most uh the most out of um the most out

play07:34

of what you're doing so that's that's

play07:36

the mental game we'll uh hide that for

play07:39

now so we can focus here on the on kind

play07:41

of psychological

play07:43

points and the first psychological point

play07:46

is

play07:49

um maybe have a sense

play07:56

of have a sense of how the brain

play07:58

processes in

play08:01

in my opinion I think this is now pretty

play08:04

mainstream the the brain is more or less

play08:07

like a machine learning algorithm rather

play08:09

than a traditional computer so the brain

play08:12

takes like a probabilistic approach it

play08:14

does a lot of pattern matching and it

play08:17

does a lot of that almost all of it I I

play08:21

would say uh kind of behind the scenes

play08:23

in a way that you're not really aware

play08:25

of so what that means is you can kind of

play08:29

take it imagine that your brain

play08:31

literally is a machine learning Al

play08:33

algorithm look at how they train

play08:35

algorithms and take that sort of

play08:37

approach so when you're training um an

play08:40

AI algorithm to let's say understand

play08:44

text uh at the end of the training it's

play08:48

able to quote unquote understand text in

play08:50

this in the sense that you can ask it a

play08:51

question and it will spit out a response

play08:54

but kind of in the beginning of the

play08:55

training or in the middle of the

play08:56

training it doesn't really understand

play08:58

anything it's like updated getting a

play08:59

bunch of weights and if you tried to get

play09:02

information out of it it would be

play09:03

terrible and garbled and so what that

play09:07

what that implies is that uh this

play09:09

algorithm is iterating over a bunch of

play09:12

documents and it doesn't really

play09:14

understand any one document instead what

play09:16

it's doing is kind of like pattern Rec

play09:18

pattern recognition across a corpus of

play09:22

documents and that's the that's the same

play09:24

sort of approach that I'm taking here is

play09:26

I've looked at a bunch of repositories

play09:29

I'm not really trying to understand any

play09:30

one repository instead I'm trying to see

play09:33

what things have in common what things

play09:35

stick out and what are different and and

play09:37

that sort of

play09:38

thing um I guess relatedly is have a

play09:42

sense of what you're looking

play09:44

for in a in a repo so if you have

play09:50

uh if you've gotten to the point where

play09:52

you've looked at a bunch of different

play09:54

pieces of code then it'll be clear to

play09:57

you as I just said what's in common but

play10:00

it would also be clearer to you uh

play10:02

what's different and it's really the

play10:04

differences you can imagine like

play10:06

literally running a diff algorithm like

play10:08

a conceptual diff algorithm um between

play10:10

two repositories and those diffs are the

play10:13

sorts of things that you want to focus

play10:14

on and so for example when I was looking

play10:17

at databases I wanted to know the

play10:19

database type thing like how are their

play10:21

how are their file systems different

play10:23

from other repositories a big part of

play10:26

databases are that it's they fast to

play10:29

search so I wanted to know how the

play10:31

querying um algorithms worked and in

play10:34

particular we'd already seen a lot of

play10:36

like

play10:37

parsing and in compiler type stuff so I

play10:40

was interested more in the query

play10:42

planning rather than the query like uh

play10:45

parsing and and mapping onto specific

play10:47

functions or

play10:48

whatever uh so having that sense of what

play10:51

you're looking for is will help Focus

play10:54

the mind because especially if you have

play10:57

a a bounded amount of time

play11:00

it'll it'll help you figure out whether

play11:02

something's worth looking at or not and

play11:04

similarly if you were like

play11:05

traveling if you were like going to

play11:07

Paris you would probably want to go to

play11:09

the parts of if as a tourist you would

play11:11

want to go to the the parts of Paris

play11:13

that are different from all of the other

play11:16

places you wouldn't like go to Paris and

play11:17

like spend the whole time eating at

play11:19

McDonald's or

play11:21

whatever

play11:24

um the last maybe psychological Point uh

play11:27

I want to make is like familiarity

play11:29

in practice I'll literally write this

play11:32

down in practice is often important than

play11:36

understanding so and I'll put these in

play11:38

in quot in scare quotes

play11:40

because I don't think these are super

play11:43

well-defined um terms

play11:45

psychologically the way that I think

play11:47

about it is that familiarity and

play11:50

understanding are kind of like

play11:51

feelings and what the psychological

play11:55

literature says in my reading of it is

play11:58

that often when people think that they

play12:01

understand something they don't actually

play12:03

understand it they overestimate how much

play12:05

they understand especially about

play12:07

technical

play12:08

topics

play12:10

uh and so understanding is kind of this

play12:14

emotion that's that's in my opinion

play12:17

really kind of about comfortableness

play12:19

with the topic uh and it can often be

play12:23

illusory on the other hand in practice

play12:26

familiarity seems to be really important

play12:29

um there's a famous quote from uh John

play12:33

Von noyman that in mathematics you never

play12:35

understand things you you just get

play12:37

familiar with them uh that's not word

play12:40

for word the qu but that's the basic

play12:41

idea and I think that's correct like Von

play12:44

noyman was one of the one of the best

play12:47

mathematicians in the last however many

play12:49

years arguably one of the smartest

play12:52

people in history and and I think he's

play12:55

correct in the sense that like you you

play12:58

sometimes see people trying to chase

play13:00

understanding or like

play13:03

intuition about a

play13:05

topic um and it's often not clear that

play13:10

that pays off that often seems like

play13:11

they're in retrospect they're they are

play13:14

wasting their time it would be uh more

play13:18

time efficient to just accept the accept

play13:22

the things that you know about them

play13:23

become familiar with them play around

play13:25

with them explore the tools that you

play13:27

have but not really

play13:29

try to P too much attention to whether

play13:33

you feel internally like you've gred

play13:35

something and I think that's a I think

play13:37

that's an important

play13:39

shortcut

play13:41

um yeah okay and then in terms of

play13:45

technical stuff this is now kind of

play13:47

getting to the computer

play13:49

science uh computer sciencey area one is

play13:53

um so I'm coming to this having already

play13:58

uh programmed professionally having

play14:01

studied uh some computer science but

play14:04

having studied lots of other technical

play14:06

things solved you know many many math

play14:09

problems uh solved many fewer but still

play14:13

a fair number of programming problems

play14:15

and so there's just some level of

play14:16

background knowledge that you'll need in

play14:18

order to understand uh to understand

play14:22

like a something as big as a as a

play14:24

repository and so I'll say like you

play14:26

should know data structures

play14:31

algorithms how much do you need to know

play14:33

them I don't know but you should be

play14:34

familiar with them you should have

play14:36

probably have

play14:38

implemented things like depth first

play14:40

search breadth first search uh a few

play14:44

times under

play14:46

different uh under in under different

play14:51

conditions exploring different problems

play14:54

um and you should obviously know the

play14:57

basics like four loops and while loops

play14:58

and all all of that stuff and if you

play15:00

struggle there then you're going to

play15:04

struggle reading other other people's

play15:07

codes because you just won't have the P

play15:09

you won't have those patterns very well

play15:11

in your system in order to recognize

play15:13

them in others so this is just like

play15:15

background knowledge I

play15:18

guess um you should know some

play15:21

programming

play15:24

language and have a programming practice

play15:27

I guess

play15:29

so this is like um for those of you who

play15:32

are learning how to code uh and want to

play15:35

read in order to learn how to code this

play15:37

maybe kind of like a chicken and egg

play15:38

problem but the way that I would do it

play15:40

personally if I were starting out is I

play15:43

would um have a practice of reading code

play15:46

have a practice of writing code and also

play15:49

have a practice of reading information

play15:52

about the the topic and programming

play15:54

language I was I was working on this

play15:56

could be that could be books this could

play15:58

be

play15:59

uh like websites documentation it could

play16:01

be videos um and kind of go back and

play16:04

forth between those three things like

play16:06

split your time because those are sort

play16:08

of M mutually reinforcing uh habits and

play16:14

uh what you want to really have is the

play16:16

Rhythm between those

play16:17

things in order to make the the fastest

play16:21

progress I

play16:23

guess

play16:25

um and then uh

play16:31

I guess the last technical point I will

play16:33

have is that

play16:34

um how maybe have an

play16:39

algorithm in mind for exploring the

play16:43

code I I typically do something that's

play16:46

maybe a little bit like uh iterative

play16:48

deepening depth for a search uh what

play16:51

you'll see that I do in almost all cases

play16:53

is I the first thing I want to know is

play16:55

like

play16:57

uh which which

play17:00

file so often there's like one folder

play17:02

that has all of the goodies and it's

play17:05

like the source folder or something it

play17:07

it depends on the language but like

play17:09

first of all finding out the right root

play17:10

folder but then inside that root folder

play17:13

looking at all of the folders in there

play17:15

that's like depth equals 1 and figuring

play17:18

out okay which of these looks like it's

play17:21

probably going to have the sort of sort

play17:24

of information I'm looking for

play17:27

so here or have a sense of what you're

play17:29

looking for if I have a sense of what

play17:31

I'm looking for like I know I'm looking

play17:33

for the uh I know I'm looking for the

play17:36

parsing routine or whatever then the

play17:39

that should hopefully be evident where

play17:42

that is from the the first level of

play17:44

folders if not or if it's a project and

play17:48

you don't really know where the most

play17:49

interesting code or routines is then you

play17:53

kind of have to make some guesses and so

play17:56

you like peek deeper into the folders

play17:58

and and try to do the same thing and you

play18:00

kind of go down bit by bit and so that's

play18:03

sort of how I think of that's how sort

play18:05

of how I think of things

play18:08

um and we'll see that I think a little

play18:10

bit in the um in the blender build

play18:14

system section

play18:16

video

play18:18

uh and then the last the real last I

play18:22

said that was the last but this is the

play18:23

real last

play18:27

um this is there's a point that comes up

play18:30

repeatedly I'm not quite sure how to put

play18:32

it in writing but we'll talk about it

play18:34

and then I'll figure a way to summarize

play18:35

it um when I first started people were

play18:38

asking me about like why not start at

play18:39

Main and kind of like Trace through the

play18:42

execution and uh after people started

play18:45

suggesting it I did start looking more

play18:47

at the main file more often

play18:50

and almost all the time the main file is

play18:54

not an interesting place to start

play18:56

because what happens is like uh Main

play18:58

it's going to kick off some like often

play19:00

command line parsing routine and then

play19:03

it's going to branch in a bunch of

play19:05

different directions depending on the

play19:07

the command line flags and then you have

play19:09

to track all that branching and then

play19:12

there's going to be like some loading

play19:13

and initialization routines and that

play19:16

probably has a bunch of different

play19:17

branching because that's also looking

play19:18

for things like what platform are you on

play19:19

etc etc and so um often like going into

play19:24

Main and tracking execution in that way

play19:26

is not super useful and also like if

play19:30

you're tracking uh if you're tracking in

play19:32

like a debugger you kind of have to

play19:34

figure out what level you want to debug

play19:36

because if you like start uh by setting

play19:38

some break

play19:39

point and

play19:43

um the if you just stay at the same

play19:46

level it's equivalent to just reading

play19:47

the code it's going to execute line by

play19:49

line if you step into and out of

play19:51

functions then you're going to like

play19:53

quickly get down uh deeper and deeper

play19:56

into uh kind of things might be

play19:59

implementation details compared to what

play20:00

you actually want to

play20:01

know and so what I have found is that

play20:05

the tracing the execution is is really

play20:07

for the computer that's how the computer

play20:09

thinks but the way that code is

play20:11

organized for humans is via the file

play20:14

system that's how uh organizations the

play20:18

the the files layout typically reflects

play20:20

how organizations have devoted human

play20:23

resources to writing the code it's uh

play20:27

it's the the files are there for humans

play20:30

to put their thoughts into and then the

play20:35

the it's

play20:37

the once it's compiled and executed that

play20:39

that's for the machine so my personal

play20:42

preference and you can differ here but

play20:44

my personal preference is focus on the

play20:46

files the focus on the human facing

play20:51

artifacts rather than the machine facing

play20:56

artifacts is how I'll put that

play20:59

now you do sometimes need to look at the

play21:01

machine facing artifact so for example

play21:03

if you want to debug a program that's

play21:07

gone Haywire or if you want to

play21:10

understand the uh like assembly code or

play21:13

if you want to disassemble some program

play21:15

you do have to dig into the weeds that

play21:18

again goes back to knowing what you want

play21:19

to look for um and so if that is what

play21:22

you want to look for then uh like

play21:25

stepping through with a debugger Etc

play21:27

that's a that's a really good way to

play21:28

look at things and I do I do enjoy

play21:30

debuggers I use them uh for tasks that

play21:34

are different from reading code but

play21:37

um but they're great they're life-saving

play21:40

tools uh I had one more thought I think

play21:44

we check my notes Here

play22:01

yeah I guess this maybe goes into

play22:03

psychological or maybe I'll call it

play22:06

mental

play22:08

game uh and that is

play22:13

um this is probably this is closely

play22:16

related to be willing to be confused and

play22:18

that is be honest about what you

play22:22

understand so if you're going to be

play22:24

looking through something and are will

play22:28

are willing to to be confused then that

play22:30

only works if you're honest with

play22:32

yourself about what you understand and

play22:35

and what you're confused about um the

play22:38

danger of not going through something

play22:40

carefully and trying to understand it at

play22:44

every step of the way is that you might

play22:46

fool yourself into thinking you've

play22:48

understood something when you haven't

play22:51

and that might take practice I don't

play22:52

know that that might just take some

play22:54

humility just but be aware that uh you

play22:58

have have limitations some of these Li

play23:02

some of these limitations are

play23:04

informational like uh the you can think

play23:07

about different ways of trying to

play23:10

understand something some of those will

play23:12

have like exponential running time some

play23:14

might have polinomial running time and

play23:16

it's kind of your uh your choice about

play23:19

which of those algorithms to

play23:21

run but um in addition to being having

play23:26

like this information constraints like

play23:27

the sort of running time intrinsic

play23:29

constraints there's also um constraints

play23:33

about like your ego might be involved in

play23:36

being able to solve some problem or

play23:37

being able to understand something

play23:39

complicated that your friends are having

play23:41

trouble with or being able to prove

play23:43

yourself

play23:44

or uh you know all of that stuff kind of

play23:47

goes into any topic that's sufficiently

play23:50

complex or wanting to to dig your way

play23:52

out of poverty or all of that stuff so

play23:56

um you just have to kind of be aware of

play23:59

when

play24:00

you're

play24:04

uh you have to be aware of kind of when

play24:07

those like emotional responses are are

play24:10

making you think that you've mastered

play24:13

something that maybe you haven't

play24:14

mastered um and I guess maybe that's the

play24:17

last point I'm sure I'll think of uh of

play24:20

more stuff but for now we'll leave it

play24:23

here and I'm going to move on

play24:26

to the blender build system

Rate This
โ˜…
โ˜…
โ˜…
โ˜…
โ˜…

5.0 / 5 (0 votes)

Related Tags
Code ReadingMental GameLearning StrategiesDebuggingCodebase ExplorationAlgorithm UnderstandingProgramming PracticeTechnical KnowledgeSelf-HonestyFamiliarity vs Understanding