►
Description
Discussion for Chapter 7, “The Hash Table: The Workhorse of Ruby Internals” and Chapter 8, “How Ruby Borrowed a Decades-Old Idea from Lisp.”
A
All
right,
just
talking
about
ruby
under
a
microscope
chapters,
seven
and
eight
chapter-
seven-
is
all
about
the
hash
table.
Chapter
eight
is
all
about.
It's
called
how
ruby
borrowed
a
decades
old
idea
from
lisp,
and
it's
all
about
procs
lambdas
and
blocks
so
all
kinds
of
fun
stuff
there,
and
we
were
just
talking
about
how
these
chapters
are
short
but
quite
dense.
B
Yeah
I
mean,
while
I
was
reading
about,
I
kept
thinking.
How
is
this
going
to
provide
me
any
value
on
day
to
day,
and
I
don't
know
that
it
will
right
now.
I
think
it'll
be
later
on,
where
I'm
debugging
something,
and
I
think
it
back
to
this
book
and
think:
oh
yeah,
that's
how
that
works,
that's
how
hash
tables
work
or
that's
how
blocks
work
and
it
might
give.
A
B
Some
insight
on
some
performance
improvements,
or
at
least
a
reference
to
go,
look
at
that
chapter
in
the
book.
Yeah,
I'm
struggling
to
see
with
how
this
will
help
me
on
a
daily
basis,
yeah
yeah.
A
A
I
thought
it
was
really
interesting.
The
whole
idea
of
these
hashtag,
I
think
it's
the
hashtable
one
where
it's
like,
got
all
the
bins
right
and
it
puts
different
items
in
the
bins
and
tries
to
sort
of
evenly,
distribute
them
and
then
once
they
get
so
full.
A
It
makes
new
bins
and
has
to
re-hash
everything
which
you
know
it's
far
beyond
my
understanding
in
terms
of
like
what
that
means
in
terms
of
optimization
and
under
the
hood,
what
the
computer's
doing
with
that
information
and
why
it's
faster,
better
or
whatever,
but
there's
an
interesting
part
where
they
said
something
about
hash
collisions.
A
So
if
two
or
more
elements
are
saved
into
the
same
bin
would
be
considered
a
hash
collision.
But
I
was
like
the
whole
point
of
the
bins
is
that
they
contained
multiple
items
like
up
to
five
or
six
items
in
a
bin,
and
it
says
that
means
ruby
is
no
longer
able
to
uniquely
identify
and
retrieve
a
key
based
solely
on
the
hash
function.
A
Now
that
was
interesting
too,
because
I
feel
like
unless
it's
the
exact
same
key,
it
seems
like,
even
if
it's
in
the
same
hash
bucket
of
like
five
or
six
items,
it
should
still
be
quite
unique.
So
my
only
comment
there
was
like:
why
not?
Why
can't
it?
Why
can't
it
find
it
and
consider
it
unique
anymore,
I'm
wondering
if
they
maybe
just
met
the
like
the
bin
number,
but
I
don't
yeah.
I
don't
know,
I
don't
know
how
that
works.
B
You
actually
got
an
array
back,
but
once
you
got
past
50,
then
it
became
more
of
a
linked
list
or
I'm
sorry
hash
table.
So
I'm
I
wonder
where
these
arbitrary
numbers
came
from
like.
Why
is
an
array
of
six
okay?
But
an
array
of
seven
now
needs
to
become
the
hash
table
in
the
bin
array.
A
C
C
Yeah
that
whole
chapter,
I
thought,
was
interesting,
just
kind
of
like
digging
down
into
like
structures,
data
structures
like
a
realm.
I
don't
think
about
a
lot,
but
it
was
kind
of
like
it
was
fascinating
to
see
how
it's
all
put
together.
C
That's
the
only
the
the
straight
honest
answer
is
overall
no,
but
there
are
a
few
things
that
have
stuck
out
so
far
in
the
book,
specifically
seeing
how
modules
are
actually
tied
to
classes.
B
C
Just
you
know
making
it
a
superclass
like
inserting
it
as
a
super
class
that,
I
think,
will
help
me
understand
better
when
I'm
looking
at
you
know
a
class
full
of
modules
and
the
module
has
a
bunch
of
modules
and
like
following
that
line
and
understanding
like
well,
which
method
is
actually
going
to
read.
I
think
that'll
help
me
think
about
that
better
and
I
think
there's
one
other
aspect.
C
Oh
yeah,
the
message
calling
I
had
never
like
in
ruby,
I
never
thought
of
things
as
messages
like
sending
messages
to
to
an
object,
whereas,
like
this
helped
me
maybe
start
thinking
with
that
mindset
a
little
bit
more
and
it
helped
me
finally,
maybe
ingrain
the
idea
between
in
ruby,
there's
send
and
call,
and
I'm
always
I
used
to
always
be
like
well,
which
one
do
I
have
to
use
in
which
situation
and
now
it
totally
makes
sense.
Oh,
it's
send
when
you're
sending
a
message
to
an
object.
A
Yeah
I
was
wondering
like:
are
there
ever
cases
where
we
would
manually
create
a
hash
table
in
ruby
for
a
similar
type?
You
know,
storage
of
of
you
know
many
hundreds
or
thousands
or
millions
of
objects
like?
Is
that
something
like
we
would
ever
need
to
implement?
Or
would
we
just
say?
Oh
here's,
a
hash
ruby
under
the
hood
is
going
to
make
us
a
hash
table.
Yeah.
C
We
would
just
use
ruby's
hash,
okay,
yeah.
I
can't
imagine
a
reason
we
wouldn't
use
it.
If
we
got
to
the
scale
where
it
was
like
the
ruby
hash
isn't
performing
enough,
then
we're
looking
for
you
know.
That's
when
you
start
saying
well,
you
know:
do
we
need
to
look
at
other
languages
for
this
specific
problem.
A
B
Yeah,
I
was
looking
through
my
notes
again
and
back
to
the
previous
point,
steve
that
you
said
about
prior.
What
does
it
tell
us
about
prime
numbers,
the
note
in
there
that
ruby
does
use
an
algorithm
based
on
prime
numbers
to
determine
the
number
of
buckets
required
in
each
hash
table.
So
it
might
be
the
same
thing
from
converting
to
an
array
to
to
the
hash
table.
A
A
Prime,
so
did
they
pre-figure
that
out,
and
they
just
put
those
in
like?
Is
that
literally
like?
Is
he
just
showing
the
code
that's
literally
there,
or
is
he
kind
of
showing
what
that
code
does
like?
I'm,
I'm
just
really
curious
like
who
took
the
time
to
figure
out
these
nearest
primes
and
put
these
in
here,
and
how
far
does
it
go
since
it
does
that
snip
there
after
5
12
like
how
far
does
it
keep
going.
C
I
found
that
yeah.
I
found
it
interesting
that
these
primes,
like
it
makes
sense
for
it.
C
I
don't
know
if
I
understood
why
they
relate
it
to
those
you
know
those
multiples
of
two
two.
A
C
B
B
We
were
talking
about
something
similar
in
coffee
chat
today
this
week
and
I'm
wondering
if
this
is
like
an
artifact
of
the
time
when
ruby
was
written
because
it
was
written
in
the
early
90s
right
when
memory
was
a
little
more
expensive
and
you
had
to
be
more
thoughtful
about
what
you're
using
in
memory.
B
Whereas
now
it's
like
just
throw
some
more
memory
at
it's
cheap,
because
we
have
the
the
primary
key
overflow
issues
in
our
database,
where
the
events
table
in
the
ci
builds
table
were
written
with
the
ruby
default,
the
rails
defaults
of
integer,
and
we
have
used
up
half
of
the
available
ids
to
this
point
in
time.
And
now
we
need
to
go
through
a
painfully
massive.
B
Yeah
get
them
there,
so
I
wonder
if
this
is
just
an
artifact
of
those
days
where
memory
was
a
little
more
front
of
mind
when
you
are
architecting
these
things,
and
you
had
to
be
a
little
more
stingy
with
how
you
use
them,
and
now
it
just
doesn't
make
sense
anymore,
because
again,
memory
is
cheap.
C
Maybe
yeah
like
the
only
thing
I
can
think
of
that.
Well,
I
don't
the
one
thing
that
I
thought
was
interesting
is
that
it's
double
every
time.
So
if
you've
got
a
256
element
bucket,
when
you
get
to
257
or
whatever
the
prime
is
it
essentially
doubles?
It's
not
just
like
adding.
Oh
here's,
10
more
in
case
you
need
it.
It's
no
here's
another
256
more!
C
So
is
it
common
that
forgiven
sizes
once
you
start
to
grow,
it's
like
you
can
expect
you're
going
to
be
growing
by
a
lot
and
not
by
a
little
every
time
like
it's
an
exponential
kind
of
growth
pattern.
A
C
A
A
Often
yeah
because
it's
pretty
expensive,
I
can
imagine-
which
kind
of
gets
me
back
to
this
idea
of
you
know
if
we
use
like
a
million
item
hash
like
at
what
point
does
that
just
become
like
you
say
I
guess
unperformant
like
how
like
how
high
does
this
go
before
it's
like?
Okay,
the
next
time
you
put
in
an
element,
it's
gonna,
take
five
seconds
to
rehash
everything
and
then
insert
and
then
we'll
begin.
C
A
That's
a
good
question:
they're,
probably
not
that
big.
A
C
It's
it's
an
object,
so
each
instance
each
record
is
like
an
object.
Pretty
much
and
the
attributes
are
part
of
it.
That's.
C
A
A
So
don't
let
your
hashes
get
too
big,
which
I
don't
know
if
I've
ever
had
a
problem
with,
but
it's
nice
to
keep
in
mind
and
the
second
one
is
the
idea
of
the
blocks
where
they
kind
of
compared
like
doing
a
while
block
versus
doing
like
the
dot
each
version
and
how
much
you
know
faster.
The
file
version
was
like
70
percent,
faster
or
whatever.
A
Yeah,
just
kind
of
thinking
like
you
know
like
they
said,
though,
in
rails,
there's,
probably
so
many
like
dot
each
type
blocks
and
it
won't
matter
by
the
time
it
gets
to
your
little
chunk
of
code,
but
just
in
general,
I
guess
in
ruby,
it's
nice
to
kind
of
think
about
that
idea
like
if
there's
some
bottleneck
somewhere.
That's
using
a
lot
of
you
know
each
type
blocks
or
loops
or
whatever
or
similar
blocks.
If
you
can
convert
them
into
non
closure
style
blocks,
you
could
maybe
save
some
milliseconds.
I
don't.
A
C
I
thought
the
blocks
were
interesting
in
that,
so
I
used
to
do
a
lot
more
javascript
development
and
the
one
thing
in
javascript
that
you
do
a
lot
is
you
pass
functions
as
arguments
of
other
functions
like
what
they
call
it
higher
order
functions.
C
And
blocks
kind
of
look
like
that,
but
not
really,
and
so
it's
always
annoyed
me
that,
like
I
can't
just
like
say,
you
know,
def
my
method
and
then
take
my
method
and
just
pass
that
as
an
argument
to
another
method
or
function
somewhere
else
and
like
what
I
kind
of
got
out
of
this
is
like.
Maybe
I
can
kind
of
do
that.
It
just
looks
a
bit
different
and
it's
in
the
form
of
you,
know,
blocks
and
lambdas,
which
is
just
less
common
of
a
pattern
in
ruby.
B
Yes,
I
agree
with
the
way
you
described
it,
steve,
I'm
trying
to
think
of
the
equivalent
in
other
languages,
but
there
are
ways
in
dot
net
that
you
can
pass
methods
as
arguments.
C
B
A
B
C
A
C
With
javascript,
I
like,
they
would
always
have
the
interview
question
like
what
is
a
closure,
and
I
would
just
always
say
it's
a
function
in
a
function
but
like
the
understanding
of
it's
a
function
that
carries
the
environment
of
the
function
that
it's
in,
like
that,
the.
C
A
A
B
That
seems
odd,
but
I
mean
as
long
as
we
know
about
it
now
we
know,
maybe
that's
something
you
can
apply
later
on,
if
you
have
unexpected
behavior
like
oh
okay,
because
I'm
calling
lambda
in
the
same
scope
more
than
once,
especially
with
the
local
variables
where
they
demonstrated.
You
know
the
increment
of
I
on
the
two
different
lambdas.
I
was
not
expecting
that,
but
of
course,
as
I
was
reading
it
and
they
were
saying
what
do
you
expect
like?
A
Is
I
was
kind
of
like
oh
okay,
I
sort
of
get
it
it's
like
a
built-in
type
or
whatever
it
just
happens,
to
wrap
a
block
which
then
points
to
you
know
that
sort
of
function.
Definition
in
that
environment
that
we
were
talking
about
that
makes
the
closure
and
then
everything
else
it
needs
is
just
copied
down
into
the
heap.
So
it's
there
and
doesn't
get
discarded
with
the
garbage
collector,
but
yeah.
It's
really.
A
C
A
Other
ways,
thank
goodness
there
are
other
ways.
Other
people
got
just
as
fed
up
and
they
did
something
about
it.
They're,
like
I'm,
writing
my
own
yeah,
that's
great,
that's
funny.
I
kind
of
took
like
graphic
design
courses
and
part
of
them
like
one
of
them
was
about.
You
know
just
basic
web
stuff
where
you
like
back
in
the
day
it
was
like.
B
B
I
don't
have
anything
else
in
my
notes
that
was
interesting,
how
they
explained
why
the
dot
each
was
different
than
the
while
loop
and
the
in-depth
explanation
they
had
about
a
scrape
new
stack
form
has
to
set
the
the
ep
for
the
new
block.
He
needs
to
create
the
new
structure.
He
needs
to
pass
the
call
the
vlog
call
into
each
and
whereas
the
while
it
just
needs
to
check
to
reset
the
program
counter.
That's
it.
C
It
does
look
like
chapters
10
and
11
would
do
well
to
be
combined
because
they're,
both
ones
j,
ruby,
ruby
on
the
jvm
and
then
the
others.
Rubiness
rubinius,
ruby,
implemented
with
ruby.