►
From YouTube: Péter Czibik - Fast & Safe Native node.js Modules with Rust (Rust Hungary #3, 2017-11-23)
Description
Fast and Safe native modules in a node.js application? Péter Czibik will show us how to achieve both with Rust and hand-rolled native node.js extensions, or by using the Rust NEON wrapper library.
Slides: https://docs.google.com/presentation/d/1QWJ_4H3NqOm9z6198X1Cy5I9lKbpndEtSIpxs_jPdAo/
[Rust Hungary Meetup #3, 2017-11-23, Mozilla Hungary Community Space, Budapest]
http://rust-lang.hu/posts/2017-11-22/meetup-03-rust-hungary.en.html
https://www.meetup.com/Rust-Hungary-Meetup/events/244411460/
B
So
I'm
here
and
I'm
here
to
talk
about
fast
and
safe
native
modules
and
nodejs,
and
actually
it's
it's
a
case
study
is
how
people
call
it
and
I
just
call
it
my
story.
This
is
my
story.
How
I
actually
started
working
on
something
rusty,
I've
been
I've
been
looking
forward
to
this,
that
this
thing
for
a
long
time
have
been
like
poking
around
the
project.
B
I've
been
checking
out
when
the
Ross
book
came
out,
I
started
reading
it,
but
it's
been
so
long
time
since
since
then
and
I
haven't
found
a
real
use
case
and
we've
been
discussing
in
the
breaks
that
right
now,
not
many
people
can
afford
to
start
the
project
over
and
like
just
write
some
things
from
scratch.
So
that
is
why
rust
is
is
a
super
cool
language,
because
you
can
just
write
a
module
and
expose
it
into
your
existing
platform
existing
language
and
then
call
it
from
that.
We're
gonna
see
how
I
did
it.
B
So
it's
me
you
can
find
me
on
Twitter
and
on
the
github
and
I
work
for
a
company.
That's
logo
is
over
there
rising
stack.
We
work
with
nodejs,
which
is
kind
of
invisible
here,
but
so
what
I
do
is
I
describe
it
I
build
stuff
on
the
internet.
That
I
can't
show
my
mom,
because
it's
invisible,
I'm
a
back-end
engineer,
mostly
working
on
infrastructure
and
I
work
with
this
lovely
language
that
we've
heard
so
much
about
today.
Well,
you
know
how
it
works
and
some
more
I'll
stop
bashing
it
in
a
few
seconds.
B
So
it's
not
the
story
about
JavaScript
and
nodejs,
but
it's
a
story
about
how
how
I
hit
the
wall
once
with
no
js'.
It's
actually
me,
but
something
like
that.
So
we've
been
working
on
a
monitoring
product
which
you
know,
application
monitoring
is
kind
of
a
hard
issue
to
solve,
because
we
have
like
processes
that
we
have
to
watch
and
how
they
work,
how
they
operate.
B
And
then
they
in
our
specific
example,
they
reported
once
every
minute
and
then
you
know,
60
processes
will
then
make
up
one
request
per
second
on
average,
and
you
know
a
customer
can
have
up
to
like
hundreds
of
process
to
like
from
one
to
hundred,
and
that
makes
up
for
like
an
average
of
630
processes
per
customer
and
that's
got
the
scale
right.
So
we've
been
trying
to
engineer
an
infrastructure
that
that
can
work
for
huge
HTTP
load
and
we've
been.
B
C
B
It's
just
the
infrastructure
really
that
we
wanted
to
cut
a
few
dollars
at
and
then,
if
you
want
to
use
micro
service
architecture
with
with
Heroku
you're,
just
gonna
end
up
like
this,
because
you
have
to
solve
one
thing
in
that's
authentication
because
Heroku
you
don't
have
you
don't
have
a
VPN,
so
you
don't
have
private
networking
and
then,
if
you
want
to
call
like
in
between
these
services,
you
want
to
communicate
securely.
Then
then
it's
going
to
be
just
a
real
pain.
We
we
went
with
HTTP
signatures.
B
We
tried
a
few
other
things
and
we.
What
we
did
at
the
end
is
that
we,
you
know
you
take
the
body,
you
take
the
parameters,
you
you
take
the
headers
and
then
you
sign
it
with
a
key
and
what
we've
noticed
after
some
time
is
that
these
signatures
were
were
really
really
slow
to
validate.
But
you
can
say
that
well,
of
course,
you've
been
doing
crypto
and
crypto
in
most
languages
really
sought
because
it's
gonna
be
really
slow,
but
you
know
as
it's
fine,
because
you
only
do
it
once
a
request
right.
C
B
B
He
knows
how
how
how
how
slow
it
is
and
how
how
it
is
a
really
complex
task
actually
to
get
to
know
how
these
things
work
and
they
have
a
really
really
long
specification
that
III
really
wanted
to
to
read
it
to,
but
it
had
so
many
external
links
that
it
was
like
no
I
can
do
it.
So,
let's
look
on
the
internet
for
some
for
for
some
already
existing
solution
and
I
found
Google
URL.
Oh
my
god,
this
is
gonna,
be
so
awesome.
B
I'm,
just
gonna
use
this
C++
library
over
here
and
then
you
know
it's
just
use
the
and
the
API,
which
is
a
C++
thing
that
binds
to
v8
and
they
extract
so
a
v8
I
pre,
probably
know
if
you've
ever
worked.
C++.
You
probably
know
this
comic:
how
to
learn
C++
in
21
days
and
at
the
end,
it's
like
you
just
got
a
time-travel,
go
back
and
then
kill
your
younger
self.
C
B
B
B
This
is
a
Kawasaki
Ninja
h2,
which
is
which
goes
at
like
300
kilometers
per
hour
and
then
I
know
something
that's
safe,
which
is
2017,
Toyota
Corolla,
which
was
the
safest
car
in
2017,
but
I
know
one
thing
that
is
also
fast
and
safe,
and
that
is
rust.
So
I
ended
up
using
this
roast.
You
know,
probably
it's
a
systems,
programming,
language
that
aims
to
be
safe
and
current
fast.
B
B
It's
a
common
interface
like
it's,
it's
a
common
thing
to
use
the
interface
in
between
the
languages
and
it's
quite
a
little
level,
but
it
can
be
used
in
multiple
platforms.
So
it's
not
only
for
nodejs.
If
you
write
a
module
that
that
exposes
its
functions
to
an
F,
if
I,
then
you
can
call
it
from
Python
or
any
other
language,
yeah
and
but
there's
more
sillier
serialization
that
we
have
to
do
if
you
use.
B
If
we
use
this,
there's
another
really
cool
project
that
I'm
going
to
show
in
today's
demo,
and
it's
called
me
on
and
what
neon
does?
Is
it
abstracts
away,
v8
types
that
we
can
use
from
from
nodejs,
and
then
it
integrates
much
better,
so
it
it
is
Roscoe
that
we
write
that
integrates
much
better
with
the
VA
types
that
we
are
used
to
using
energy
is
much
tighter
integration
and,
let's
hop
into
some
demo.
What
we
have
over
here
is
the
FFI
library
we've
seen
some
of
these
things
today.
Already.
B
B
For
to
keep
the
names
and
and
stuff
like
that,
and
then
we
have
to,
if
you
look
at
the
top,
you
have
to
use
the
leap
secret
which
which
has
a
few
things
from
so
it
is
used
to
access,
see
type
like
over
there,
and
then
we
can
just
parse.
So
we
get
like
a
car
pointer
over
there
and
we
can
craft
a
C
string,
but
we
have
to
wrap
it
into
an
unsafe
block,
because
it's
we're
using
raw
pointers
over
there
shaky
at
times
and
there's
the
URL
module
from
the
from
the
servo
team.
B
B
There
is
some
other
thing,
so
this
is
the
rossport
and
to
access
it
from
the
OGS.
We
can
just
use
the
FFI
package
and
we
have
to
give
it
the
compiled
binaries
path
and
we
have
to
give
it
the
name
of
the
function
that
we
would
like
to
call
and
the
the
parameters
it
takes
and
what
it
returns.
And
then
we
can
just
expose
it
as
any
other
node
module
that
we
would
would
do
otherwise.
So
this
was
the
FFI
cord
and
you
can
see
if
we
go
back
to
the.
B
And
if
we
look
into
the
native
folder
over
here,
we
have
the
source
file
and
then,
instead
of
having
to
do
any
kind
of
realization,
we
can
just
you
can
just
use
v8
types
directly
and
we
can
craft
v8j
s
strings
and
we
don't
have
to
implement
every
so
in
JavaScript
were
used
to
having
like
functions
that
take
any
kind
of
arguments.
And
if
you
look
into
this
one,
this
this
function
takes
a
call
which
is,
if.
C
B
B
Sony
on
and
then
neon
Bo,
so
we
don't
have
to
worry
about
configure,
and
this
was
this
was
a
real
selling
point
for
me,
because
I'm
not
languages,
I've
been
I've,
been
working
with
nodejs
for
three
years
now,
and
for
me
at
this
whole
C++
and
like
the
compilers
and
stuff
like
that,
they
were
super
scary
and
I
know
for
a
lot
of
people.
They
are,
and
this
neon
project
had
like
a
CLI
tool
that
generated
everything
for
me
and
they
didn't
have
to
worry
about
actually
learning
all
those
bits
and
pieces.
B
C
B
You
are
else
to
generate,
and
then
I
can
run
all
the
tests
functions
on
that
and
I
I.
Try
it
just
once,
but
you
can
set
the
try
count.
You
can
increase
that
so
it
parse
is
the
same
over
and
over
again
we're
going
to
see
why
that
is
important,
I'm
just
requiring
it
is.
If
you
have
ever
written
no
js'
code,
you
can.
You
can
already
see
that
this
integrates
really
well
with
it,
and
what
I
was
thinking
about
is
just
setting
up
a
bit
type
line.
B
B
If
I
try
to
run
it
with
I
can
run
it
with
just
a
single
URL.
You
can
see
that
the
native
this
is
a
time
it
takes
for
them
to
parse
it,
and
then
the
native
URL
parse
was
actually
the
native
I
mean
it
is
the
one
that's
built
into
nodejs
and
the
rust
FFI
one
took
a
bit
longer
than
me
on
its
big,
mostly
because
of
the
serialization
of
this,
and
if
I
try
to
increase
it,
we
can
see
as
we,
the
native
URL
pores
is
actually
getting.
C
C
B
Optimizations
that
we
can
do
and
we
have
to
take
the
right
tool
for
the
right
job
that
we
have,
but
as
we
as
you
see
the
rust
well,
those
those
parts
are
not
optimized
by
the
Java,
the
v8
JIT,
but
we
can
do
other
optimizations
on
the
rough
side
if
we
want
to
so
what
I
wanted
to
say
about
all
these
things.
Where
here
is
the
average
time
it
took
trigger
supports
as
we
went
up,
it
v8
actually
won,
but
it's
not.
B
B
B
B
D
D
D
B
There's
there's
just
gonna
so
on.
Well,
let's
approach
it
from
the
other
side,
if
you,
if
you
use,
if
you
use
it
from
VA
I've
written
native
modules
with
C++
before
and
I
know,
when
you
bind
it
to
v8
scopes,
and
then
you
create
allocate
objects
on
that
side,
then
it's
gonna.
It's
gonna
be
just
much
more
integrated
into
the
garbage
collection
and
stuff
like
that.
So
it's
it's
just
gonna
be
like
more
optimized
that
way,
but
I,
don't
know
why
the
why
why
we?