Slide 1

Slide 1 text

How to Break into Reading Open Source

Slide 2

Slide 2 text

Hi, it's Kasper

Slide 3

Slide 3 text

We often talk about writing code

Slide 4

Slide 4 text

Today let's focus on reading

Slide 5

Slide 5 text

reading Open Source

Slide 6

Slide 6 text

 180.000 gems

Slide 7

Slide 7 text

be a sponge new Ruby syntax – Ruby methods – tricks – names – concepts –

Slide 8

Slide 8 text

Our meal plan reading ahead-of-time 1. reading just-in-time 2.

Slide 9

Slide 9 text

reading ahead-of-time AOT

Slide 10

Slide 10 text

reading just-in-time JIT

Slide 11

Slide 11 text

MINASWAN matz-is-nice-and-so-we-are-nice

Slide 12

Slide 12 text

WRAOTSTWCARJIT we-read-ahead-of-time- so-that-we-can-also-read-just-in-time

Slide 13

Slide 13 text

where I read

Slide 14

Slide 14 text

AOT happens on GitHub

Slide 15

Slide 15 text

JIT EDITOR=zed bundle open bundle open -h

Slide 16

Slide 16 text

cases we'll cover two AOTs from Rails and minitest a JIT from just last week

Slide 17

Slide 17 text

How this started

Slide 18

Slide 18 text

2013 Google Summer of Code

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

Now as prep I thought…

Slide 21

Slide 21 text

"I'll just read all of Rails"

Slide 22

Slide 22 text

"what a truly dumb heroic endeavor"  Thomas Cannon

Slide 23

Slide 23 text

let's proceed, stupidly

Slide 24

Slide 24 text

a little more background

Slide 25

Slide 25 text

rails just bundles other gems

Slide 26

Slide 26 text

actionpack ↪ actioncontroller ↪ actionview actiondispatch actionmailer 2013 activerecord activesupport railties

Slide 27

Slide 27 text

what I did Demo Time

Slide 28

Slide 28 text

summary - went to https://github.com/rails/rails - clicked activesupport - read #blank? & #present?

Slide 29

Slide 29 text

then I gave up reading Rails

Slide 30

Slide 30 text

but I learned a ton

Slide 31

Slide 31 text

what stuck with me

Slide 32

Slide 32 text

it's not about getting it 100%

Slide 33

Slide 33 text

Open Source isn't a blackbox (literally)

Slide 34

Slide 34 text

read the parts you can come back and read more

Slide 35

Slide 35 text

reading principles 1. just click things 2. remain neutral 3. keep coming back

Slide 36

Slide 36 text

just click things

Slide 37

Slide 37 text

"Oh, that's an interesting name!"

Slide 38

Slide 38 text

"What does this method do? Is this a Ruby thing?"

Slide 39

Slide 39 text

"What the hell is this?"

Slide 40

Slide 40 text

remain neutral

Slide 41

Slide 41 text

Do you say things like…

Slide 42

Slide 42 text

"I should know this already" evens, odds = integers.partition(&:even?)

Slide 43

Slide 43 text

"I shouldn't need to do this, right?"

Slide 44

Slide 44 text

"I'm not smart enough to get this"

Slide 45

Slide 45 text

"there's too much magic"

Slide 46

Slide 46 text

judging yourself stops you

Slide 47

Slide 47 text

like listening to new music

Slide 48

Slide 48 text

with music, we'll just try listening

Slide 49

Slide 49 text

it's not smarts it's context

Slide 50

Slide 50 text

reading helps you build that context

Slide 51

Slide 51 text

set anger & frustration aside

Slide 52

Slide 52 text

try to have an open mind

Slide 53

Slide 53 text

keep coming back

Slide 54

Slide 54 text

with practice you'll be quicker

Slide 55

Slide 55 text

you'll be quicker - parsing brand new code - splitting it into chunks - picking up new names & concepts - spotting styles & patterns

Slide 56

Slide 56 text

it's a process, not a task

Slide 57

Slide 57 text

1. just click things 2. remain neutral 3. keep coming back

Slide 58

Slide 58 text

it's much better just to look

Slide 59

Slide 59 text

before the next part

Slide 60

Slide 60 text

when you're learning something

Slide 61

Slide 61 text

follow a laid out path

Slide 62

Slide 62 text

WAY HARDER

Slide 63

Slide 63 text

part 2 a concept from minitest's source

Slide 64

Slide 64 text

minitest  Ruby's default test framework  1200 lines

Slide 65

Slide 65 text

Running 1 tests in a single process (parallelization threshold is 50) Run options: --seed 56269 # Running: . Finished in 0.018606s, 53.7461 runs/s, 53.7461 assertions/s. 1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

Slide 66

Slide 66 text

class Reporter < AbstractReporter def record result end end class SummaryReporter < Reporter; end # . class StatisticsReporter < Reporter; end # 1 assertions…

Slide 67

Slide 67 text

class CompositeReporter < AbstractReporter def << reporter end def record result end end

Slide 68

Slide 68 text

self.reporter = CompositeReporter.new self.reporter << SummaryReporter.new self.reporter << StatisticsReporter.new # in tests, minitest calls: self.reporter.record result

Slide 69

Slide 69 text

class CompositeReporter def record result self.reporters.each do |reporter| reporter.record result end end end

Slide 70

Slide 70 text

this is polymorphism

Slide 71

Slide 71 text

JIT from last week

Slide 72

Slide 72 text

audited + actiontext gem "audited" class Post < ApplicationRecord has_rich_text :content end ActionText::RichText.audited associated_with: :record

Slide 73

Slide 73 text

let's do a little ahead-of- time reading

Slide 74

Slide 74 text

YAML (not official docs, just looks nice) https://rubyapi.org/3.3/o/yaml

Slide 75

Slide 75 text

JIT Demo

Slide 76

Slide 76 text

summary we read a bit of YAML ahead-of-time – we used that knowledge to debug an issue – we looked at the source of audited and actiontext – we saw that ActionText::Content doesn't support YAML serialization –

Slide 77

Slide 77 text

wrap up

Slide 78

Slide 78 text

what the hell did we just do we learned about AOT and JIT reading – we nibbled some rails reading – we became experts at polymorphism from minitest – we used AOT to debug while also doing JIT –

Slide 79

Slide 79 text

reading principles 1. just click things 2. remain neutral 3. keep coming back

Slide 80

Slide 80 text

Work with me [email protected]

Slide 81

Slide 81 text

Special thanks Kim Burgestrand Sam Stephenson Thomas Cannon