►
Description
What if we take Rust, compile it to WebAssembly and it becomes the application language of the web? WebAssembly as a target for the web opens up new possibilities and Rust is one of the first languages with full support for it. Together with Jan-Erik Rediger we will get a chance to catch a glimpse of all these possibilities.
Slides: https://fnordig.de/talks/2017/rust-hungary/
[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/
A
B
That's
a
bit
better
anyway,
we
can
get
started
alright,
nice,
that
some
people
turn
up.
We're
really
glad
it's
more
crowd,
that's
good!
So
if
I'm
speaking
too
fast
or
you
have
any
questions
in
between,
we
can
do
the
questions
in
between,
because
we're
not
that
many
I
mean
Eric.
I,
do
organize
stuff,
mostly
rust,
meetup
and
Russ
conferences,
namely
the
rust
fest.
There
will
be
a
run
in
Paris
next
year,
so,
if
you're
into
rust,
please
come
to
the
raw
space.
I
do
work
as
a
software
engineer.
B
You
could
suddenly
do
something
in
the
browser
that
the
user
could
interact
with
without
requiring
going
to
the
server
again,
so
people
started
to
use
it
to
make
funny
little
things
on
the
websites.
At
this
time
of
the
year,
you
probably
saw
some
snowflakes
on
websites
and
so
on,
and
this
worked
quite
good
about
the
JavaScript
interpreter
in
engines.
Back
then
were
simple
interpreters
and
by
today's
standards
they
were
quite
slow
but
Rebecca.
B
It
was
just
enough
yet
like
a
couple
of
lines
of
JavaScript
in
there,
but
at
some
point
people
want
you
to
do
more
in
the
browser
and
JavaScript
just
couldn't
offer
more.
They
random
API
is
to
do
more
stuff
that
needed
to
interact
with
the
system
or
was
the
network
again.
So
at
some
point
we
got
this
massive
monster
called
flesh
and
also
Java
applets,
which
now
allowed
us
to
do
much
more
in
the
browser
we
could
do,
network
requests.
We
could
do.
We
could
stream
video.
B
We
had
interactive
games,
we
even
had
3d
games
in
the
browser,
but
all
of
these
required
flash
or
Java
to
work
and
for
most
parts
that
worked,
but
we
also
hit
some
pretty
huge
roadblocks.
Their
flesh
and
Java
were
never
really
integrated
into
the
browser.
There
are
always
something
built
on
top
and
their
interaction
with
the
website
at
the
flesh
was
always
a
bit
shaky
and
at
some
point
we
also
had
a
lot
of
security
bugs
with
flash
and
Java
running
in
the
browser.
B
You've
got
pretty
much
everything
that
you
had
had
as
the
native
application
before,
and
people
at
some
point
even
took
other
languages
and
compiled
them
to
the
browser,
mostly
to
JavaScript,
to
run
them
in
the
browser.
Because
they're
round
happy
was
writing
JavaScript,
but
for
a
language
that
was
designed
and
implemented
in
like
10
days,
there
was
never.
It
was
never
intended
as
a
target
for
a
compiler,
so
it
couldn't
it
had
all
the
features
one
would
have.
B
Yes,
MDS
was
intended
as
a
subset
of
JavaScript
that
reduced
it
to
just
a
simple
core,
but
that
would
allow
to
be
much
more
optimized
once
the
browser
detects
this
special
mode
of
JavaScript,
and
it
did
so
by
mainly
two
main
features
in
in
the
specification
or
in
the
subset
that
was
used
and
that
are
type
annotations
and
a
flat
memory
buffer
for
all
your
data.
So,
let's
quickly
look
at
what
that
is.
Who
here.
A
B
A
B
Mean
you're,
probably
all
programmers
at
some
point,
so
you
will
understand
this
function.
It's
called
at.
It
has
two
arguments:
X
and
Y.
It
calls
the
plus
operator
and
returns
the
result.
If
you
input
two
numbers,
that's
pretty
easy.
You
call
the
plus
operator
and
two
numbers,
which
is
just
the
sum
of
the
two
numbers.
But
if
you
input
two
strings
into
this
function,
it
will
actually
need
to
concatenate
these
strings,
which
is
a
whole
other
operation
than
the
sum
operation.
But
the
JavaScript
engine
knows
how
to
do
that.
B
But
now,
if
you
pass
in
something
other
than
a
string
or
an
integer
like
an
object
or
an
array
which
is
also
just
an
object
and
something
completely
different
as
well,
well
you're
pretty
much
out
of
luck.
Something
will
happen
but
I'm
pretty
sure
it's
not
the
thing
you
wanted
it
to
happen.
So
there's
a
lot
of
going
on
just
by
calling
the
plus
operator
and
two
unknown
things,
but
every
could
tell
the
compiler
that
we're
only
dealing
with
integers.
B
It
would
be
much
easier
to
run
this
code
because
then
we
could
just
drop
down
to
the
instruction
of
your
CPU
to
do
this
sum
operation
of
two
integers,
but
for
that
we
need
some
way
to
say
that
we
have
a
certain
type
and
JavaScript
doesn't
have
that.
But
what
JavaScript
has
a
sanitation-
and
we
can
now
add
these
annotations
to
tell
the
engine.
That's
running
the
JavaScript
what's
happening
here.
B
We
just
used
the
binary
R,
which
is
zero
to
tell
it
while
we're
dealing
with
integers
a
binary
or
only
makes
sense
when
we
have
integers
at
binary
or
was
a
zero,
doesn't
change
the
value.
So
at
this
point,
we're
telling
the
engine
well,
we
expecting
to
introduce
as
input
and
we're
also
expecting
introduce
the
output
of
this
function,
and
the
engine
can
now
go.
Compile
this
function
down
to
the
instruction
on
your
CPU
and
executed
right
away
without
dealing
with
the
different
types.
B
B
The
other
thing
I
mentioned
is
the
linear
memory
access
if
you're
writing,
JavaScript
you're,
probably
not
thinking
about
memory
too
much
you're,
just
creating
your
objects
or
needs
strings
that
your
integers
using
them
and
at
some
point
not
using
them
and
you're.
You
can
expect
that
the
JavaScript
engine
will
at
some
point
just
remove
the
data.
That's
not
in
use
anymore
and
that's
done
by
the
garbage
collector,
but
the
garbage
collector
runs
randomly
at
certain
points
has
to
stop
it
code.
B
Go
through
all
the
data,
look
at
what
there's
and
unused
remove
the
data
from
memory
and
then
resume
your
code.
These
stop
times
that
it
needs
to
do,
are
quite
unpredictable
and
for
certain
algorithms
are
just
not
acceptable
that
your
code
is
stopped
at
some
point.
So
you
don't
want
that.
So
what
you
can
do
in
s
MJS
instead
is
just
use
a
huge
buffer
of
memory
from
the
point
of
view
of
the
engine.
This
buffer
is
always
in
use.
B
So
there's
no
need
to
stop
your
program
and
remove
the
memory
to
just
use
the
butter
now.
But
now
you
have
to
place
your
data
into
this
buffer
somewhere
and
now.
This
is
completely
up
to
your
application.
How
this
buffer
is
used
if
you're
coming
from
C
background
or
it
may
rust,
but
it's
pretty
similar
or
how
the
heap
is
handled.
They
also
only
have
some
attack
pointers
into
some
memory,
and
you
have
to
deal
with
this
yourself
and
see.
B
You
have,
for
example,
mellow
and
free
which
do
the
heavy
lifting
for
you,
so
you
don't
actually
have
to
track
it
yourself,
but
Melek
does
that
for
you,
but
now
this
perfectly
maps
to
a
SMGs
people
did
use
that
to
some
extent
and
they
built
on
top
of
that,
but
they
had
other
roadblocks,
mainly
because
it's
JavaScript
and
JavaScript
does
not
have
all
the
features
we
want.
So
that's
when
they
sat
down
and
thought
about
what
they
need
on
top
of
that
and
that's
when
webassembly
was
born.
B
B
Representing
is
also
a
general-purpose
virtual
architecture,
it's
comparable
to
your
x86
code
or
Java
bytecode.
It
basically
gives
you
a
few
operations
and
the
semantics
of
these
operations
and
the
engine
implements
that
and
can
execute
it.
It's
also
modeled
in
a
way
that
it's
easily
transferable
to
actually
x86
machine
code.
So
there's
not
a
huge
step
from
web
assembly
to
actually
running
on
the
CPU
web
assemblies
alter
compiler
target.
B
So
there
are
people
from
all
major
browser
when
you're
sitting
in
this
community
group
are
discussing
what
features
representing
would
need
and
how
to
implement
them,
and
by
now
it's
enabled
in
Firefox,
in
chrome
and
edge
and
in
Safari
and
even
in
Mobile
Safari,
so
he
pretty
much
can
use
representing
everywhere
by
now,
when
speaking
world
representing,
we
also
need
to
think
about
what
represent
leans.
Not
because
people
tend
to
confuse
and
get
a
bit
too
excited
about
representing
webassembly
is
definitely
not
a
replacement
for
JavaScript.
B
It
will
happily
lift
side-by-side
with
JavaScript
for
the
foreseeable
future,
and
none
of
the
application
that
you're
using
today
will
be
rewritten
tomorrow.
To
represent
me.
It
just
doesn't
make
sense
and
represent,
is
just
not
a
future
rich
enough
to
to
handle
that
right
now
what
assembly
is
also
not
necessarily
a
programming
language?
You
can
write
in
the
assembly
instructions
yourself,
but
just
as
you
wouldn't
do
that
for
you
in
86
or
our
machine,
except
in
very
extreme
cases,
you
don't
need
to
do
that
for
represent
lis,
except
maybe
for
learning.
B
Web
assembly
is
also
not
a
target
for
every
language
out
there,
yet,
especially
for
languages
that
have
a
heavy
runtime
and
a
lot
of
additional
features
on
top
things
like
Java
or
even
JavaScript
itself,
or
Ruby
or
Python
that
have
their
own
runtime.
A
garbage,
collector,
bundled
wisdom
are
not
easily
translatable
to
represent
me
by
now.
It
will
get
easier
in
the
future,
but
for
now
C
or
C++
and
rust
are
the
main
languages
that
you
can
use
to
target
web
assembly
in
the
end.
B
B
We
can
now
write
code,
that's
a
lot
smaller
than
a
SMGs,
it's
a
binary
format
and
then
coding
especially
made
in
a
way
that
most
things
that
we
need
to
put
in
there
a
pretty
incredible
in
a
very
few
bytes,
and
it
also
makes
it
a
lot
faster
to
parse
in
the
JavaScript
itself
is
not
that
kind
of
net
new
Java
language,
it's
still
very
hard
to
parse
with
webassembly.
It's
a
lot
easier.
B
Basically,
you
just
need
to
go
through
the
web
assembly
code
once
check
that
it
adheres
to
been
coding,
and
then
you
can
compile
them
and
with
rep
assembly.
We
need
now
also
have
the
freedom
to
extend
their
platform
of
the
features
we
needed.
One
thing,
for
example,
in
JavaScript:
we
still
don't
have
our
integers
above
in
the
range
of
64
bit
or
even
larger,
which
rep
assembly
will
will
have
these
natively
and
for
a
rep
assembly.
There's
a
formal
specification
that
all
browser
vendors
agree
on.
We
didn't
have
that
for
flesh.
B
It
was
just
implemented
once
we
didn't
have
that
for
the
Java
integration
into
the
browser
really
and
even
for
a
SMG,
as
not
every
browser
implement
that
that
or
agreed
on
the
specification
so
for
web
assembly.
We
now
have
a
specification,
I'd
hit
version
one
earlier
in
the
beginning
of
this
year
and
all
browsers
implemented
that
and
for
we
can
be
pretty
sure
that
they
continue
to
implement
the
same
thing.
B
B
I
also
used
C
as
an
example,
because
it
was
a
little
bit
easier
then,
but
we
won't
write
C
I,
traversed
Meetup,
so
we've
got
a
red
rust
and
thanks
to
this
pull
request
to
the
rest,
language
called
add
a
new
wasn't
30
to
an
unknown
target.
We
now
have
a
target
in
the
rust
compiler
that
allows
us
to
compile
rust
natively
to
web
assembly
without
additional
tools.
This
actually
landed
in
the
rust
compiler
a
few
days
ago,
it's
already
in
the
nightly
compiler,
except
that
the
LLVM
site
is
not
prepared
for
that.
B
But
that
should
happen
in
like
one
or
two
weeks
as
well,
so
you
kind
of
can
use
it,
but
you
still
need
to
hack
a
bit
around
that
I'm
gonna
skip
about
the
hacking
part
and
just
show
you
how
you
can
actually
spit
out
web
assembly
so
anyway.
This
is
some
rust
out.
We're
gonna
greet
Budapest
good
evening.
Budapest
I
returned
that
as
a
string
all
right
now,
we
still
need
to
basically
right
binary,
so
we
need
the
main
function,
even
though
it
will
be
removed
later.
B
It's
just
for
the
compiler
to
do
the
right
thing
and
there's
a
few
interesting
things
about
that.
First,
we
need
a
attribute
attribute
called
no
mangle
by
default.
The
rest
compiler
will
use
mangle
algorithm
to
don't
duplicate
any
symbols
in
the
compiled
file,
but
obviously
we
want
to
call
this
function
read
and
we
need
to
have
the
name
greet
in
the
final
executable,
so
we
don't
need
to
mangle
it.
We
also
want
to
give
it
a
third
and
a
VI
and
we're
using
the
same
API
accede
us
by
using
external
see.
B
This
beta
just
defines
how
we
pass
arguments
back
and
forth
between
functions,
and
we
returning
a
static
string
here,
which
will
come,
will
be
important
later
so
now,
if
you
want
to
compile
this
code
with
west
to
native
code,
you
just
call
Russy,
let
it
optimize
give
it
the
file
and
it
does.
Its
thing
will
not
do
anything
because
the
main
function
is
empty,
but
we
can
compiler
to
represent
me
now
with
this
new
target,
which
basically
means
we
passing
a
few
more
flags
and
we'll
do
the
right
thing.
B
We
then
need
to
actually
garbage
collect
the
weapons
Emily
file
a
bit
because,
right
now
we
don't
have
any
optimizer
in
there
and
there
will
be
a
lot
of
useless
crap
in
there.
So
this
step
will
go
away
once
the
linker
from
LLVM
is
actually
capable
of
doing
rep
assembly
itself,
but
for
now
we
can
remove
a
lot
of
the
stuff
in
there
using
wasn't
easy
and
what
we've
did
all
this.
This
is
what
we
get.
B
This
is
the
hectic
coding
of
a
small
part
of
the
web
assembly
module
largest
compiled,
and
you
can
already
see
a
few
things.
If
you
can
read
hex,
you
might
actually
see
that
it
starts
with
a
SM.
This
is
just
a
metric
header
in
the
file
telling
Brady
through
the
browser,
the
engine
that
it's
actually
a
web
assembly
file
arm.
If
you
look
a
bit
further
down,
you
see
more
words,
there's
the
word
about
memory
in
there
and
further
there's
the
Greek
in
there.
B
Reading
hex
code
is
really
hard.
So
when
webassembly
was
built
up,
they
already
thought
about
that.
There
needs
to
be
a
text
format
of
the
same
code
and
there
are
now
also
tools
that
just
translate
from
one
for
me
to
the
other.
We
can
format
to
the
what
format,
which
is
the
text
format
of
web
assembly
using
a
tool.
The
code
wasn't
too
well.
If
we
do
this
and
look
at
the
code,
we
basically
see
a
list
like
language
that
includes
the
same
things
that,
as
the
binary
before
we
have
some
media
data.
B
B
So
the
thing
about
references
and
rust
is
that
there
most
of
the
time
of
what's
called
fat
pointer
and
it's
actually
just
a
pointer
to
some
data
and
the
length
of
the
data
behind
this.
Where,
as
you
see,
you
usually
just
have
a
pointer
and
it's
up
to
you
to
figure
out
how
large
the
object
behind
that
pointers
in
rust.
Most
of
the
time
you
get
the
actual
length,
so
what
this
code
is
doing
is
actually
getting
a
parameter,
which
is
just
an
integer
as
an
input
parameter.
B
It
will
then
store
the
length
of
the
value,
our
string,
which
is
21
bytes
long
into
the
lower
four
bytes
of
this
past
index
and
will
then
store
the
pointer
to
the
actual
data
in
the
upper
Courbet's.
I
have
no
idea
why
it
does
it
that
way.
I
could
just
do
it
the
other
way
around.
First,
all
the
pointer
then
the
length,
but
that's
just
how
the
code
compiled
now
it
doesn't
really
matter,
but
what
we
will
have
in
the
end.
B
We
need
to
pass
it's
important
to
some
form
of
memory
where
it
will
write
to
values
the
pointer
to
the
actual
data
and
the
length.
Now
this
is
the
module
that
we
have
to
actually
execute
it
from
the
JavaScript
side
and
get
access
to
this
data.
We
need
to
do
a
bit
a
little
bit
more
work
around
that,
so
we
have
a
few
helpers.
This
is
again
a
bit
of
JavaScript
and
basically
just
gives
us
the
memory
that
we
need
for
our
two
values.
B
Now
we
need
to
get
set
before
the
pointer
and
the
length
and
we
are
using
a
32-bit
architecture
here.
So
we
just
pass
it
right.
4
bytes,
this
alyc
function
is
actually
a
pretty
simple
alligator,
that's
exported
from
the
same
representing
module
which
I
haven't
shown
me
for
arm.
It
basically
just
gives
you
a
block
of
memory
in
the
memory
buffer
that
rust
sees,
and
if
you
know
C,
you
pretty
much
know
already.
That
pointers
are
just
numbers
and
that's
how
they
are
handled
in
web
assembly
as
well.
B
B
The
data
from
that
we
passed
in
before
follows
the
pointer
to
the
actual
data
in
memory
copies
out
the
number
of
bytes
that
the
length
specifies
turns
that
into
an
utf-8
encoded
string
in
JavaScript
and
returns
back,
it's
still
a
little
bit
of
banging
around
instead,
but
you
basically
write
this
code
once
and
then
can
use
it
from
the
JavaScript
side,
so
you
can
actually
interact
with
the
web
assembly
module
now.
If
you
want
to
execute
that
in
the
browser
you
have
this
nice
little
API
for
handling
rep
assembly.
B
Basically,
you
fetch
the
data
from
the
server.
Are
you
turn
that
into
an
array
buffers?
So
you
have
the
actual
bytes?
Then
you
call
the
web
assembly
module
where
you
call
the
compile
function
and
give
it
this
buffer
and
the
compile
function
actually
does
not
compile
anything.
It
just
checks
that
it's
valid
web
assembly
from
that
Eugene
then
need
to
instantiate
a
module
which
then
actually
compiles
the
code
and
gives
you
back
an
object,
which
also
has
all
the
exports
on
there.
B
Now,
there's
a
bit
more
code
than
I
have
actually
shown
the
web.
Slides
are
online,
it's
actual
JavaScript
in
there,
so
it
could
read
the
source
code
if
you
want,
if
you
don't
want
to
view
the
slides
I'm
at
the
side,
hello,
Roz,
calm,
where
I
will
collect
all
these
things
in
the
future,
how
to
make
it
happen?
What's
the
different
pieces,
you
need
there,
it's
pretty
bare-bones
right
now,
but
over
the
coming
weeks,
I
will
extend
this
quite
a
bit.
B
So
what's
missing
from
this?
Well,
this
planet,
the
new
target
just
landed
pretty
much
most
of
the
parts
from
the
standard
library
of
rust
are
currently
just
returning,
nothing
they're,
basically
just
crashing,
because
there
was
no
time
and
no
sensible
way
to
implement
this
by
the
way
everything
that
handles
file
operations
or
network
operations
or
anything
that
a
real
operating
system
would
do
for.
You
are
not
in
the
standard
library
for
this
target,
because
representa
has
no
notion
of
that.
B
We
also
need
a
lot
more
testing.
Basically,
this
will
just
be
well
enable
testing
for
my
crate.
At
some
point,
we
have
some
ideas
that
we
will
do
this
on
all
crates
that
are
published
on
crates
at
I/o
at
some
point,
so
we
can
actually
see
how
much
of
webassembly
it's
already
working,
but
if
you're
interested
and
want
to
see
what
works
and
what
does
not
work
just
play
one
with
it.
B
It's
really
fun
to
experience
a
lot
of
packs
in
libraries
that
were
never
intended
to
be
compiled
to
the
browser
and
see
what
breaks
I
did
that
for
certain
libraries
and
fixed
bugs
and
in
the
end,
also
fixes
wheel
bugs
in
these
libraries
anyway
and
of
course,
a
lot
of
documentation
and
tutorials
and
examples
are
just
not
there.
Yet
I
intend
to
put
a
lot
of
this
onto
hello,
Roz
calm,
but
people
will
experiment
with
this
and
bright
more
tutorials.
B
B
My
personal
idea
is
also
that
web
pack
will
have
easy
integration
with
retro,
sembly
and
rust.
They
already
have
integration
with
rep
assembly
and
they're,
trying
to
figure
out
how
to
do
that
as
efficiently
for
the
developer
and
for
the
compilation
process,
and
my
idea
is
that
at
some
point
we
can
just
drop
our
rust
files
into
your
project
and
cold
web
pack,
and
web
pack
will
also
just
compile
everything
rev
it
up
into
we're
personally,
module
export
the
things
to
your
JavaScript
modules
and
they
can
access
it.
B
B
Yes,
so
that's
like
basically
one
thing
about
webassembly:
the
version
that
we
currently
have
enabled
in
the
browser
is
intended
as
an
MVP
as
the
most
viable
product
that
I
could
ship
this
year,
but
there
were
always
ideas
to
add
new
features
and
it
was
built
in
a
way
that
these
futures
could
be
added.
It
was
just
a
matter
of
designing
these
systems
and
actually
the
threading.
B
A
B
That's
really
hard
to
say,
but
so
what
I
think
like
for
everything
that's
doing
anything
performance
was
in
the
browser.
The
very
first
examples
and
demos
out
there
are
always
games
because
they
benefit
a
lot
of
from
these
performance,
wins
so
they're,
already
game
engines,
3d
game
engines
compiled
to
that
assembly
running
in
the
browser.
I
think
it
will
be
quite
interesting
to
see
a
full-blown
game
that
you
can
run
in
the
browser
without
needing
to
install
anything
besides
downloading
the
resources
once
that
will
be
one
thing.
B
I
also
know
about
a
few
projects
trying
to
do
certain
video
algorithms
in
the
browser.
For
once
you
saw
me
interacting
with
the
demo
at
the
beginning,
which
was
Ellie
doing
some
filters
over
some
live
video.
That
will
be
quite
interesting.
There's
a
new
codec
in
development.
They
want
to
use
rep
assembly
to
test
out
this
codec
in
the
browser
and
share
samples
of
the
running
code
through
just
putting
represent
me
on
the
side.
B
So
you
can
actually
share
this
running
code
with
people
and
debug
it
so
I
think
these
multimedia
applications
will
be
one
of
the
very
first
things
that
will
make
heavy
use
of
it.
The
other
thing
I
see
is,
for
example,
ember
is
rewriting
their
glimmer
engine,
which
is
basically
their
engine.
That
does
all
this
dumping
and
rendering
they're
rewriting
this
in
rust
in
rust
and
compiling
that
rep
assembly,
because
they
actually
see
their
glimmer
engine.