spotifyovercastrssapple-podcasts

Code Reading Club with Katja Mordaunt

We discuss Code Reading Club, how improving your code reading skills can make you a better programmer, and the readability of Elm code.
September 25, 2023
#91

Transcript

[00:00:00]
Hello Jeroen.
[00:00:02]
Hello Dillon.
[00:00:03]
Read any good code lately?
[00:00:04]
I read a lot of great code.
[00:00:07]
I thought you were going to start by doing a bad pun, but I feel like you're reading
[00:00:12]
The Room recently and I feel like you shouldn't.
[00:00:17]
I was having trouble decoding your joke at first, but it finally landed.
[00:00:24]
Well, hopefully we've got somebody who can save us from our terrible puns today.
[00:00:30]
Katja Mordent is joining us.
[00:00:32]
Welcome Katja.
[00:00:33]
Thanks for joining us.
[00:00:34]
Hello.
[00:00:35]
Thanks for having me.
[00:00:36]
I'm excited.
[00:00:37]
I'm excited to do some, I don't know, code reading The Room.
[00:00:40]
You're supposed to save us from the puns, not tangle us into them further.
[00:00:50]
So Katja, what is Code Reading Club?
[00:00:53]
Wow, that's a big question Dillon.
[00:00:58]
Our episodes are usually pretty long, so you have all the time you need.
[00:01:03]
Is an hour and a half sufficient?
[00:01:05]
So Code Reading Club is not a club where I get together with lots of small children and
[00:01:11]
teach them to read code, which is a common misconception.
[00:01:15]
So a lot of times people say, oh, you do Code Reading Club.
[00:01:18]
That's so cute.
[00:01:20]
But it's not.
[00:01:22]
It's for professional developers.
[00:01:24]
And it was inspired by research that Felina Hermans did.
[00:01:30]
I saw her speak at a couple of conferences and then approached her after one of them
[00:01:35]
and said, all of that theory that you're talking about would be really interesting to bring
[00:01:40]
into practice.
[00:01:42]
I can see all of these problems manifesting with my development teams.
[00:01:46]
And I'd really like to make some strategies and techniques and things to help bring this
[00:01:53]
knowledge to them.
[00:01:54]
So that's kind of where it came from.
[00:01:57]
Have either one of you ever been to one of my Code Reading Clubs?
[00:02:00]
Are they online?
[00:02:01]
They are online.
[00:02:02]
Sometimes.
[00:02:03]
Yeah, I mean, they're in person and online.
[00:02:06]
So if I go back to our original question, probably I should introduce what Code Reading
[00:02:12]
Club is entirely, because it is a club where you read code, or a set of clubs where you
[00:02:19]
read code.
[00:02:20]
Code Reading Club is a set of exercises that have been designed to help professional programmers
[00:02:28]
get better at reading code.
[00:02:30]
It's to help with getting into a new code base.
[00:02:34]
So looking at a piece of unfamiliar code.
[00:02:36]
It's to help with finding bugs and like figuring out what's going wrong.
[00:02:42]
It's to help with how you can review code and have conversations about code with your
[00:02:48]
colleagues.
[00:02:50]
And the way that it manifests is about an hour, it takes about an hour and a half, and
[00:02:56]
you should run your clubs with the same people over and over so that people get familiar
[00:03:02]
with each other and how they think.
[00:03:07]
You can do it with your programming teams in your company, or you can do it with a group
[00:03:11]
of people from lots of different companies, and they both have different benefits.
[00:03:16]
And the exercises are designed to start from like looking at the very first exercise that
[00:03:21]
we always do is an exercise called first glance, where you look at a whole piece of code in
[00:03:27]
one glance and like less than 10 seconds and try and identify what the thing that jumps
[00:03:32]
out at you is.
[00:03:33]
And then you try and identify what the second thing that jumped out at you was.
[00:03:38]
And then you try and think about why those two things jumped out at you and you have
[00:03:42]
a conversation.
[00:03:43]
So every exercise is designed for like individuals do it by themselves and reflect on it by themselves
[00:03:49]
and then bring it back to the group and the group has a conversation about it.
[00:03:53]
So I'm going to pause and let you ask me a question.
[00:03:58]
So I kind of want to ask you like, what are the kinds of things that pop out that jumped
[00:04:04]
at people, but maybe that will spoil the exercise for me.
[00:04:09]
I don't know.
[00:04:10]
No, there are no spoilers.
[00:04:13]
And there are no like wrong answers and in code reading clubs either.
[00:04:17]
So I should also go back and say that we always look at a piece of code that is an open source
[00:04:22]
piece of code that is real, like in production somewhere.
[00:04:26]
We tend to try and use packages that we think a lot of people are using.
[00:04:30]
We look at all different languages.
[00:04:33]
The only constraint that we make is that the code should be like around 120 lines and we
[00:04:38]
don't do any editing.
[00:04:39]
So we don't take out any comments.
[00:04:41]
We don't take out any white space.
[00:04:43]
We don't do anything to it.
[00:04:45]
We just take it as it is out of GitHub.
[00:04:47]
And we have a tool in our code reading club website, which allows you to make a PDF out
[00:04:54]
of a piece of code in GitHub and another tool which allows you to annotate a piece of code,
[00:04:59]
which is another one of the exercises we do.
[00:05:01]
But so in terms of like the things that jump out at people, they can be like really trivial.
[00:05:06]
They can be some like comment block.
[00:05:08]
They can be a word.
[00:05:10]
Often if there's a word like Microsoft in there, then that jumps out at people.
[00:05:16]
Sometimes it's like a really long variable name or sometimes it's I mean, it's different
[00:05:21]
totally.
[00:05:22]
One thing is that beginners tend to look at the top of the page and read like if they
[00:05:28]
were reading like a natural language prose, whereas more experienced developers will like
[00:05:34]
try and like jump for the export or something like look for the return statement or like
[00:05:40]
dive into the middle of where something looks like a big nested loop or things like that.
[00:05:45]
Right.
[00:05:46]
Fascinating.
[00:05:47]
It makes me think of I recently read a really great book called The Inner Game of Tennis.
[00:05:52]
And one of the things it talks a lot about is sort of natural learning processes as opposed
[00:05:58]
to like sort of more top down learning where, you know, if you're trying to help somebody
[00:06:04]
with a tennis stroke, telling them every physical motion and describing it in great detail versus
[00:06:11]
having a high level tennis player hit some tennis balls and saying, watch this and repeat
[00:06:16]
after me, you know.
[00:06:18]
And this book talks a lot about, you know, looking at following the tennis ball or looking
[00:06:23]
at the seams of the tennis ball to really just bring your attention to specific places
[00:06:29]
and then trust the learning that comes from watching that and tapping into that rather
[00:06:36]
than just intellectually trying to overthink.
[00:06:40]
It's trying to tap into your subconscious because your subconscious is going to be able
[00:06:45]
to play a way better tennis game than your conscious brain.
[00:06:48]
And it seems like there's something here that maybe your subconscious is going to be able
[00:06:53]
to have more insights about code than your conscious brain.
[00:06:57]
Do you see that as part of it?
[00:06:59]
Yes, definitely.
[00:07:00]
And I wanted to go back and say that a lot of that.
[00:07:04]
So Felina wrote a book at the same time as we were developing the exercises for the Code
[00:07:09]
Reading Club.
[00:07:10]
And that book is called The Programmer's Brain.
[00:07:13]
And in the book, it details a lot of the theories behind the exercises that we developed and
[00:07:18]
also some of the exercises that we do, although we made them so the ones in the book are made
[00:07:23]
so that you can do them by yourself or do them like you can do them in pairs and things.
[00:07:28]
But the ones that we made for the club are deliberately like designed for like working
[00:07:33]
in a group.
[00:07:34]
Right.
[00:07:35]
So the book, it basically she set out to study what are the cognitive processes that happen
[00:07:41]
in your brain when you're trying to read code, because she started trying to teach children
[00:07:46]
to code and realize that.
[00:07:48]
Yeah, very, very cute.
[00:07:50]
Right.
[00:07:51]
Yeah.
[00:07:52]
Yeah.
[00:07:53]
It's a sad story how she got to that, because unfortunately, when she was doing her PhD,
[00:07:59]
she got a little bit slated by the programming community, which made her in her own words
[00:08:05]
cry, because she was she was tasked with making a domain specific language for the finance
[00:08:12]
industry by her PhD supervisor.
[00:08:16]
And she went and did all the research and found out that they already had one.
[00:08:19]
And it was called spreadsheets.
[00:08:21]
And it was working really well for them.
[00:08:23]
And she did her PhD on the on spreadsheets or programming.
[00:08:28]
And a lot of the programming community did not like that.
[00:08:32]
And so she took a whole different branch in her career and started thinking about the
[00:08:38]
cognitive processes and what she started thinking about teaching kids to code, because she thought,
[00:08:42]
oh, I know one thing I'm good at programming.
[00:08:44]
I can teach kids to do this and then found that she couldn't teach kids to do it because
[00:08:48]
there wasn't any good methodology for doing that as there is teaching and other things.
[00:08:54]
So the basis of the book and the basis of the exercise is like three parts of your brain,
[00:09:01]
like how brain process, which is your short term memory, your long term memory and your
[00:09:06]
working memory.
[00:09:08]
And your short term memory is about information.
[00:09:11]
And as we probably mostly know, you can only hold like very small, like amounts of information
[00:09:16]
in your head at one at any given time.
[00:09:19]
There's like a debate of whether it's like four or seven or something.
[00:09:23]
It's well researched.
[00:09:25]
But you can hold chunks of information.
[00:09:27]
And that's one of the things that maybe Dillon was alluding to.
[00:09:29]
I know it took me a long time to get here.
[00:09:32]
Back to your point.
[00:09:33]
But you can hold chunks of information, which are your previous knowledge and your previous
[00:09:40]
knowledge, your long term memory is like a network of related things.
[00:09:47]
So it's really good.
[00:09:49]
Like one of the things that Felina says is if you do deliberate practice in, for example,
[00:09:55]
learning syntax or learning like common patterns that we use, often programmers will think,
[00:10:01]
oh, I'll just look that up every time I know I can.
[00:10:04]
I know I can look that up on the Internet, so I don't need to memorize it.
[00:10:07]
But actually, what happens if you just look it up on the Internet is you end up going
[00:10:11]
down a very fascinating rabbit hole and all sorts of other things, probably.
[00:10:17]
And you're distracting yourself away from from like being in the flow of writing code.
[00:10:23]
And on top of that, you're also taking away from yourself the ability to be able to chunk
[00:10:29]
things and see like see the bigger picture.
[00:10:33]
If you have it memorized in your brain, then you'll be able to like more fluidly read the
[00:10:39]
code.
[00:10:40]
And so it kind of benefits you in both ways.
[00:10:43]
And one advice is like, if you must look it up, firstly, write down somewhere the things
[00:10:50]
that you're looking up and make flashcards out of them so that you don't keep looking
[00:10:55]
up the same things all the time.
[00:10:57]
And the second thing is, before you look it up, try and remember it.
[00:11:01]
Try and do it yourself, because that's how we make those.
[00:11:05]
I can't remember what it's called.
[00:11:08]
It's called something with elaborate.
[00:11:10]
I don't remember what it's called exactly, but it's how you make that retrieval to how
[00:11:13]
you make that connection to something else in your brain.
[00:11:16]
And we're very good at doing it like associations with experiences and things.
[00:11:22]
But we don't really think about doing it with programming, but it is the same thing.
[00:11:26]
And there's some research that says that your subconscious brain like holds everything you've
[00:11:32]
ever known and ever seen and ever, ever, ever.
[00:11:35]
But it's the fact that you can't retrieve it.
[00:11:37]
That is the problem.
[00:11:39]
It's the cache misses.
[00:11:40]
I don't know what that...
[00:11:42]
Well, your brain, your brain is...
[00:11:43]
Oh, the cache!
[00:11:44]
It's not in the cache, right?
[00:11:45]
It's in the cache.
[00:11:47]
I'm like, who is this cache misses scientist?
[00:11:50]
What are you talking about?
[00:11:53]
Yes, yes, the cache misses.
[00:11:54]
Miss and Mr. Cache.
[00:11:56]
Yeah.
[00:11:57]
Yes.
[00:11:58]
So, yeah.
[00:11:59]
So, if you try, if you try deliberately to remember or to like reproduce something or
[00:12:05]
remember something, even if you're doing it wrong, you're actually not training yourself
[00:12:09]
the wrong thing by guessing, which is maybe what it feels like you might be doing.
[00:12:14]
Or making a pathway in your brain so that next time you will be able to remember it.
[00:12:19]
To be able to access it faster.
[00:12:20]
Yeah.
[00:12:21]
Yeah.
[00:12:22]
I remember hearing that if you try to come to remember like a word and you know you have
[00:12:28]
it on the tip of your tongue and you try to recollect it and someone gives you the answer,
[00:12:34]
then you're not going to remember it for the next time.
[00:12:37]
So if you come, if you try to remember it and then you succeed, then you just made a
[00:12:44]
pathway where it will be easier to remember next time.
[00:12:46]
But if someone tells you the answer, then you won't.
[00:12:50]
I don't know if that's true, but I've heard it.
[00:12:53]
I should look up the research somehow.
[00:12:55]
Yeah.
[00:12:56]
I mean, I think that, I mean, that makes sense with what little I know about the brain process,
[00:13:03]
which is what I've all learned from Felina and her book and talking to her.
[00:13:08]
So one of the problems that you hit in programming is that this long-term knowledge, if you don't
[00:13:13]
have knowledge about the domain or if you don't have experience in programming this
[00:13:18]
specific pattern from before, then that will stump you.
[00:13:24]
That will take up all your cognitive process when you're trying to work it out.
[00:13:29]
And the working memory is where you're actually trying to process or calculate something as
[00:13:36]
you're reading it.
[00:13:37]
So when you're going through reading code, you can do what's called a cognitive refactor
[00:13:44]
to try and like split things out separately so that they're in small chunks that will
[00:13:50]
help you be able to process like each small chunk.
[00:13:53]
And that's one of the reasons why Elm is really great as well, because it encourages you to
[00:14:01]
write in ways that are really easy to process in our tiny brains.
[00:14:07]
Right.
[00:14:08]
So I do really want to get into this topic of why Elm is easier to process in some ways,
[00:14:14]
but let's put a pin in there for a second because I'm still really fascinated by this,
[00:14:21]
you know, retrieval and chunking and stuff.
[00:14:25]
So I read once about a study they did with chess players where they took...
[00:14:31]
It's in the book.
[00:14:32]
Are you familiar?
[00:14:33]
Yeah, it's in the book.
[00:14:34]
Oh, cool, cool, cool.
[00:14:35]
Yeah.
[00:14:36]
Yeah.
[00:14:37]
So the gist of it is that they took, from what I remember of the study, it was like
[00:14:43]
you take very skilled chess players and then some lower level chess players and you put
[00:14:49]
a chess position in front of them for however long and then take it away and then ask them
[00:14:55]
to set up and recreate the position on the board.
[00:14:58]
And what they found was that, as you would imagine, the much more experienced skilled
[00:15:05]
chess players performed far better than the less experienced chess players.
[00:15:10]
But then it actually changed when they started showing them positions that were nonsensical
[00:15:16]
because pawns would legally not be able to arrive at certain positions or certain, you
[00:15:22]
know, rooks like to be together in the same rank or file, but they weren't.
[00:15:28]
And maybe there are two dark squared bishops or things that just don't make sense in a
[00:15:35]
chess game.
[00:15:36]
And suddenly they were equalized.
[00:15:38]
The less experienced and the more experienced chess players were equalized.
[00:15:42]
And the moral of the story being that basically the advanced chess players were chunking these
[00:15:50]
things into high level groupings.
[00:15:52]
So they were noticing dynamics instead of piece by piece, remembering where each piece
[00:15:57]
was.
[00:15:58]
They know, oh, this is a fianchetto position and the knight is, you know, the king is castled
[00:16:04]
kingside and this looks like a Sicilian, you know, things like that.
[00:16:09]
They were just one high level concept in their brain that was easily retrievable.
[00:16:14]
Whereas the less experienced players were just looking at every single piece on the
[00:16:17]
board.
[00:16:18]
So I think that there is a clue there about how to get better at reading and writing and
[00:16:26]
maintaining code, which is, you know, having these shorthands and these ways to think in
[00:16:33]
higher level terms.
[00:16:35]
So as you said earlier, Katya, you can't increase the number of items in your short term memory
[00:16:42]
that you're able to hold, but you can learn to think in higher level terms and equip yourself
[00:16:48]
with some high level concepts that allow you to navigate a particular area.
[00:16:55]
Well, it might allow you to navigate a regular chess board, but not an abnormal chess board,
[00:17:01]
but that's okay for a real game of chess.
[00:17:03]
So in Felina's book, as I said, she does give that as an example of chunking.
[00:17:08]
And there have subsequently been some people doing software, like research with software
[00:17:13]
developers in chunking.
[00:17:15]
And yes, if you use familiar patterns, and if you use more high level, like functions,
[00:17:25]
like mapping rather than for loops, then you will take away some of the cognitive issues
[00:17:31]
that people will have when they're trying to process reading code.
[00:17:35]
There's been specific research on that?
[00:17:37]
Yes.
[00:17:38]
Yeah.
[00:17:39]
That's kind of cool.
[00:17:40]
So like more a more declarative style?
[00:17:43]
Yes.
[00:17:44]
That definitely resonates with my experience, but I am highly biased.
[00:17:51]
I was wondering if you wanted me to go back to the code reading club exercises, because
[00:17:58]
I only mentioned like the first one, and I just wonder, there's about 10 that I can just
[00:18:05]
use over and over again, and I can maybe just give like a really quick explanation.
[00:18:12]
I didn't know how much time you wanted me to take on specifically like what happens
[00:18:16]
in a code reading club versus like, what happens when you read code?
[00:18:21]
I'm interested in both.
[00:18:24]
I'm very interested in like how to apply these things to actually get better at reading code.
[00:18:30]
Yeah, that sounds great.
[00:18:31]
Yeah, and writing and writing code, which is one of the like side effects.
[00:18:35]
And one of the very exciting side effects that happened was making people aware of how
[00:18:43]
to write more readable code for the like diverse teams.
[00:18:48]
I would say that is a controlled effect.
[00:18:51]
A managed effect?
[00:18:52]
Yeah, not a side effect.
[00:18:55]
Because you meant for that to happen.
[00:18:58]
I didn't.
[00:18:59]
It was totally unexpected, and I don't know how to process puns.
[00:19:07]
Rolling your eyes like you just did is perfect.
[00:19:12]
That is the intent.
[00:19:14]
Great.
[00:19:15]
So there wasn't a side effect.
[00:19:19]
So as I said before, like all the exercises are designed so that you do them individually,
[00:19:23]
and then you come back and discuss what you like, what the experience was like for you.
[00:19:28]
And the amazing thing that happened was that that obviously makes people who are in the
[00:19:32]
group much more empathetic with the other people who are in the group.
[00:19:37]
And they start asking questions like, oh, so if I wrote it like this, it would be easier
[00:19:42]
for you to read.
[00:19:43]
And then the person says, yes, it would.
[00:19:45]
And they say, oh, well, then I'll write it like that from now on.
[00:19:49]
And that's been really very cool.
[00:19:52]
So the exercises start out by, as programmers, we are always wanting to figure things out,
[00:20:00]
right?
[00:20:01]
Like solve the puzzle, figure out the problem.
[00:20:02]
And so when you put a piece of unseen code in front of a programmer, they're immediately
[00:20:06]
like, I want to crack this code.
[00:20:08]
And so we try and step back from that and explain that we are trying to learn like deliberate
[00:20:15]
techniques, practices that we don't use every day.
[00:20:19]
You already know how to Google things.
[00:20:21]
You already know how to use a syntax highlighter and like your ID, because that's one of the
[00:20:26]
other things that we always look at, just black and white code.
[00:20:29]
So or any color, but like two tones.
[00:20:33]
So and people question that to begin with.
[00:20:36]
But it is training your brain in a different way to just look at the code.
[00:20:40]
And one of the really cool things as well, when we first started was we printed things
[00:20:45]
out on paper.
[00:20:46]
This is before the pandemic, when we did all of our clubs in person.
[00:20:50]
And it really does change the way that your brain processes what's on the page.
[00:20:55]
It's amazing.
[00:20:56]
Like, I know my brain, when I look at it on my computer screen, my brain's constantly
[00:21:00]
trying to like process it and make it like evaluate, right?
[00:21:04]
When I look at it on a page, like I guess people get it from reading textbooks about
[00:21:08]
computer programming.
[00:21:09]
It's a very different, it's just a different part of your brain, I think that's acting
[00:21:14]
on it.
[00:21:15]
So would you say that highlighted code is easier to read or worse to read?
[00:21:20]
I think that it's different to read.
[00:21:22]
And I think that it makes it makes it more dynamic in your mind.
[00:21:27]
What do you mean with dynamic?
[00:21:29]
So it makes it like that the code is evaluating, it makes it like that the the actors in like
[00:21:34]
the words have more properties than just being a word.
[00:21:38]
And there's there's from a long time ago, and I think it was maybe in the 70s, there,
[00:21:43]
there's a video that someone showed me of a person who was experimenting with making
[00:21:49]
annotations in IDEs that were for reading code that's different to the ones that you
[00:21:54]
use when you're writing code.
[00:21:57]
And that is a cool idea for me, like, that's one of my like, side side side projects in
[00:22:02]
the future one day, you know, when I get to be retired.
[00:22:08]
That I will look at because that is fascinating.
[00:22:10]
And if there's a lot of research now happening on what will help us read code, that I can
[00:22:16]
I can apply that research to this like switching editor of like, now I'm writing now I'm reading,
[00:22:22]
what different things would you want highlighted?
[00:22:24]
You know, you don't have to wait until retirement.
[00:22:27]
It's called open source, you just need to spend hours and weeks working, right?
[00:22:32]
It's fine.
[00:22:33]
Exactly.
[00:22:34]
Yeah.
[00:22:35]
But I already have some other things like code reading club that I have to do in my
[00:22:39]
spare time.
[00:22:40]
Yeah, so so really, I keep getting distracted.
[00:22:43]
But in terms of the exercises, we start off by just looking at words in isolation or a
[00:22:49]
line in isolation.
[00:22:50]
So there's one exercise, which is random line where we just select a random line in the
[00:22:54]
code.
[00:22:55]
And then we think about what that line means on its own, and how it relates to the other
[00:23:00]
lines around it.
[00:23:02]
And one of the themes of code reading also is about which things are specific to the
[00:23:07]
domain of the program and which things are knowledge that you need from computer science,
[00:23:13]
or or from so.
[00:23:15]
So that's one thing that that your brain will hit when you're trying to read code, because
[00:23:18]
we always read the this code out of context.
[00:23:21]
So people won't even know what domain it's in.
[00:23:25]
And sometimes words get very, like people have misconceptions about like that a word
[00:23:30]
is referring to a specific thing, when by the time you finish the club an hour and a
[00:23:37]
half later, you realize that that is not the not what that word meant at all.
[00:23:42]
I can't think of a specific example right now.
[00:23:46]
But that that happens pretty frequently.
[00:23:49]
Cash missing is a perfect example.
[00:23:52]
That in itself was a cash miss.
[00:23:58]
So I guess yeah, so the thing that we're trying to do at the start of the club in the first
[00:24:03]
half is looking at what are the stumbling, like what are the building blocks and what
[00:24:07]
are the things within those building blocks that are going to make it really difficult
[00:24:10]
for you to process or different people in the room to process.
[00:24:13]
So another thing we look at is syntax, just asking people to highlight things that look
[00:24:18]
confusing to them, things they don't understand.
[00:24:20]
And then other people in the room can say, oh, that looks similar to what happens in
[00:24:24]
this language.
[00:24:25]
Maybe it's this.
[00:24:27]
One of the things that that really trips people up a lot is types in TypeScript.
[00:24:32]
If they're a JavaScript programmer who's never done TypeScript before, they get really confused
[00:24:38]
about what where the types are declared.
[00:24:41]
Whereas when you do Elm code, nobody gets confused about where the types are.
[00:24:47]
So that's that's one that's one thing.
[00:24:50]
But yeah, so we look at the syntax and then we don't we don't the facilitator will not
[00:24:57]
participate in a way of answering questions.
[00:24:59]
They just participate in facilitating the conversation in the room.
[00:25:03]
So we do that.
[00:25:04]
People make make wrong declarations and and just let it sit because you're working with
[00:25:11]
the knowledge of like everyone's on the same same playing field, as it were.
[00:25:16]
People have previous knowledge that helps other people.
[00:25:19]
Right.
[00:25:20]
Yeah.
[00:25:21]
It seems like there's a lot of the like diverge type activity where you're just like, let's
[00:25:26]
not start limiting and constraining the ideas we're going to explore.
[00:25:31]
Let's get everything we're noticing on the table and opening your your mind, because
[00:25:37]
what happens a lot like I actually used to used to run a learn to code meetup in my hometown.
[00:25:44]
And and so I would observe a lot of people who were brand new to coding going through
[00:25:50]
the process of debugging something or trying to make some code work.
[00:25:56]
And what I noticed was happening a lot, like one of the biggest stumbling blocks I saw
[00:26:01]
was just not trying something without having a theory of what was going on.
[00:26:10]
So like debugging and just typing some code, I would try to get people in the habit of
[00:26:15]
saying like, OK, before you type something, what do you think is causing the problem?
[00:26:21]
And what's your hypothesis?
[00:26:23]
Like what do you believe is causing the problem and how will you evaluate the change that
[00:26:29]
you're about to make?
[00:26:30]
How would you expect that to have an effect if that is the source of the problem or if
[00:26:35]
it's not the source of the problem?
[00:26:37]
But that type of thinking that what that wasn't the comfortable process that people.
[00:26:42]
So I'm not sure if there's any, you know, connection there with with reading code, but
[00:26:47]
just have it making your intentions more clear.
[00:26:50]
I thought it was really powerful and also that opens you up to more possibilities because
[00:26:56]
you can get very tunnel visioned on one specific line and not can.
[00:27:01]
So it's a good thing to step back first and say, well, what are the possibilities here?
[00:27:05]
There is currently a project that I'm trying to refactor where there is a type that I don't
[00:27:11]
understand.
[00:27:12]
It's it deals with parsers and it's too complicated for me.
[00:27:17]
And right now what I'm doing is I'm changing the type, trying to change the type to do
[00:27:21]
something else.
[00:27:22]
And then I get compiler errors.
[00:27:24]
And that tells me a little bit more of what is going on, like what it is trying to do,
[00:27:28]
what it what the type is for.
[00:27:32]
And I'm again, a little bit more understanding every time I try it out.
[00:27:37]
But yeah, so I make a change and then I try to understand what I discovered.
[00:27:42]
So are you are you saying that you're doing the thing that Dillon was discouraging in terms
[00:27:48]
of you're just trying something because you can't you don't even know where to start in
[00:27:53]
terms of figuring out a hypothesis in a way.
[00:27:56]
But in this case, I have a compiler that helps me.
[00:28:00]
Which compiler would that be?
[00:28:02]
Maybe a long compiler, who knows?
[00:28:06]
Out of...
[00:28:07]
Lucky you.
[00:28:08]
But yeah, like if this was JavaScript, like no, this is not helpful.
[00:28:15]
Maybe tests would help.
[00:28:17]
But yeah, otherwise, not the way to go.
[00:28:20]
It's really because I really don't understand the code.
[00:28:22]
I'm just trying whatever and see what what sticks.
[00:28:25]
So this is like a little bit tangential.
[00:28:28]
But one of the one of the things that inspired me to start Code Reading Club was this practice
[00:28:33]
of rewriting other people's code.
[00:28:36]
So I found a lot that there would be a new person on the team who would be given a feature
[00:28:43]
to write or a bug to fix and they do it.
[00:28:46]
And then the person who does the code review was like making a suggestion to say, why don't
[00:28:53]
you just do it this way instead of actually bothering to read what the person had written?
[00:28:58]
Or even worse than that, not even like letting it through the review process.
[00:29:02]
And then in the next feature that's being made by the person who's been on the team
[00:29:07]
a longer period of time, they're like sneaking in like a whole refactor on the code that
[00:29:12]
the other person had had successfully submitted and was working and had gone through the review
[00:29:17]
process.
[00:29:18]
And that to me is is a lot of because we practice writing so much.
[00:29:25]
That's what we feel confident and comfortable to do.
[00:29:28]
And we don't practice reading enough to feel confident and comfortable to talk about and
[00:29:34]
reason about what things that exist already mean.
[00:29:38]
Something that I've learned from Dillon and from Llewellyn Falkor's talks is refactoring
[00:29:46]
to understand code as well.
[00:29:49]
So if something is too complex or does something odd, then you refactor, you chunk it, you
[00:29:55]
rename things, you inline things, you outline, extract things.
[00:30:02]
Should be outline in order to understand it.
[00:30:07]
Yeah, so this is what Felina calls the cognitive refactor.
[00:30:11]
And the way that she promotes it is that you should do it if you're new to a project or
[00:30:17]
if you're new to programming, but you should also change it back if it was more maintainable
[00:30:23]
the way it was before.
[00:30:24]
Yeah, that's right.
[00:30:25]
You have to think you have to think about it.
[00:30:27]
But sometimes you're making it more maintainable by doing it.
[00:30:31]
And again, I know we're not allowed to talk about Elm for some reason yet, but we are.
[00:30:35]
There's so much we can talk about there.
[00:30:39]
But that is another like, really, really, really, really beautiful, amazing thing about
[00:30:44]
Elm in terms of all the things that I'm trying to promote with Code Reading Club, which is
[00:30:48]
that if you need to rename a variable because the thing has changed or you need to rename
[00:30:53]
a function because the thing that you're doing has changed, it's not scary.
[00:30:58]
And so you don't get these legacy like naming things where people have just left it because
[00:31:03]
they're worried about what is going to happen that they can't see, which is which is one
[00:31:07]
of the things that makes Elm like so much more readable on the surface than other languages.
[00:31:13]
So I'm curious about this because I as we're talking about some of these things, I definitely
[00:31:17]
find like for my understanding of code, I am pretty dependent on syntax highlighting,
[00:31:24]
you know, changing code, like using refactoring tools to change code to understand it better,
[00:31:31]
doing go to definitions and navigating to test files and things like that.
[00:31:36]
So I do find if I'm looking at a static piece of paper and it doesn't have highlighting
[00:31:42]
and I can't navigate to definitions and tests, that's definitely out of my comfort zone.
[00:31:47]
Like my brain definitely wants to go jump to things and do things with the code.
[00:31:53]
But so like what are some of the benefits of like specifically developing that skill?
[00:31:58]
It makes you quick, it makes you quicker at programming because you're not getting that
[00:32:05]
fundamental thing of like the distraction.
[00:32:07]
So you're going to another file and looking at the test, you're going to look at a function,
[00:32:11]
you'll go you you get faced with a bunch of imports at the top and you think, oh, I must
[00:32:15]
understand all the details about all of these imports, where they're coming from.
[00:32:19]
Whereas this like allows you really to just focus on the thing that you're looking at
[00:32:23]
right now.
[00:32:24]
And this is a very good time for me to like go into the next level of exercise.
[00:32:28]
So those ones at the beginning are the ones where we're looking at things in isolation.
[00:32:32]
And the last one of those exercises is about naming.
[00:32:36]
And I could probably talk about the naming stuff for a really long time.
[00:32:40]
And Felina is in fact doing a lot more research about naming at the moment.
[00:32:44]
And there are other other computer scientists who are doing or have done lots of research
[00:32:49]
about names.
[00:32:50]
But the naming exercise that we do is just highlighting all the things that a developer
[00:32:55]
made up a name for.
[00:32:56]
So basically everything that's not like a keyword, you're highlighting that in the code.
[00:33:03]
And then you're thinking about how those things are related to each other.
[00:33:09]
If there's any patterns that you notice or any anomalies.
[00:33:12]
And there was a piece of code that we were looking at in the last club I did, where there
[00:33:16]
was one function, which had all single letter variable names.
[00:33:21]
And all the rest of the code was very like verbose.
[00:33:24]
And all the variable names were very verbose.
[00:33:26]
And we had some fun like trying to think about how did that chunk of code get in there.
[00:33:31]
We ended up probably that it was from cut paste from Stack Overflow.
[00:33:36]
And that they didn't bother changing the variable names.
[00:33:39]
But we don't know.
[00:33:41]
We could because we always use code in GitHub, we could have, after the fact, looked it up.
[00:33:47]
I got distracted.
[00:33:48]
So I never ended up trying to find the source of truth.
[00:33:51]
It could have just been a different developer.
[00:33:52]
It was also something that was like it was a for loop or something.
[00:33:55]
There was something some other reason why it might have been used like that.
[00:33:59]
But back to just naming things.
[00:34:01]
So then you see, look at all the names and you try and start thinking about like, which
[00:34:05]
ones are specific to the domain that we talked about before, or which ones are programming
[00:34:10]
computer programming concepts or math concepts that you know from other parts of your knowledge.
[00:34:15]
And then this is also one of the first things that made me want to do this with development
[00:34:20]
teams, which is that you can actually come up with a set of guidelines for your team
[00:34:25]
for naming so that you don't have like snake case and camel case in the same code base.
[00:34:29]
Of course, Elm like solves that problem for us.
[00:34:32]
But in other programming languages, you do have those choices and you do have a mixture
[00:34:38]
of both.
[00:34:39]
And there is I'm probably going to get this wrong, but there is some research which maybe
[00:34:43]
Evan knows about that camel casing is much less error prone to read.
[00:34:49]
It takes you a little bit longer than snake case, but it but it has like a lot higher
[00:34:57]
cognition after you've read it.
[00:35:00]
So camel case is the what we use in Elm usually.
[00:35:05]
Snake case is the one with underscores.
[00:35:07]
Yes.
[00:35:08]
OK, I was going to bring this up and I my memory says that it was the opposite.
[00:35:14]
The snake case was actually easier to understand.
[00:35:17]
It's quicker to read according like, yeah, I mean, maybe maybe we need to look this up.
[00:35:23]
Maybe I'm wrong, but I haven't looked it up in a year or so.
[00:35:27]
It's quicker to read snake case, but it's you get the wrong idea more often.
[00:35:32]
Oh, you have the wrong concept in your head more often.
[00:35:36]
And there's a lot of things that Felina talks about as well, which are just like very simple.
[00:35:41]
Like if you if you ever use abbreviations or you never use abbreviations or because
[00:35:47]
sometimes I see code a lot where you start at the top of the function and then like an
[00:35:52]
outer layer of the function with a full word like object and then it turns into OBJ as
[00:35:57]
you start processing it and then you do a little bit more and it turns into O at the
[00:36:00]
end and it's the same thing that's flowing through.
[00:36:04]
But it's really difficult, like it takes so many extra steps for your brain to to like
[00:36:09]
process that it's the same thing that's flowing through.
[00:36:13]
And yeah, you can just make you can make rules in your team to like always put like the word
[00:36:18]
max or min at the start of your variable name instead of the end of your variable name.
[00:36:22]
Because again, every time you come across it in the other way, it trips you up.
[00:36:26]
Whereas if you get used to certain patterns, which again is the thing in Elm that is like
[00:36:31]
very like across lots of different packages in the you know, and the community as a whole,
[00:36:37]
there's a lot of naming conventions that have just kind of stuck that people use, which
[00:36:42]
you get used to when you when you work on different projects.
[00:36:45]
And it's really nice that the whole community has like, almost is starting to come up with
[00:36:49]
its own sort of naming conventions that that you can rely on.
[00:36:55]
Right.
[00:36:56]
I think there's also in what we're discussing here, like there's, there's this underlying
[00:37:02]
idea that that small cognitive costs add up in aggregate to a larger cognitive cost, which
[00:37:12]
I think some people's intuition might be like, hey, it's just just a little abbreviation.
[00:37:20]
How is that really going to slow me down?
[00:37:22]
Or is that really the bottleneck to understanding code, but I certainly am of the opinion that
[00:37:30]
like these tiny cognitive costs, you know, compound, and that also, these tiny micro
[00:37:40]
skills that we can develop, can combat that and break down and make us stronger.
[00:37:46]
So small costs accumulate, and small skills build up to make us better at dealing with
[00:37:53]
those things.
[00:37:55]
I would definitely agree with that.
[00:37:57]
And the more that I've done code reading, the more I start to reflect that that's the
[00:38:02]
other thing that it does for you is it makes you start reflecting on everything you read
[00:38:07]
and everything you write.
[00:38:10]
And you can feel those like, you can feel those cognitive like bombs when you see them.
[00:38:16]
Yeah, it's kind of like you hear people talking about this with productivity, too.
[00:38:21]
It's like, do you do you get clear on the big priorities in your life?
[00:38:27]
Or do you get clear on like, the email that you need to send today and the bill you need
[00:38:32]
to pay today?
[00:38:34]
Like which one do you do first to get more clarity?
[00:38:37]
Like which one is more important, right?
[00:38:39]
It's like, well, what could be more important than the meaning of my life?
[00:38:42]
It's like, well, but if you're drowning in like, a bill you need to pay today that you
[00:38:47]
might forget, maybe you're not going to do such a great job thinking about the meaning
[00:38:51]
of your life.
[00:38:52]
So similarly, people think about like the high level architectural patterns of their
[00:38:56]
code and stuff.
[00:38:58]
And these little, little spots that add a little cognitive load can be forgotten, because
[00:39:04]
it's like, well, first, let's get the architecture right.
[00:39:07]
But I think there's value to just starting with those little cognitive burdens.
[00:39:11]
Yeah, definitely.
[00:39:13]
And the other thing about just to bring Elm back into it again, is that there's so many
[00:39:17]
architectural patterns that are just well established within the community, because
[00:39:21]
there's only like a fixed number of ways you can do things that that that whole burden
[00:39:26]
is taken off you.
[00:39:27]
And if you even if you like, I always start with a totally different architecture than
[00:39:32]
the one that I finished with, or that or like, oh, I guess I'm never finished, but like it
[00:39:36]
transforms over time.
[00:39:38]
And with Elm, it's such a low overhead to like keep changing your whole data model to
[00:39:42]
keep changing the whole way that you know, the whole way the architecture is set up.
[00:39:47]
It's such a low burden to do that, that you can focus on those little cognitive wins,
[00:39:51]
I guess is what you were calling them.
[00:39:54]
Yeah.
[00:39:55]
Right.
[00:39:56]
So you talked about like, these, you know, domain concepts and names, and then like,
[00:40:02]
computer programming concepts, or computer science concepts, would sort of like, fmaps,
[00:40:09]
and monads and things like that, fit into the category of computer science concepts?
[00:40:16]
And would that be like, is there any research on readability for concepts like that being
[00:40:23]
used heavily?
[00:40:25]
Maybe there's not that.
[00:40:26]
Yeah, I'm thinking I don't know the research that Felina that you know, that I'm familiar
[00:40:33]
with Felina is just around programming patterns in general, and that it is easier when you
[00:40:40]
recognize when you recognize a pattern, because you because you know it, and it's worth studying
[00:40:46]
them in terms of like, specifically functional, like, I guess what you're talking about is
[00:40:52]
like, almost like pieces or tools that you can that you can leverage.
[00:40:58]
I suppose one problem, one thing for me would be like, if you called if you called monads
[00:41:05]
my monad, then that would be a cognitive bomb for me, because then I'd have to start thinking
[00:41:10]
about what's a monad, what's a monad, what's a monad, every time I saw it.
[00:41:16]
But I think that's like a different that that's a totally different conversation.
[00:41:19]
Right?
[00:41:20]
Yeah.
[00:41:21]
And I think it's like Haskell, the Haskell and Elm communities have like arrived at at
[00:41:27]
opposite perspectives here, where the Elm community has said, let's use domain terms
[00:41:34]
here, whatever the terms are in your domain.
[00:41:37]
And let's sort of not talk about the fact that this is a functor, even though it's like
[00:41:42]
a thing that you map, let's just use, let's try to use the word map most of the time when
[00:41:48]
we're doing that type of thing, but let's not talk about this abstract idea, because
[00:41:54]
beginners can get hung up on it.
[00:41:56]
So let's not use those that technical jargon.
[00:41:58]
So it's just very interesting how those two communities have arrived at opposite conclusions
[00:42:04]
there.
[00:42:05]
Yeah.
[00:42:06]
And I think in terms of the readability and the cognitive load, you're you're coming with
[00:42:09]
a whole bunch of baggage when you use the word functor, or you use the word monad.
[00:42:14]
And if you're just using the thing that's specific, the concept that's specific to the
[00:42:20]
thing that you're writing about, then that's that is easier for you to understand that
[00:42:25]
the name, it's not Felina's research, I can't remember who it is.
[00:42:28]
But there is some research on how to design well, like how to well design names, how to
[00:42:34]
choose good names.
[00:42:36]
There's some research and I always get this wrong, it's in my code reading club, which
[00:42:40]
is that like only 7% of the time, would you come up with the same name as your colleague,
[00:42:45]
if you have no conventions together.
[00:42:47]
So it's a it's a huge field, obviously, naming is famously difficult, right?
[00:42:53]
But this the way to come up with a good name is I'm going to try and remember it's three,
[00:42:58]
there's three steps.
[00:42:59]
One is that you need to identify what concepts you're trying to get across.
[00:43:03]
The next is to think about what words you want to use for those concepts.
[00:43:08]
And then the next one is to arrange those words in a meaningful way.
[00:43:12]
So it's like that's very abstract.
[00:43:14]
But if you if the middle part of that the the concepts mapping to words bit is like
[00:43:20]
a glossary that you define with your domain that you can even put with your code, like
[00:43:25]
this is how we refer, it would solve a surprising number of of those where like the two different
[00:43:32]
people are calling a person person and someone else is calling it human or whatever those
[00:43:37]
kind of that's a huge cognitive burden if you're referring to the same data in your
[00:43:42]
program and someone's calling it humans and someone's calling it person.
[00:43:47]
What choices like, oh, we tend to use verbs in the present tense, the naming choices,
[00:43:55]
would that be part of the second step as well?
[00:43:58]
Yes, yes, I think.
[00:44:00]
Yeah.
[00:44:01]
So so yeah, the first step is like, what concepts do you need to get across with this?
[00:44:04]
Like, what is what is this thing actually doing?
[00:44:07]
And then and then what words are you going to use to describe and that would include
[00:44:10]
the tense of those words.
[00:44:13]
It's just reminded me as well, like way back in the beginning of my code reading club journey.
[00:44:18]
Another one of the surprises that we discovered was that if you so sometimes we use code reading
[00:44:25]
club exercises as an interview technique to just to start to understand where a person's
[00:44:31]
at in their knowledge around not just programming, but just generally, you know, how would they
[00:44:38]
how would they be able to process this code?
[00:44:41]
And one of the things that happens when you ask, so I'm like segueing a little bit because
[00:44:50]
I'm remembering I'm remembering the whole the whole story.
[00:44:53]
I'm doing like the joke backwards, right?
[00:44:56]
Great, so yeah, I won't I won't be upset when you don't laugh at the end.
[00:45:04]
So if you if you assign a new person to your team, a problem, and you tell them what to
[00:45:11]
call the things in it, you refer to the parts of it in name, you won't learn as much about
[00:45:18]
what they understand.
[00:45:19]
So if you don't, if you resist the temptation to tell them what the parts of it are called,
[00:45:26]
and you let them name it themselves, then you will understand you will see like how
[00:45:31]
much understanding they have about the thing that they're writing.
[00:45:34]
So what happens to me often is I'll write a function or name a variable.
[00:45:39]
And then 10 minutes later, I'm like, that is not what that thing is at all or what it's
[00:45:45]
doing or what I need that function.
[00:45:47]
And then I'll rename it.
[00:45:49]
And when you get a new person on the team to do to do that process, and they they maybe
[00:45:54]
don't get to the part where they're renaming it because they haven't quite understood where
[00:45:58]
it sits and what its purpose is.
[00:46:01]
That is really fascinating.
[00:46:02]
Also, I like my backwards joke.
[00:46:03]
I hope that makes sense.
[00:46:04]
Yeah.
[00:46:05]
I'm a big fan of a series of blog posts that Arlo Belshi wrote, where he talks about it's
[00:46:16]
called naming is a process.
[00:46:18]
I think one of the ideas in there is that like, basically, just acknowledging that a
[00:46:25]
certain chunk of code is a coherent idea, it can be step one.
[00:46:32]
And he talks about giving it nonsense, nonsense names like he uses applesauce, basically a
[00:46:38]
name that it's clear you are going to need to loop back around and change because it's
[00:46:42]
not connoting anything.
[00:46:45]
It has no meaning, except that it's like this anonymous thing.
[00:46:49]
So it's basically a way to clearly mark that this is an anonymous thing that doesn't yet
[00:46:55]
have a meaningful name, but it is a meaningful group of behavior.
[00:46:58]
That is, that's very cool.
[00:47:01]
Yeah.
[00:47:02]
So I like that idea a lot.
[00:47:03]
And I use that in like in refactoring, I'll often just be looking at some code and be
[00:47:09]
like, Oh, yeah, this does look like a paragraph.
[00:47:11]
You can even like add some white space between a few sets of things that might seem like
[00:47:16]
they're grouped, should be grouped separately or you know,
[00:47:20]
But then elm format takes it away again.
[00:47:23]
I was thinking the same thing.
[00:47:24]
That's true.
[00:47:25]
You couldn't put a comment and in that case, you will space it out.
[00:47:30]
Right, exactly.
[00:47:32]
Exactly.
[00:47:33]
Yeah.
[00:47:34]
And you can just start extracting some things and, you know, give them meaningless names.
[00:47:40]
So that's a good first step.
[00:47:41]
Yeah, that's a really good technique to like unblock yourself, right?
[00:47:45]
Exactly.
[00:47:46]
Exactly.
[00:47:47]
We don't always know what we're writing.
[00:47:50]
Exactly.
[00:47:51]
Yeah, I think of it like my cognitive pulleys because, you know, it's a technique that allows
[00:47:58]
you to distribute force over a greater distance.
[00:48:02]
So you have to exert less force over more time, because sometimes it's too much of a
[00:48:09]
heavy lift to just do in one step.
[00:48:12]
You don't know the end result you want, but you know the direction you want.
[00:48:16]
So you can just start pulling in that direction.
[00:48:19]
So let's talk about elm.
[00:48:21]
No.
[00:48:22]
Okay.
[00:48:24]
What's been your experience in these code reading clubs with people looking at elm code
[00:48:31]
versus other languages?
[00:48:33]
One of the problems is that the exercises were designed to get people to think about
[00:48:40]
things in terms of classes and functions and variables.
[00:48:46]
So one of the exercises that we do after the listing names one is where you then start
[00:48:53]
highlighting where things are declared and where they're used.
[00:48:55]
So you can see how the data flows through the program.
[00:48:58]
And that exercise is often problematic with the elm code.
[00:49:03]
Apart from you can see where like functions and values are, well functions, where you
[00:49:09]
can see where all the functions are declared, and then you can see where the functions are
[00:49:13]
used.
[00:49:14]
But there's not as much interesting things that happen with that.
[00:49:20]
Yeah.
[00:49:22]
Inheritance hierarchies and things like that.
[00:49:24]
Yeah.
[00:49:25]
So a lot of the problems that Felina like uncovered in her cognitive research are not problems
[00:49:31]
in elm.
[00:49:32]
And so something like this exercise is designed for a code which has those problems.
[00:49:40]
Identifying like potential mutation that's happening in places or identifying like how
[00:49:48]
it's basically like how the data flows through the code and like hotspots.
[00:49:52]
So like if you have like nested for loops and things like that, where you start to get
[00:49:58]
like super deep into something, these those exercises will highlight like where areas
[00:50:03]
of the code that look particularly complicated to process are.
[00:50:08]
And elm comes out very flat in that type of analysis.
[00:50:14]
It's already done the hard work for you.
[00:50:15]
It's like, where does the code change?
[00:50:18]
Update and yeah.
[00:50:19]
Yeah.
[00:50:20]
Yeah.
[00:50:21]
And often because we're also just looking at single files.
[00:50:24]
I do with elm choose and I don't do this with any other language, actually.
[00:50:29]
I choose like example files or where where someone's like showing you the whole the whole
[00:50:38]
functionality rather than like actual elm files.
[00:50:43]
Firstly, because elm files do tend to be like really long and I'm looking for things that
[00:50:46]
are less than 120 lines, but also because you don't get as much meaningful analysis
[00:50:53]
from many of the elm files as you do from other languages where where things are kind
[00:51:00]
of grouped together in different ways, I guess.
[00:51:02]
And maybe I need to select different exercises because you definitely get interesting variable
[00:51:09]
naming conversations.
[00:51:11]
And like I said before, it's very obvious where the types are.
[00:51:14]
And there's there's a concept of beacons, which are things that you put in the code
[00:51:23]
or things that are in the code that help a person frame what's happening.
[00:51:28]
And like variable names can be beacons or comments can be beacons or function names
[00:51:33]
and things like the update function being a beacon for like, OK, this starts this section
[00:51:40]
where we update the model.
[00:51:42]
Is that the kind of beacon you're thinking of?
[00:51:44]
Yes, and maybe not.
[00:51:47]
So like the update function, that's more of a convention of a pattern to like to know.
[00:51:54]
So you know that that's where the updates are going to happen.
[00:51:59]
Beacons are more like helping take like helping give the person a hint of like, what's that
[00:52:04]
thing in their brain that they should be connecting this to?
[00:52:08]
Like what what are I'm always like struggling to come up with examples, but it's it's like
[00:52:17]
a hint about.
[00:52:20]
So what I was going to say is that the variable names in Elm are often like so descriptive
[00:52:24]
and explicit and specifically formed within like known patterns that they can be like
[00:52:32]
really good beacons.
[00:52:34]
The idea of these exercises that that look at hotspots for mutation and things like that,
[00:52:39]
it actually it's interesting because it it does remind me of something in the context
[00:52:43]
of Elm that Richard Feldman gave a really nice talk called Scaling Elm Apps.
[00:52:50]
And one of the key points there was basically like, just make the you know, make the type
[00:52:56]
annotation for a function as limited as possible.
[00:53:00]
So if you depend on if you depend on less data as input, then pass in more narrow parameters,
[00:53:08]
whether that's like just passing in a single value instead of a big record with additional
[00:53:13]
context you don't depend on.
[00:53:15]
Or he uses a lot of extensible record syntax to sort of say, you can pass in the whole
[00:53:21]
record, but I'm only going to look at this.
[00:53:24]
And I'm going to return the whole record, but I'm only going to possibly change this.
[00:53:29]
So and don't return a command if you're not going to perform a command, like just as a
[00:53:33]
default scope it down more narrowly.
[00:53:35]
So I could imagine doing a similar sort of hotspot analysis in an Elm code base, where
[00:53:42]
you're saying, well, what is this return?
[00:53:45]
Or like, if we're trying to follow the code path of like, how this value in the model
[00:53:51]
could change?
[00:53:52]
Where could that possibly happen based on the type annotation?
[00:53:55]
Yeah, and that's a really good example of how you can make something more simple to
[00:54:00]
understand and make make your intentions more clear about what what you're what you're doing
[00:54:07]
in that specific place.
[00:54:09]
Because the exercise that follows on from that data flow one is getting people to independently
[00:54:17]
identify like the four most important lines in that 120.
[00:54:22]
And again, that throws up some like very interesting like differences of of why people choose things
[00:54:30]
that are important.
[00:54:31]
So people will choose things that have bitten them in the past, people will often choose
[00:54:36]
like an early return.
[00:54:38]
And then most of the other people in the room will have not even noticed that it was there,
[00:54:43]
which is fascinating.
[00:54:45]
And you know, why it's maybe not such a great pattern.
[00:54:50]
But again, like things like that, just with with Elm, like, because everything is a function
[00:54:56]
that returns something, it kind of takes away all the fun.
[00:55:00]
Right, exactly.
[00:55:02]
It is so interesting, because like, I always felt like out of place with some of my opinions
[00:55:10]
on this stuff back in my days doing Ruby on Rails and like different different programming
[00:55:15]
languages where, you know, there would be an early return and I'd be like, hmm, can
[00:55:21]
we do this like with an if else and it's like, well, that's like an unnecessary amount of
[00:55:25]
code that's like, people would think that that was a code smell because it's more terse
[00:55:31]
if you just do an early return.
[00:55:33]
But for me, I'm like, this is making my brain think harder.
[00:55:38]
This is like a very dramatic little keyword that we can put in here that has like an outsized
[00:55:46]
effect on the behavior of this thing, and like makes it incongruous.
[00:55:51]
I even have the example where I was going to a coding club, not a reading club, coding
[00:55:59]
club.
[00:56:00]
And it was very object oriented.
[00:56:04]
And at one point they said like, oh, here's an empty pattern, use the else keyword.
[00:56:09]
I'm like, what do you mean?
[00:56:13]
Yeah, basically, they were saying you should always use the return, an early return.
[00:56:19]
Right.
[00:56:20]
And I'm like, exactly.
[00:56:22]
I would say the opposite.
[00:56:24]
Like, in some mentors have that opinion to like, there are rules for this to say, oh,
[00:56:30]
this could use an early return.
[00:56:32]
Yeah, I guess it does make sense if you're in a community where you've been trained,
[00:56:38]
where it's conventionally accepted to use early returns, because then people get used
[00:56:44]
to that.
[00:56:45]
Yeah, then you can spot them more easily.
[00:56:48]
That makes sense.
[00:56:49]
But it's also I think we need to change the way that we're writing code now to reflect
[00:56:57]
like, the number of people who are needed to read and write code compared to 10 years
[00:57:04]
ago or 20 years ago, the types of problems that we're solving are different to those
[00:57:10]
that we were solving 20 years ago and 50 years ago.
[00:57:13]
And I think there needs to be some like realization that like the things that were true then and
[00:57:19]
were good then maybe are not true and good in our current domain.
[00:57:24]
Right.
[00:57:25]
And that might be that might be one of them.
[00:57:28]
You brought up Ruby earlier, and I have done like Rails code in reading clubs.
[00:57:35]
And that's one of the ones where it relies on a lot of knowledge about Rails.
[00:57:41]
There's so much magic.
[00:57:43]
Yep.
[00:57:44]
And it's fine if you're a Rails developer, right.
[00:57:49]
And the same with React as well.
[00:57:54]
People who come in a lot of times who are not as experienced developers, a lot of times
[00:58:00]
they're coming, I mean, coming to Code Reading Club, a lot of times they're coming from a
[00:58:04]
boot camp background, which means they probably did do React.
[00:58:08]
But when people are career changers, sometimes they haven't done React.
[00:58:14]
And that again, has the same problem.
[00:58:15]
They get really overwhelmed and tripped up on like, all of these like things that don't
[00:58:20]
appear to have a source.
[00:58:21]
They're not coming from anywhere that's in the file.
[00:58:24]
I mean, so again, that's another thing Elm is so explicit that it really lends itself
[00:58:30]
to that, like being able to process the whole thing independently of the context, which
[00:58:36]
is what the Code Reading Club is all about, which is what our brains can really only look
[00:58:44]
at one piece in isolation at a time.
[00:58:48]
So it's really great to have Elm in our lives.
[00:58:54]
So would you say that the experience of reading Elm code is positive in Code Reading Clubs?
[00:59:01]
Because often what I hear from people on podcasts or on the Elm Slack is like, oh, at first
[00:59:07]
I was afraid of the syntax or I was alienated by the weird syntax, which I have trouble
[00:59:15]
empathizing with or relating to.
[00:59:19]
So that's definitely a problem.
[00:59:20]
The very first time that I did Elm code in a club.
[00:59:24]
So people, so the rest of the people who are in the Code Reading Club, the company Code
[00:59:29]
Reading Club, are not Elm fans like me, right?
[00:59:35]
So I have to be very careful how much I keep bringing it in.
[00:59:40]
And also, like I said, it's not as fun to do Elm code because there's not as many things
[00:59:45]
to discover.
[00:59:46]
But yeah, the first time I did it, we didn't have the syntax exercise yet.
[00:59:50]
And it really, it really did stump people.
[00:59:53]
It really very much did confuse people.
[00:59:56]
And after that, I introduced a syntax exercise and it just unclear, like it clears some very
[01:00:09]
big cognitive black spots, I guess, for people who have never seen it before.
[01:00:15]
And once you've done that, then it's very easy for them to read.
[01:00:21]
Yeah.
[01:00:22]
Right.
[01:00:23]
Yeah.
[01:00:24]
Reason ML had a big change in their syntax, which is like a functional OCaml dialect that
[01:00:33]
compiles into JavaScript.
[01:00:35]
They made a big shift.
[01:00:37]
It's created by the same people who created React.
[01:00:39]
And they changed to C style syntax and rebranded as Rescript.
[01:00:43]
So they made a big decision to use less OCaml style syntax and more C style JavaScript style
[01:00:51]
syntax.
[01:00:52]
Hmm.
[01:00:53]
So one of the things that that's reminding me of is that there's very few keywords in
[01:01:03]
Elm as well.
[01:01:04]
So you don't have those like function or funk or def or return.
[01:01:11]
And so if you don't know that, if you don't know that kind of very fundamental information,
[01:01:17]
again, it can be very confusing to look at.
[01:01:22]
And other thing that it reminded me of is there's a concept in Felina's Programmer's
[01:01:29]
Brain book, which is just brain concept in general, which is that if you try and transfer
[01:01:35]
knowledge from one domain to another domain, you can often make like a wrong assumption.
[01:01:43]
False friends.
[01:01:44]
Is that another pun?
[01:01:47]
No, maybe that's a way we have in French of saying that something looks like another thing,
[01:01:55]
but it isn't.
[01:01:56]
So it's a presumage of false friends.
[01:01:59]
Yes, false friends.
[01:02:01]
That's what I'm talking about.
[01:02:03]
I think the bad example that's popping into my brain is what happens if you put a coat
[01:02:09]
on a snowman that like people immediately will think it melts faster.
[01:02:14]
But most people with some science knowledge will then like after a second thinking, realize
[01:02:21]
that it like preserves the cold inside the coat.
[01:02:25]
But that is an example of where if you just assume that putting a coat on anything makes
[01:02:31]
it warmer, it's not true.
[01:02:33]
Only if you put it on a warm blooded animal does it make it warmer or the sun maybe.
[01:02:37]
I don't know.
[01:02:38]
That's how we use global warming.
[01:02:40]
Just put a coat on the sun.
[01:02:45]
But yeah, it can be a very fundamental.
[01:02:46]
You can imagine like in a practical science setting that that would be a very fundamental
[01:02:52]
like mistake to make at the outset.
[01:02:55]
And the same thing can happen if you misapply like a syntax, you know, a symbol in a computer
[01:03:01]
program.
[01:03:02]
I think it was maybe rust that we were doing.
[01:03:07]
And there is some syntax which means like evaluate this thing, which looked like it
[01:03:14]
was doing something totally different, which confused a lot of people.
[01:03:18]
But yeah, if you use the same symbol in two languages to do different things, then that's
[01:03:24]
very confusing.
[01:03:26]
So Elm has very few operators, operator symbols mostly.
[01:03:31]
Does that help, do you think?
[01:03:34]
Because I would imagine that having plenty of operators is like one of the more complex
[01:03:39]
things to grok because it's not something you can pronounce as long as you don't have
[01:03:45]
a name for it.
[01:03:47]
So like if you have a like those weird Haskell operators that people do or the ones that
[01:03:53]
we did in Elm before custom operators got banned.
[01:03:59]
If you don't have a name to give to something, then it's harder to keep in your mind and
[01:04:05]
to assimilate.
[01:04:06]
Yeah, definitely.
[01:04:07]
And that's one of the very beginnings of Felina's research was about how you pronounce the things
[01:04:14]
that are on the page.
[01:04:15]
And it has a huge knock on in when you're like trying to discuss something with a remote
[01:04:21]
team or when you're trying to teach something to people, especially if their first language
[01:04:26]
is in English as well in programming.
[01:04:29]
That's a whole nother like landscape that we're not going to enter into in this podcast.
[01:04:33]
But that's where her research has moved on to now.
[01:04:37]
But yeah, so if one of her suggestions in that talk was to sit down with your team and
[01:04:44]
just agree the names of what you're going to call the operators.
[01:04:48]
And I was thinking at that time, I was already using Elm and I was thinking, wouldn't that
[01:04:55]
be amazing if that was part of the Elm docs, like this is how we pronounce these things.
[01:05:00]
And you're right, having a much smaller number, like having just a very tiny language to learn
[01:05:08]
makes it easier to read because you can master all of it in terms of like that chunking effect.
[01:05:16]
You can master that linking your long term knowledge with what you're seeing in the short
[01:05:22]
term.
[01:05:23]
There's one thing that I do a lot when I'm writing Elm code, which is I write in like
[01:05:29]
closures and then I transform it into a pipeline because I know that it's going to be easier
[01:05:34]
to read in a pipeline, but it's easier for me to write in like inside out.
[01:05:42]
And one thing that I notice in my Elm code bases when I'm working with a team is that
[01:05:49]
people will choose like different styles of doing that.
[01:05:54]
And there's another operator that you can do away with parentheses, right?
[01:05:57]
If you do like the backwards pipe, I don't know what you would call it.
[01:06:01]
Yeah, left pizza.
[01:06:02]
Left pizza.
[01:06:03]
Okay.
[01:06:04]
Is that like an official Elm?
[01:06:07]
It's pretty common, but it's obviously a little silly, but it kind of stuck and I don't mind
[01:06:12]
it.
[01:06:13]
I'm not opposed to pizza.
[01:06:14]
There is an Elm review rule to forbid left pizza.
[01:06:21]
That's good to know because I find myself trying because I'm trying, I do a lot of like
[01:06:26]
new projects with new teams and I try and let people make their own mistakes and let
[01:06:32]
people do things in their own style.
[01:06:33]
And like, I try not to like step on it too much at the beginning, especially.
[01:06:38]
And that's one of the things that I always, I find myself sort of biting my tongue going,
[01:06:42]
please don't do that.
[01:06:43]
But I don't say it and I could justify it with it.
[01:06:47]
It does make it very unreadable.
[01:06:50]
It's like, especially if you're using right pizza and left pizza, like it's, I think we
[01:06:56]
need to lobby just to get rid of it.
[01:06:59]
Who needs it?
[01:07:02]
Right?
[01:07:03]
I think some people find parentheses hard.
[01:07:05]
Maybe.
[01:07:07]
If there are too many left pizzas in a particular expression, then it's definitely like, this
[01:07:12]
seems like a right pizza kind of expression.
[01:07:16]
Yeah, they both sound delicious to be fair.
[01:07:22]
They do.
[01:07:23]
This is the wrong pizza and the right pizza.
[01:07:24]
That's not, that's not cool.
[01:07:26]
I mean, you have two kinds of pizzas.
[01:07:30]
The one on the right has all the ingredients you like and the left pizza has pineapple.
[01:07:34]
That's how you should see it.
[01:07:37]
Exactly.
[01:07:38]
Yeah.
[01:07:39]
That's very controversial.
[01:07:40]
Offensive.
[01:07:41]
Yeah.
[01:07:42]
So do you want me to move on into the, like, I've kind of covered a little bit of like
[01:07:51]
code reading club, the whole, that's the whole, like the first time you look at a piece of
[01:07:56]
code with a group of people.
[01:07:58]
Those are the things that you do and at the end, hopefully you can start to summarize
[01:08:02]
what you think the code does because people through you, you would have had so many conversations,
[01:08:06]
particularly like in the important lines conversation where people start to articulate to other
[01:08:11]
people in the room.
[01:08:13]
The reason why they chose this line is because they think it's at the core of what this thing
[01:08:16]
is delivering or doing or operating, or they might've chosen it because it's something
[01:08:21]
which is something you need to watch out for.
[01:08:24]
So after you've done that with one group of people, you get the same group of people back
[01:08:28]
a week later or a couple of weeks later and you look at the same piece of code with all
[01:08:34]
of that knowledge behind you and you've told them now the context so they know where it
[01:08:38]
sits in like the wider world.
[01:08:40]
And some people then go and do a little bit more research in terms of like which other
[01:08:44]
things it's connected to.
[01:08:46]
You come back and then you do a little bit of warmup exercises on that and maybe like
[01:08:52]
on board people who weren't there at the last time.
[01:08:55]
And then you launch into thinking about what are the themes and concepts of the code.
[01:09:01]
And more interestingly, like my favorite, favorite ones are getting people to list out
[01:09:06]
all the decisions that got made by a person when they were writing this code.
[01:09:11]
So any decision, it can be like super trivial, like using left pizza, or it can be like very
[01:09:16]
complicated, like some kind of algorithm that they chose over another algorithm.
[01:09:21]
And then you just get list all those out.
[01:09:23]
And then you ask people to choose one or two of those decisions that you've listed out
[01:09:27]
together and think about what are the consequences of those decisions, like what has happened
[01:09:33]
because they made that decision.
[01:09:35]
And then you have like a whole conversation around that.
[01:09:38]
And then you think about why, why possibly like you're not going to know you weren't
[01:09:43]
there, but why might they have made those decisions.
[01:09:46]
And you can get some really interesting answers from people and like reflections from people
[01:09:52]
saying, oh, yeah, like when I first looked at that, I thought, oh, what idiot would have
[01:09:56]
done it that way.
[01:09:57]
And now these eight people in the room are telling me eight different reasons why that
[01:10:01]
like person who's not an idiot might have done it that way.
[01:10:06]
And it really gets you to think about not being judgmental.
[01:10:10]
That's awesome.
[01:10:11]
I love that.
[01:10:12]
Like honoring what the role the code has played and that it got its job done and that it came
[01:10:19]
into existence for a reason which you might not know.
[01:10:22]
Like I love that.
[01:10:24]
And I think that it really does better equip you to deal with code because as you're sort
[01:10:31]
of saying, like if you're assuming the worst about the reason it was written, like, oh,
[01:10:35]
my God, this this code is idiotic, it's gonna get you making assumptions instead of being
[01:10:44]
open to possibilities and like, well, what could how could this have come to be?
[01:10:49]
What might be behind this?
[01:10:50]
And it's going to give you a more open mind, which is going to empower you to navigate
[01:10:56]
that code better.
[01:10:57]
Yeah, definitely.
[01:10:58]
I mean, if you come into a situation and you're feeling like essentially what you're feeling
[01:11:01]
like angry about something being being wrong, right, then your whole like ability to reason
[01:11:07]
is totally clouded by that, as we know from other aspects of our lives.
[01:11:11]
Do you ever give code examples where you're expecting people to say WTF, like the XKCD
[01:11:19]
comic?
[01:11:20]
No, we don't.
[01:11:22]
We don't bait people.
[01:11:23]
Is that?
[01:11:24]
No, no, we don't.
[01:11:27]
We don't do that at all.
[01:11:28]
And also, we do like refrain from just calling things bad code, because it's just it's code.
[01:11:35]
So we do explicitly like set out at the very beginning of every single club that we're
[01:11:40]
not we're not here to talk about how good or how bad this code is.
[01:11:44]
We're here to talk about this code.
[01:11:46]
Right.
[01:11:47]
And code is a process.
[01:11:48]
Do you try to find ways to improve the code at some point?
[01:11:52]
Yes.
[01:11:53]
Yeah, we do often like have that, what I was saying earlier, where somebody in the room
[01:11:58]
will say, oh, if I wrote it this way, it would be easier for you to understand.
[01:12:02]
And we have had a couple of sessions.
[01:12:04]
And I really want to do more of this, where somebody brings their own code to the session
[01:12:11]
and lets other people read it.
[01:12:12]
And here and here's how here's how people read it.
[01:12:15]
So there was somebody who brought like a piece of code that he thought was problematic to
[01:12:19]
understand because it was so complex when he was writing it.
[01:12:23]
And he did actually do a big refactor after he after he had that session.
[01:12:28]
So it was like really, really helpful, very helpful for him to like see, because we're
[01:12:33]
very limited in our scope of thought, right?
[01:12:36]
We have that tunnel vision.
[01:12:37]
So often it is the way that you can only see one one way of doing things.
[01:12:42]
And it really does open your mind to hearing other people's strategies and experience how
[01:12:50]
they experience stuff.
[01:12:52]
Katya, how has this influenced the way that you approach code?
[01:12:58]
And like, if you're coding day to day, like, how do you read code differently or navigate
[01:13:04]
code differently?
[01:13:05]
I'm much more of sort of forgiving of myself when I'm writing and reading, like when I'm
[01:13:09]
having a tricky problem, I think to myself, it's just because I'm missing a bit of knowledge
[01:13:15]
here.
[01:13:16]
And I'm sure I can find that knowledge either here in this paper or by asking somebody or
[01:13:21]
by looking it up.
[01:13:22]
And so rather than just thinking, oh, I'm never going to be able to understand this
[01:13:26]
and walking away.
[01:13:27]
Right.
[01:13:28]
It's also so, you know, sometimes when you stare at something and this happens to me
[01:13:33]
and when I'm reading a book, as you know, a book, yeah, I'm reading words when I'm reading
[01:13:42]
English words, where you like reread the paragraph like five times, you just keep rereading it
[01:13:47]
and you still don't understand it.
[01:13:48]
And you keep rereading and you stare at it and they say like, that is something that
[01:13:52]
used to happen to me in code where I just like stare at the screen blankly.
[01:13:56]
Right.
[01:13:57]
And just you keep trying, you keep trying and then you just give up.
[01:14:00]
And what what's happened, what happens now is I start to think, well, how can I pull
[01:14:04]
this apart into pieces that I can try and understand rather than like getting into that
[01:14:09]
like terrible cycle of like reread, reread, reread.
[01:14:13]
So yeah, so I find that that is also the same thing that I that I do now when I'm reading
[01:14:18]
a book with a concept or something that I don't understand is like trying to identify
[01:14:23]
what are the concept, like what are the specific things that are stopping me from understanding
[01:14:27]
it rather than just keep reading it over and over and thinking that's going to solve the
[01:14:30]
problem.
[01:14:31]
So yeah, breaking things down into an awareness that there is.
[01:14:35]
It's been proven to me like time and time again, with like all different groups of people
[01:14:40]
with different skill levels in programming and different mathematical levels and different
[01:14:44]
linguistic levels and different languages like people.
[01:14:47]
Now that we do the code reading clubs online, like people come from all over the world and
[01:14:51]
participate and it has proven to me that every person in the room is like able to, even if
[01:14:59]
they were to do these exercises independently, get more understanding than they did when
[01:15:03]
they walked in the door and saw the piece of code, which when you first look at it,
[01:15:07]
you think I'm never going to understand this.
[01:15:09]
And you can if you just take it one piece at a time.
[01:15:13]
Yeah.
[01:15:14]
Amazing.
[01:15:15]
If somebody wanted to get involved and start attending some code reading clubs, what's
[01:15:19]
the best place to find out more and find a good place to join?
[01:15:23]
I would say our website, but it's in the middle of a rewrite at the moment.
[01:15:28]
So there's not very much information on there because we took everything down and just put
[01:15:33]
the very minimum up and it's too minimal.
[01:15:37]
By the time this comes out, I can try and put a little bit more on there.
[01:15:42]
But Discord is probably the best place.
[01:15:45]
We have a code reading club Discord and then you can like ask specific questions.
[01:15:50]
What our intention has always been to help people set up their own clubs.
[01:15:57]
So we used to do on the first Tuesday of every month, this like international online club
[01:16:05]
and then got to be too much for us to do that on top of like also running in person.
[01:16:11]
Like once the pandemic is well behind us now, there's more in-person stuff happening as
[01:16:16]
well and it's just too much to promise to do that.
[01:16:19]
But we do do those occasionally.
[01:16:21]
And the other thing that we found with those is that they're more like tasters.
[01:16:25]
So you come along and like if everyone in the in the session has never done code reading
[01:16:29]
before, then you're mostly teaching the techniques.
[01:16:32]
Whereas if everyone in the session has done it before, then you're actually reading the
[01:16:36]
code together.
[01:16:37]
And so we're trying to rework our like the way that we invite new people into code reading
[01:16:44]
to like you have to do an intro session and then you can join like a regular club.
[01:16:50]
But we haven't quite designed how that is going to happen.
[01:16:53]
But definitely like if you want to start one or if you want us to come and facilitate one
[01:16:57]
in your workplace, we will do that and then help you like help you get your own club started.
[01:17:03]
But there's a we have a GitHub as well, which is called Code Reading Clubs, I think.
[01:17:11]
And that has resources that you can use to start your own.
[01:17:14]
But again, that's another thing that we're working on making it more easy, easier for
[01:17:20]
people to come into.
[01:17:22]
So did that answer your question?
[01:17:24]
Absolutely.
[01:17:25]
We will link to all those resources and people can jump into the Discord and say hello.
[01:17:31]
And amazing.
[01:17:32]
Well, this was a lovely conversation.
[01:17:33]
Thanks so much for coming on, Katya.
[01:17:35]
Thank you.
[01:17:36]
Yeah, thanks for having me.
[01:17:37]
I really enjoyed it.