[Music]
hello all right awesome so like they
said we ate webassembly and the future
of JavaScript and a multi-language web
so as I mentioned I'm Casper ch besides
being a developer avocado at CloudFlare
I am also a robotics author and addict
I've written two books on using
javascript with robotics
I also twitch stream hardware and
software on Sundays from node botanist
so yeah I'm also a parent of two cats
and like they're my favorite like
animals Laurel so that's ace on the left
and that's Aria on the right and they're
very angry with me because I've been
gone for like three weeks and I may be
done for like another week they're
really mad at me right now anyway yeah
that's not what you're here to here here
to here about come on what even is
webassembly
this is a five-year-old technology and
we're still answering I and the quiet
when you when you think about why it's
because no one's figured out how to use
it until now oh people who are very very
hard to make this more accessible but we
still need to kind of have this talk
about like what is it even because I
think it's easier to answer what it's
not first it's not a programming
language like you don't you ever run
LinkedIn recruiters would say like you
need ten years of nodejs experience like
in 20 in 2008 like it's it's like saying
I'm a web assembly programmer like you
don't you don't program and webassembly
you don't write web assembly the second
is web assembly is not going to kill
JavaScript if javascript is the
cockroach of everything it's never going
to die but especially not to web
assembly because it's not meant to kill
javascript and what assembly is not
something you can just ignore because
it's gonna go away I hope to convince
you in the next you know 28 or so
minutes
if anything you should be embracing it
because it's the future
so whatever sorry button
what webassembly is it is a compilation
target for other languages to compile to
you compile other languages to
webassembly and it's a specification and
a compiled target
it's an augmentation of the abilities of
JavaScript far from replacing JavaScript
it is there to let JavaScript do what it
is good at and then do things that
javascript is not good at and give back
the results but most importantly it's
pretty literally magic not literally
literally but like I'll explain it a bit
there's a pun involved you know it's
fine
so web assembly has a compilation target
you write code in other languages and
then compile them into web assembly rust
which is pretty much written for web
assembly C and C++ go C sharp those are
just a few of the languages that have
web assembly available is like a pile
target there are way too many to mention
and I'm certainly forgetting a few but
those are the four main ones that I can
think of just right off the top of my
head especially with rust being pretty
much written to be optimized for web
assembly though it's also just a pretty
cool programming language if you ever
get a chance to try it but then the
question you have to ask is what why why
would you write code for the web and
other languages why would you do this
why would you take pictures of Laurie
Voss while he's giving talks like this
and then use them in other dogs there
are so many reasons you would a want to
take pictures you Laurie Voss and B have
webassembly in your life this is the
next Ajax for the browser and like I've
been seeing that a lot this weekend I've
gotten this reaction quite a few times
like oh yeah sure cats the next Ajax
okay cool but I mean it I'm I'm very
serious in the sense that Ajax gave huge
credibility and made client-side
applications possible and this is an
evolution of that this is the next step
of that
and that is an adorable Pokemon gift
that I found this morning and I was like
oh well now I gotta stick that in there
and so I had to pick the word evolution
to like stick I write slides around
gifts if you haven't noticed so now
you're like alright maybe maybe it's
like eight the next Ajax but like I'm
not whatever percent committed this is a
drawing that I did in OneNote this
morning of this is what I call ancient
dot PNG so this is back when we had HTML
renderers CSS engines and we had
JavaScript and all JavaScript did was
play mp3s in the browser annoyingly when
you opened a page thanks to MySpace and
back then the server had literally
everything everything was over here
where did my G go anyway um so you click
a link and it would return a page and
you click a link and it would return a
page and so on and so forth
you get a browser refresh every time you
needed new information from the server
so now this is what I call then dot PNG
we got Ajax which that's not the right
button that's the right button got Ajax
request the page and then get the page
and then we make an AJAX request without
refreshing the page and we'd get back a
result Ajax result a grx result maybe
there'd be another page request we got a
lot of single page applications out of
that as well and then the server became
a REST API that also served up the
occasional HTML CSS and J's file right
so this is what I call now this is what
I call now because now we have and web
assembly and I ran out of like sparkly
colors so I have to use like this like
red and black super goth but it sticks
out so it works see a request the page
returned the page and then you use WebP
is simply to do some computation but
you're still over here in the browser
and use the serviceworker for your
third-party module and you're still over
here in the browser you use some Ajax
and your servers like lawl okay I'm not
even actually a server I'm just a server
list function sitting on someone else's
server and then gives back your results
we're heading ok now you're thinking ok
I get it
ok this is starting to make a little
more sense being able to compute things
in the browser and not necessarily have
to do it in JavaScript it's kind of a
big deal this is kind of important but
why does this matter why why do we
really care we care because we need to
augment Jaso that's not so strong points
because I know this is something you've
probably either heard a million times
and is sick of hearing or it's blasphemy
or whatever but there's some things that
jeaious isn't really good at not
rewriting entire code bases to use them
on the web who wants to rewrite an
entire code base of any library that's
like more than five years old and has
unit tests yeah Eli hands me neither
there's no good fewer calls as a server
means less latency and it means faster
web applications for your users that's
always important performance is good
not having go back to the server a
billion million times is good so let's
talk about augmenting JavaScript it it's
not so strong points I'm sure you've
seen this at least once in your
JavaScript career 0.1 plus point two is
actually point three zero zero zero zero
zero zero zero zero four so that's false
and so if you're running anything that
relies on mathematical numerical
accuracy financial applications anything
they with socks or bond trading Kirt
currency conversion anything really that
requires games require a lot of math
precision it's not really a JavaScript
strong point obviously you would need an
ajax call back to a server that would
run a different language and give you
back the actual result which then you
know might get converted incorrectly
even though with web assembly you can do
this in the browser with the correct
tool for the job with rust with see with
with languages that have float types
that are more than 32-bit other not so
strong points we've got type coercion
side-effects empty string equals equals
zero is true it's really hard if you're
trying I can like say did they enter a
number other than zero
oops API overloads so it's this one is
new to me actually so if you oneplus
document.getelementbyid II value it
concatenates but if you put number
around that it adds it even though
that's not really like a number or it
might not be a number it might be an an
and then it's 1 plus 9 which is nan
probably see I mean like tight coercion
can be tricky and then speaking of types
the mystery that is type of like that
last one it has infuriated so many
people over the years
using webassembly means using the right
tool for the job if you've ever seen me
speak before you might have seen me to
have a talk about fanaticism and I
talked about using the right tool for
the job and webassembly is using the
right tool for the job on the web we are
no longer forced to use JavaScript for
things that it is not good at and that
is a big deal that is huge for the web
that is huge for browser applications
but this will kill JavaScript oh we're
gonna have all these applications that
are only written and web assembly and
it's gonna no just calm down calm down
it's not gonna kills us
it makes JavaScript better by letting it
do what it's good at Dom manipulation
react and other frameworks have made Dom
manipulation ridiculously fast and GIS
engines have made Dom manipulation
ridiculously fast
I don't think web assembly is gonna beat
JavaScript and Dom manipulation anytime
soon it might in the future distant
future but I don't think it's gonna do
it anytime soon and it's good at
manipulating classes CSS things like
that it's not gonna replace CSS is
either certainly under play CSS so it's
a good at augmenting websites that use
JavaScript and you will still probably
use JavaScript on top of that it's just
letting JavaScript kind of like take a
load off on things that's not so great
at it's like so my fiance and I but if
you don't say hates doing laundry like
with a burning passion and he's bad at
it like a really bad at it and I hate
doing dishes and I'm really bad at it so
I do all the laundry and he does all the
dishes everything's fine except right
now because he has to do his own laundry
because I've been gone for three weeks
he only has two weeks worth of clothes
it makes the web better by creating
better browser experiences which is
exactly what Ajax did these better
browser experiences are mind-blowing
when you think of the implications like
Jeff Goldblum mind-blowing but let's
take a closer look at what I mean by
this with a demo this demo is using Waze
image magic if you haven't used image
magic before it is a command line and
see library that is extremely good at
creating and manipulating images it can
create animated gifs
don't at me about that pronunciation it
can create images of its cell I can
create fractal images it's a very
powerful library that I don't want to
rewrite in any language much less
JavaScript we're gonna manipulate images
in the browser up to ten times faster
than JavaScript can and in some ways
that JavaScript just can't at least
certainly not performing Lee and it's
kind of show the real power of not
having to rewrite code and being able to
let us use the right tool for the job so
let's take a look and hope it works
because it's worked every other time so
it won't work this time you know what I
mean okay get my webcam turned on say
select an image and I'm gonna go down to
Ken oh I always look silly in photos so
like I look silly on my terms
okay so these buttons say I'm going to
make this a little bigger so you can see
so I guess my tongue and the buttons so
we're gonna rotate right and below it
you'll see it's rotated right and that
was really really fast rotate left same
thing you can do that with CSS really
quickly though right like this is not
that impressive let's do a grayscale
boom grayscale
right no flash let's add some contrast
BAM added contrast let's remove some BAM
removed contrast can't chance do that
that quickly nope so yeah that's my demo
I will tweet out a link to the github
repo this is entirely open source so you
are more than wha
to play with it yeah so that's my demo
yeah thank you but what about nodejs
wait but but what about nodejs like this
is a browser thing right like this is
this is just this is a browser
technology I just did all that talk
about the browser why am i bringing up
nodejs because this is a note cough I'm
in the wrong spot right that's an
Ireland that's also he's gonna smoke up
of you yeah yeah why am i okay the
reason I'm bringing it up is native heck
in modules who has ever seen a C
compilation error when running npm
install' most of your hands should be
going up because this has happened to a
lot of people native heck in modules are
a huge pain point in node and they are
ridiculous and they make you want to
yell what Bryan Cranston is yelling you
can probably read his lips on this one
because it's like and he's saying blah
obviously he's not saying you know the
other word blogger native modules of
Japan they have to be recompiled on
download and they have to be recompiled
for every single architecture there is
that includes the raspberry pi that
someone will inevitably file an issue on
your library because it doesn't work on
the Raspberry Pi it wasn't meant to well
it didn't well it isn't meant to and
then you have that argument for TOEIC
days on github they either have to
compile for your platform or leave left
platforms for support and that can be
kind of tricky again that's the same
github argument or you could just feel
bad does it means heater because like
I'm sorry this doesn't work on Windows
who's been like I'm sorry but this
doesn't work on Windows it's not a fun
feeling to say that and no chip
disclaimer I respect the heck out of the
people who work on no chip like that
they have an insert they with Sisyphean
task like an insurmountable task so I
respect the heck out of them but
webassembly works on node anything
higher than 8.0 so this is math why why
this might matter why does it matter
that webassembly works on node 8.0 knob
webassembly modules are precompiled for
note j s not for the architecture so
they're portable to any platform that
runs node so no more recompilation on
download for every architecture yes for
reals yes I tried it you can try it too
it's pretty awesome
so this quote is from Laurie this
morning
everyone wants to deprecate note chip
and webassembly would allow us to do
this that's huge for know jazz that is
and that's the near future note 8 is at
the end of life and anything below no 2
8 is not being supported that doesn't
mean people don't use it I mean people
still use Android like 300 off of water
literally just hit me on the head sorry
this confusing thing that's ever
happened to me there's an arrow it's
actually okay I'm just gonna not stand
there cuz there's water dripping up that
spot okay so webassembly is even
invading serverless for instance I work
at CloudFlare and we have clouds where
workers which run the v8 engine so you
can run webassembly on serverless which
is pretty cool we have a free tier now
for those of you not in this audience
and I mean a hypothetical those of you
like maybe those of you who are watching
this video or a live stream whoever like
but you don't have a free tier and I
don't want to pay and I get that don't
get me wrong I hate paying for things
too if you scan this QR code you can
reserve a sub-domain
of workers not dev which it guarantees
30 workers and a hundred thousand
requests a day which is slightly more
than one a second I did the math without
using javascript and I will show this
again later and it is also at our booth
but I will pause for a moment until I
stop seeing cameras plus I'm like
running super super early so like I'm
just gonna like pause for a second yeah
for the QR code obviously not because
I'm like running away anyway all right I
see very few cameras out now so the
point of this talk trial of assembly I
like rust the more things I learned
about rust like what I learned a new
thing I keep standing in the spot with
the water the more I learn about Russ
every new thing I learned I'm like wow I
was really well thought out it's like
this wasn't created in 13 days no more
I'm not dissing JavaScript it's one of
the best languages ever but it was made
in 13 days and rust was definitely not
made in 13 days it was definitely well
well-thought-out webassembly is the
future of Jay s and all of its forms
though that I hopefully have shown you
it's it's going to create better browser
experiences it's going to deprecate no
chip don't quote me on that five years
from now when it doesn't actually do
that but it could deprecated no chip you
can quote me on that one
and the last one is that if you are a
hiring manager watching this right now I
would like you to do something very
important and that is hire someone
different from you they might look
different from you they might believe
different things from you they might be
different they might have a gender
identity different sexuality than you
hire them and before you tell me it's
hard I'm gonna refer you to mr. LaBeouf
on this just do it it's not that hard
just do it
there's higher someone who is different
from you somehow anyway thank you for
listening
I Laurie I hope you're gonna run over I
tend to be succinct and that's my nice
way of saying I tend to run early
there's water dripping everywhere on
this stage now by the way Lou so like we
might want to look at that we might want
to spend that ten minutes looking at
that danced around over here so Carl
Sagan and I both think you're super
awesome for watching this talk I can be
found at Kas at CloudFlare comm and also
at Noda botanist
I don't grow plants with knowed it was a
discussion with like Rick Waldron and
some other folks from Johnny Five we
were trying to figure out what to call
people who didn't know BOTS and I was
like two drinks in and I went no
platanus and Rick was like no but that
would make a great handle so that's my
handle and then if you search meetup.com
for server lists there's a meet-up on
Tuesday at Frazier's tower in Singapore
that's where the CloudFlare offices
and I will actually be doing a workshop
there where I will teach you how to
write a worker that controls a robot and
it's the same robot that's at our booth
there currently only I control moi but
you can learn to control it on Tuesday
if you happen to be in the Singapore
area still and then the QR code is back
up for anybody who missed it on the last
slide
now I'm only 10 minutes early and I'm
feeling much better about that so I'm
gonna say thank you very much
[Applause]