►
From YouTube: BindNode
Description
Recorded at DataSystems September 2021 Colo. Join us in #retrieval-market on filecoin slack to ask questions or build an open data transfer stack with us!
A
A
We've
got
this
node
interface,
and
this
node
interface
is
what
describes
any
ipld
node
any
apld
value,
and
it
has
some
methods
like
kind.
What
kind
am
I
you
can
interact
with
it?
Look
up
by
string
to
get
a
field
if
it's,
for
example,
an
integer
you
can
tell
it
give
me
the
actual
integral
value
and
so
on,
and
you
can
use
prototypes
to
build
more
of
those
and
the
way
most
people
use.
A
This
interface
nowadays
is
with
codegen
and
that's
cogen
that
eric
wrote
a
while
ago,
and
that
is
in
schema,
gen
go
so
you
can
see
quite
a
lot
of
code
here,
I'm
not
going
to
walk
you
through
it,
but
you
can
see
it's
just
a
bunch
of
templating
and
then
a
nice
example
of
this
in
action.
Is
this
gen
demo
package.
A
A
No,
where
is
it
okay?
There
we
go
so
message
by
string
lookup
by
string,
because
this
is
all
code
generated,
it's
pretty
static,
so
it
literally
just
generates
what
key
am
I
and
then
it
just
goes
to
the
actual
field
in
memory
and
that's
fine.
But
if
you
notice
for
such
a
tiny
schema,
we
generated
2000
lines
of
code
for
the
methods
alone
and
that's
usually:
okay,
that's
not
the
biggest
deal,
but
at
least
to
me
the
biggest
problem
with
this
approach
was
number
one.
You
actually
do
need
to
code
gen.
A
So
you
you
add
an
extra
step
to
iteration
and
development,
and
sometimes
you
can't
code
gen,
for
example,
suppose
that
you
know
you
get
the
schemas
at
runtime
and
you're,
not
compiling
so
code.
Gen
would
be
a
problem
then,
and
you
also
end
up
with
these
weird
types
with
unexpected
fields
and
interacting
with
those
is
pretty
finicky.
A
So
you
would,
you
would
either
need
to
go
through
the
methods
which
are
fine
but
they're,
pretty
generic,
so
they're,
not
very
nice
or
you
would
have
to
like
go
into
these
unexported
fields.
If
you
can
so
that's
that
was
that's
a
state
of
the
art.
So
what
I
did
I'm
gonna
copy
this
here
I
essentially
said:
okay,
let
I'm
gonna
just
try
to
implement
this
with
reflection
and
reflection
and
go.
I'm
gonna
briefly
show
what
that
is.
A
Reflection
and
go
essentially,
you
can
do
if
you
have
a
value
of
anything
like
a
string
or
a
struct
or
a
map.
You
can
say
value
of,
and
it
gives
you
this
reflective
value
which
is
opaque
because
it's
sort
of
like
a
magic
way
to
modify
arbitrary
values
of
of
go
in
at
runtime,
and
you
can
then
do
with
this
say.
Something
like
give
me
the
boolean
value.
If
it's
a
bull,
can
I
address
this
to
make
it
a
pointer?
Can
I
convert
it
to
something
else?
A
A
A
What
I
implemented
in
the
by
node
package,
is
essentially
three
apis.
One
of
them
is
prototype
and
prototype.
You
give
it
your
go
type,
which
is,
for
example,
a
struct
definition,
and
you
give
it
your
schema.
So
here's
an
example
of
you
giving
both
of
them
so
just
like
before
I'll
make
this
slightly
bigger.
A
So
just
like,
before
you
have
to
define
a
you,
have
to
define
a
schema
and
right
now
that
is
done
through
this
api.
So
you
spawn
some
types,
you
accumulate
them
into
a
type
system
and
then
you
end
up
with
types.
So
this
is
a
schema
type
and
in
this
case,
string
of
it
or
end
is
a
union
between
a
string
or
an
end.
A
A
A
So
in
here
you
can
see
I
can
encode
it
as
that
json
at
the
type
level,
which
is
not
very
useful
or
at
the
representation
level,
which
is
the
actual
union,
how
it's
meant
to
be
when
you
give
it
to
other
people,
and
you
can
see,
for
example,
hasn't
this
field.
Here
is
what
I
said
should
happen
in
the
schema.
A
And
it
also
knows
how
to,
for
example,
infer
things
so,
for
example,
if
you
only
give
it
the
schema,
so
here's
the
schema,
but
you
don't
give
it
the
the
go
type
it's
going
to
build
another
mosquito
types,
so
that
is
pretty
cool.
For
example,
if
somebody
is
giving
you
schemas
at
runtime,
but
you
don't
have
the
go
types,
but
you
still
want
to
interact
with
them
right,
that's
not
something
you
can
do
with
codegen.
A
So
in
this
case,
what
it
does
you
can't
really
see
it
here,
because
all
I
do
is
just
dac
json
encode
the
data,
but
if
I
can
I
edit
this,
I
can
that's
cool.
So
if
I
did
something
like
where'd,
it
go.
No,
if
I
do
something
like
printf
tell
me
exactly
what.
A
And
the
remote
server
is
nice
enough
to
do
it.
For
me,
undefined
font
thanks.
A
So
you
should
be
able
to
see
the
value
but
yeah
the
actual
types
they're
not
named
types
that
you
would
have
on
statically
in
your
go
program.
They're
like
anonymous,
structs
anonymous,
go
types
and
that's
pretty
much
it
so
you
have
you.
Have
these
three
apis
you've
got
prototype,
which
I
just
showed
you
you
give
it
a
go
type
and
you
give
it
a
schema
type
and
it
gives
you
a
prototype
and
with
a
prototype
you
can
build
nodes.
A
You
can,
for
example,
decode
that
json
into
that
you
can
also
unwrap
to
get
the
actual
go
value
underneath
that
and
you
can
also
wrap
and
wrap,
is
like
prototype,
but
you
give
it
an
already
existing
go
value.
So,
for
example,
here's
here's
using
this
without
a
schema,
so
you
have
a
go
struct
in
this
case
person
with
a
bunch
of
fields,
you
fill
it
and
then
you
say
wrap,
but
you
don't
give
it
a
a
schema.
A
So
it's
just
gonna
infer
what
the
schema
is-
and
this
is
kind
of
maybe
a
little
bit
simple,
but
it
is
going
to
work
it's
just
going
to,
for
example,
for
a
struct.
It's
going
to
say
I'm
going
to
guess:
you
want
an
ipld
schema,
struct
representation
map
that
kind
of
thing,
so
it's
just
gonna
work,
but
you
can
also
use
it
with
a
schema.
So
here's
a
schema
and
I'm
not
sure
if
I
did
anything
interesting
with
this
schema.
A
A
A
A
Yes,
it's
not
documented,
but
I
I
I
think
at
the
top
of
this
yeah
this
package.
I
said
this
is
experimental
because
it's
not
so
many
of
these
choices.
I
made
them
like
as
simple
as
I
thought
they
might
be,
but
I,
if
they're
not
set
in
stone
once
I've,
there's
some
things
that
are
still
yet
to
be
implemented
like
some
advanced
features
once
I
finish,
all
of
that,
I'm
probably
going
to
fix
the
behavior
and
then
I'm
going
to
properly
document
it.
A
A
So
I
look
at
the
the
struct
fields
and
the
ipld
schema
and
I
say:
is
it
nullable?
I
just
add
a
level
of
interaction
with
a
pointer
if
it's
optional,
I
do
that
again.
If
both
are
used
at
the
same
time,
don't
ask
me
what
happens
I
haven't
tested
it.
C
A
You're
gonna
end
up
with
two
pointer
levels,
and
you
can
also
see,
for
example,
here
when
I
find
a
map,
I
just
wrap
it
in
a
struct
with
keys
and
values.
A
I
think
a
lot
of
this
will
get
easier
with
generics
because,
for
example,
optional
types
I'm
going
to
be
able
to
say
an
optional
of
t
with
a
boolean
and
not
have
to
jump
around
memory
with
pointers
and
also
because
pointers
and
go
are
kind
of
like.
If
you
want
to
make
a
pointer
to
the
number
three.
You
have
to
declare
a
variable
of
value
3
and
then
take
a
pointer
to
that
which
is
kind
of
annoying.
B
My
question
is:
there's
of
determinism.
How
much
have
you
take
into
account
about
interacting
with
other
languages?
For
example,
can
we
guarantee
that
the
reflection
will
be
deterministic
in
different
machines,
like
that
there
will
be
no
situation
where
one
interprets
something
as
a
slice
and
another
another
interprets
it
as
a
string,
and
then,
when
you
manipulate
the
data,
what
the
serialized
back
is
actually
something
that
is
different.
A
So
in
case
the
mic
isn't
biking
and
picking
it
up.
The
question
is:
can
you
guarantee
that
reflection
works
the
same
on
every
single
machine,
right
yeah?
I
think
the
answer
is
yes,
because
they
follow
the
go
spec
and
memory
model.
So
it's
the
same.
In
theory,
if
reflect,
has
no
bugs
yeah,
it's
the
same
as
asking,
can
you
guarantee
that
a
go
program
behaves
the
same
with
all
machines
right,
yeah.
B
Well,
what
I'm
concerned
is
like
when
you-
and
I
know
this
is
just
for
my
interfacing-
between
bill
and
jess.
A
lot
of
times
is
that
there
is
different
interpretations
like
what
are
slices
or
strings
and
and
so
on,
and
often
that
would
lead
to
situations
where
you
would
create
the
same
data
or
you
start
from
the
starting
point
and
then
apply
the
same
transformation
supposedly
and
when
you
sterilize
it
back,
you
actually
have
something
with
a
different
cd
just
because
the.
B
One
girl
would
write
it
in
one
way.
Ngs
will
write
in
another
way,
and
so
my
question
is
like:
can
we
securely
or
provably
go
back
and
forth
between
multiple
runtimes
and
ensure
that
this
will
not
create
an
event
where
the
data
will
be
modified
in
a
way
that
is
not
deterministic,
therefore,
generating
different
settings
in
different
machines?.
A
I'm
going
to
summarize
the
question
for
the
mic
in
case:
it's
essentially
can
you
guarantee
that
the
data
is
going
to
be
the
same
across
different
runtimes
and
languages
because,
for
example,
strings
in
javascript
are
utf-16
and
then
go
there,
etf,
eight
and
other
languages
don't
allow
nulls
and
strings
that
kind
of
thing
right.
A
So
there
was
a
pretty
large
discussion
about
what
is
a
valid
ipld
data
model
string,
for
example,
because
exactly
of
those
reasons
and
beyond
that,
I
think
the
behavior
of
bind
node
should
be
practically
the
same
as
the
code
gen.
So
if,
but
if,
if
this
has
a
problem,
I
think
cogen
would
have
it
as
well.
So
I
don't
think
it's
making
anything
worse.
E
D
Be
fast
in
my
reflection
and
all
that,
but
on
the
other
hand
I
want
to
coach
in
from
a
ghost
struct,
because
that's
what
I've
already
got
used
and
I
don't
want
to
like,
like
I've,
got
a
ghost
truck
that
I've
been
using,
let's
say
and
writing
serialization
code
with
like
sea
water.
Essentially-
and
I
wanted
you
to.
D
Like
after
the
moment
when
you
write
it,
is
there
like
a
version
of
this
that
does
the
code
gen
as
opposed
to
just
doing
it
at
runtime,.
A
So
there's
multiple
options
you
could
take
here.
You
could
do
a
code
like
that
yeah.
My
argument
would
probably
be
that
you
would
sort
of.
A
A
I
actually
haven't
measured
this,
but
I
think
I'm
willing
to
bet
that
buying
node
is
within
the
same
order
of
magnitude
as
as
kilgen
in
terms
of
performance.
It
might
be
maybe
like
50
percent
slower,
maybe
up
to
twice
as
low.
I
haven't
measured
it,
but
there's
this
has
not
been
optimized.
There's
quite
a
lot
of
things
you
could
do,
and
I
want
to
show
you
one
example.
If
I
can
find
it.
A
Because
encoding
json
works
in
a
pretty
similar
way,
it
uses
it
uses
reflection
right,
and
this
is
the
wrong
tab.
A
A
A
Yeah,
so
here,
for
example,
it
remembers
how
to
encode
the
name
of
a
field
of
a
struct
field,
name
of
a
struct
field.
It
also
remembers
the
encoder
func,
so
it
it
sort
of
builds
a
function
at
run
time
to
encode
a
value
and
then
memoizes
that
later
yeah
so
type
encoder.
A
C
D
E
A
D
A
D
A
The
question
from
will
was
next
steps
in
terms
of
connecting
this
right,
so
something
that
I'm
working
on
right
now
with
eric
and
should
be
ready
in
a
few
days,
because
eric
did
unblock
me
on
this
is
to
essentially
use
bind
node
to
implement
the
schema
schema
and
the
schema
schema
is
very
briefly:
we've
got
this
schema
spec,
but
it's
itself
defined
as
an
ipld
node
and
it
so
it
has
a
schema,
and
then
you
can
use
that
to,
for
example,
parse
a
plain
text
schema
in
its
language
and
then
take
the
json
and
do
stuff
with
it
so
that
used
to
be
used
with
codegen.