►
Description
For over 20 years, JavaScript was the only scripting language you could use reliably in a browser. That all changed a few years ago, when WebAssembly became supported by all major browsers. This talk is a 29,032-foot overview of WebAssembly, why it's awesome, and how to get started using it. As concrete use cases, Robert will mention two open source tools he contributed to where WebAssembly improved performance, and enabled reusing C/C++ code on the web. The talk will also cover upcoming WebAssembly features such as threads and SIMD, and will end with a discussion of use cases where WebAssembly shines (...and when the added complexity might not be worth it!)
A
So
let
me
start
by
introducing
myself,
so
my
name
is
robert
buchaliel
and
my
background
is
a
mix
of
software
engineering
and
bioinformatics,
I'm
the
maintainer
of
the
library,
bio
asm.
So
this
is
a
collection
of
bioinformatics
tools
that
we've
pre-compiled
to
webassembly
and
are
hosting
for
free
on
cdn,
so
that
other
bioinformatics
web
apps
can
make
use
of
it.
A
I'm
also
the
author
of
the
book
level
up
with
webassembly,
so
if
you're
just
getting
started
with
webassembly
feel
free
to
check
it
out
all
right.
So
what
is
web
assembly
anyway?
Well,
I
like
to
think
of
webassembly
as
really
just
being
yet
another
language
that
you
can
use
in
the
browser,
alongside
javascript,
html
and
css.
A
A
Now
you
don't
need
to
know
anything
about
webassembly,
just
looking
at
this,
you
can
tell
this
is
not
a
language
that
you
probably
want
to
code
and
that's
good,
because
you
don't
have
to.
In
fact,
the
whole
idea
of
webassembly
is
that
you
can
take
code
written
in
other
languages
and
compile
that
down
to
webassembly,
and
so
that's
why
it's
called
a
compilation
target,
because
you
take
code
written
in
these
other
languages,
compile
it
to
webassembly,
and
then
you
run
it
in
the
browser.
A
A
You
know
all
these
applications,
I'm
showing
here
are
very
large
code
bases,
hundreds
of
thousands
millions
of
lines
of
code
where
web
assembly
was
really
essential
to
let
them
transition
these
apps
from
running
on
a
desktop
or
in
a
command
line
onto
the
web,
without
having
to
rewrite
everything
in
javascript.
So
this
is
very
convenient
from
the
code
reusability
perspective.
A
The
other
big
use
case
is
performance,
so
in
in
these
four
applications.
What
they've
done
is
look
at
the
most
compute
intensive
part
of
their
apps
that
were
written
in
javascript
and
replaced
those
with
webassembly
and
what
they
noticed
was
a
large
speed
up
and
better
performance
now,
of
course,
sidenote.
This
is
not
guaranteed
to
work
right.
A
Just
because
you
use
webassembly
does
not
mean
that
your
app
will
always
be
faster,
but
for
a
certain
category
of
data
intensive
applications,
it
can
help
the
other
use
case
behind
webassembly
is
portability,
so
the
idea
here
is
that
you
can
also
use
webassembly
outside
the
browser
really
anywhere,
where
you
can
find
a
webassembly
runtime
that
can
execute
your
code.
You
can
have
webassembly,
and
so
here
I'm
showing
for
examples,
for
example,
cloudflare
and
fastly.
These
are
providing
serverless
functions
that
run
webassembly
at
the
edge.
A
The
nice
thing
about
using
webassembly
for
serverless
is
that
they
initialize
a
lot
faster
and
are
cheaper
because
webassembly,
you
know,
is
more
a
lot
more
lightweight
than
using
containers.
For
example,
you
can
also
run
webassembly
on
your
server.
If
you
use
runtimes
like
wasm
time,
wasmer
or
even
node.js
right
can
run
webassembly.
A
A
One
thing
that's
interesting,
though,
is
you
know
how
many
developers
actually
use
webassembly
and
so
to
get
a
sense
for
that?
What
we
can
do
is
look
at
the
state
of
javascript.
This
is
a
survey
that
is
done
every
year
they
pull
20
000
javascript
developers,
and
one
of
the
questions
they
ask
is:
are
you
familiar
with
webassembly,
and
so
here
are
the
results.
A
A
Now
you
know
I'm
kidding.
Of
course,
that's
not
how
anything
works,
but
it
will
be
interesting
to
see
how
that
number
actually
plays
out
over
time.
A
A
It's
also
problematic
because
you
need
to
make
sure
that
it's
secure
and
it
doesn't
accidentally
let
users
execute
arbitrary
commands
on
your
servers
and
start
mining
bitcoin,
but
but
also
there's
a
data
upload
issue
right.
You
know
the
main
use
case
for
this
application
was
to
analyze
files
that
were
already
on
the
user's
local
computer,
and
so
this
would
be
inconvenient
to
have
them
uploading
the
data
to
the
cloud
before
they
can
even
analyze
it.
A
A
So,
despite
the
the
challenges,
we
ended
up
going
with
option
number
two,
so
we
rewrote
a
small
portion
of
the
tool
ctk
in
javascript
and
it
worked.
A
However,
then
I
came
across
webassembly
and
that's
when
the
third
option
opened
up-
and
this
is
really
where
webassembly
shines
like
these
are
all
existing
tools
that
are
written
in
in
languages
other
than
javascript,
that
we
can
now
compile
to
webassembly
and
run
directly
in
the
browser.
A
A
A
Part
of
this
application
involves
parsing
a
special
bioinformatics
binary
file
format,
and
to
do
this
parsing
we
have
a
few
existing
tools
that
we
can
use
written
c
and
rus.
You
know
again,
this
is
very
often
the
case
in
bioinformatics,
by
the
way
where
a
lot
of
the
tools
are
written
in
c
and
c,
plus,
plus
and
rest
and
so
on,
and
so
here
we
kind
of
end
up
with
the
same
situation
right
in
terms
of
implementation.
A
But
after
the
success
that
we
saw
with
fastq
bio,
we
figured
well,
let's
try
webassembly
here
as
well,
and
so
what
we
saw
was
again.
Interestingly
enough,
we
saw
a
two
to
three
x
improvement
in
terms
of
runtime,
but
probably
even
more
important
than
that.
We're
we're
now
able
to
reuse
a
hundred
thousand
lines
of
very
complicated
c
code
that
parses
unique
genomics
file
formats.
A
A
All
right,
so,
if
you're
building
these
kinds
of
data
intensive
web
apps,
there
are
several
interesting
tools
that
you
can
use
with.
Webassembly
and
one
is
threats
you
know.
Obviously,
a
lot
of
tools
use
threads
to
speed
up
execution
and
webassembly
does
support
threads
using
web
workers
and
the
way
that
shared
memory
is
implemented
between
threads
is
using.
This
thing
called
shared
array
buffer.
A
So
you
know
we're
getting
there,
but
we're
not
quite
all
the
way
there
and
so
for
if
you
are
using
threads.
It's
probably
a
good
idea
to
use
feature
detection
where
you
test.
Does
the
user
support
shared
array
buffer
then
use
webassembly
with
threads,
otherwise
use
the
version
of
the
webassembly
binary
that
does
not
have
threading
in
it.
A
Another
really
powerful
tool
is
simdi,
so
cimd
stands
for
single
instruction,
multiple
data,
and
the
idea
is
that
this
is
a
way
to
parallelize
code
that
is
very
commonly
used
in
data
analysis,
image,
processing
and
so
on,
and
so
the
idea
is,
as
the
name
suggests
you
can
process.
Multiple
data
sets
within
a
single
cpu
instruction.
A
A
A
Now
I
recently
did
a
test
drive
of
webassembly
simd.
What
I
wanted
to
do
was
essentially
align
dna
sequences
to
a
reference
genome
and
benchmark
the
run
time
with
and
without
webassembly
simd,
and
what
I
found
was
really
really
interesting,
where,
as
you
can
see,
the
webassembly
with
simdi
gives
us
pretty
close
to
the
native
cmd
performance,
but
in
the
browser
which
is
really
fantastic
for
those
applications
that
can
benefit
from
some
d
now.
What's
really
interesting
about
this
is
that
you
know
when
we
compare
performance
between
javascript
and
web
assembly.
A
One
can
always
argue.
Well,
you
didn't
optimize
your
javascript
enough
and
it's
not
because
of
the
web
assembly
that
your
app
is
faster
and
that
could
be
very
true.
But
when
now
we're
talking
about
simd,
this
is
a
whole
new
game,
because
javascript
does
not
have
access
to
cmd
instructions,
whereas
webassembly
does,
and
so
this
is
why
this
is
a
really
really
exciting
advancement.
A
And,
finally,
you
know:
code,
reuse
and
performance
are
really
nice
and
all.
But
it's
also
important
that
we
consider
the
complexity.
The
webassembly
adds
to
our
code
base
to
our
build
process,
but
also
to
the
maintainability
of
the
code
for
your
entire
team
right.
It's
it's
a
bit
hard
to
give
concrete
examples
here,
because
this
will
really
depend
on
your
team
and
how
comfortable
they
they
are
with
with
introducing
something
like
webassembly,
but
at
the
end
of
the
day,
webassembly
is
a
really
powerful
tool.