WHY WEBASSEMBLY IS IMPORTANT | USE CASES | Introduction to WebAssembly (WASM)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey welcome back and in this video we're going to look at why i believe webassembly is probably going to be one of the most disruptive technologies to hitters over the next few years now of course you're probably thinking yeah i get it from a front-end perspective and we will be focusing in on that as well on why webassembly is different and why it's going to be disruptive in the web browser experience but we're also going to look at and more importantly why webassembly is going to be game-changing and i mean game-changing in the back end webassembly is likely to become the lingua franca of integration and we when we look at things like the move to edge devices the move to edge network such as cdns and especially when we look at integration technologies whether it's sort of api gateways or integration buses or even if we look at general how i plug my code together webassembly is going to be the key to all of this in the future and we're going to look at industries such as banking or e-commerce where webassembly is probably going to change the game completely and we'll look at those use cases on why that is the case alrighty so let's get started [Music] so the first thing we're going to do is we're going to look at why webassembly is disruptive in the browser space so up until a few years ago if you wanted to write code that would run on the browser you only had a few options one of them of course is going to be javascript which is your web standard compliant way of writing code that can execute in a browser or you could rely on some sort of plug-in mechanism whether that's something like java or whether that's flash or whether that was something like silverlight and the problem with all of those plugin based technologies is they never really lasted it out and it could have been from things like security perspective or it could have been people like steve jobs saying yeah i'm just blocking it that you know flash isn't running on my devices anymore and these are the sort of things that ultimately killed those plug-in based technologies from becoming ubiquitous and the biggest difference now with a world of web assembly is that it's a standard and that is the key thing it is a standard so when you write webassembly code and it's an evolving standard but when you write webassembly code then you know it's going to run in those browsers you know that all browsers are going to support that because it is a web standard now the only thing that you could guarantee before that was javascript so you're probably thinking to yourself well why wouldn't i just run javascript code all the time well and let's come back to some of the fundamental differences between javascript and webassembly so javascript is a dynamic language so when you want to execute a piece of javascript on a browser essentially what's going to happen is the browser is going to pull down the javascript from the server and then it's going to start doing parsing it's going to parse all of that javascript it's then going to convert it into something like an abstract syntax tree and then it's going to do the sort of compilation into bytecode and then it's going to turn that into machine code so there's a lot of steps that are involved before you can execute a piece of javascript now the difference with webassembly is it is not a dynamic language it is a static language so therefore the code that you have written has been compiled in advance so therefore what you're really doing is pulling down the webassembly code and all that really needs to happen is it needs to be optimized for the local machine that's running on none of that parsing steps none of those um conversions into abstract syntax trees all of those steps are come out the way now the second thing that is important is performance right so if you've got to do all of this conversion and parsing then it's really difficult for the browser to be able to run your code at speed but of course with webassembly that can be done in advance because it's statically compiled and that is one of the most important differences and you can kind of see that in javascript today if you've ever written something like a kind of a quick sort routine i have and if you've ever tried to write one of them then what you'll probably notice is that your quick sort routine that you write would not be able to perform as quickly as the inbuilt javascript functions for something like a regular sort which might not make too much sense from a coding perspective because you're thinking quick sorts should be faster than doing some sort of regular sort but the difference is is the inbuilt sort functions in something like javascript is actually been written in c plus plus and then the code is made available as a module as an interface for you to execute and that's why the architecture of webassembly is important because the same way that the inbuilt functions are exposed from the underlying javascript engine such as the v8 engine is the same way that web assembly exposes its functions at the heart of it each web assembly module is the equivalent of an es6 module and therefore you have interoperability so i can write code in javascript i can write code and web assembly and then i can call my code between the two so i can have a javascript function call a webassembly function uh in a webassembly module and then likewise i can have a webassembly function in my webassembly module called a javascript function across an in an es6 module so these things start to become really interoperable and that means that if i've got something that's really performance oriented so maybe i need to do a sorting routine or something then i can write that in webassembly and then get the benefits of that so that's that's why i think from a browser perspective it's going to be really important what we are going to start to see over time is this hybrid approach where you write some stuff in es6 modules in javascript and you're going to write other stuff that requires performance and web assembly modules so it's going to get a little bit hybridy and a little bit not messy but it's going to be a lot more plug and play and we're already starting to see that evolution today so if we look at things like image optimization routines you are starting to see people go okay this is a code intensive thing that i need to do maybe i want to convert this image into a compressed format or i'm going to do a lot of calculations and what you're starting to see now is people writing code that will get converted to webassembly so that on the browser you get that extra performance by doing some of these compression type routines on the browser using webassembly based modules so that's sort of the first scenario so things like image optimization or any sort of compute intense routines you can start to write uh in webassembly and then make that available uh for your browser and use that interoperating capability between javascript and webassembly to call your code so scenario number one and we're seeing that already today and the second scenario that we're starting to see today and probably one of the most common scenarios is we are seeing a lot of people trying to harvest old code they've written in the past and bring that into the modern web world so and the reason for that is because web assembly is an intermediate language i can compile from something like c or c plus plus or rust uh into webassembly and once i've done that compilation then that code is accessible from in the browser so therefore because you've got that ability to compile from these existing languages you're seeing people look at legacy code that they may have written or legacy libraries and then bring that into the webassembly world and again image optimization compression is an area where we're starting to see that today so that is a sort of common use case so somebody will take an old piece of code compile it down to webassembly and now their old piece of code that maybe is 20 30 years old is now it able to be run on a browser so a good example of that was autodesk um you know the sort of cad manufacturing company they had code that was like 20 30 years old but they wanted to bring the sort of autocad experience to the browser and they took their code base and they converted it across the web assembly so this existing c plus plus code base and they use the tool called m scriptum to be able to do that and then you now got this really fast cad experience running on a browser but legacy code is not the only strategy in this case it's not the only use case new pieces of code is is another example and i think um i think it was figma one of the design companies they wanted a really sort of uh fast performance for a sort of user experience and prototyping and they wanted that to run a browser so rather than trying to do that on javascript and get a substandard experience what they did is they would write those performant elements of their code base and they would write all of that uh i think it was in rust they wrote it and then they compiled that down into webassembly so it was able to run on browser so they're they're the sort of primary sort of use cases that you're gonna get on browsers so that's number one all right so we've covered the web browser now what i said earlier is that i believe that webassembly is going to become the lingua franca of the back end what do i mean by that well i want you to think about this sort of code ones deploy anywhere mentality that we're getting into right so maybe you've probably seen this quite a bit is docker is becoming huge in the development space and in the infrastructure space now why is it becoming huge it is because i can write my code i can package it up and i know i know that when i hand across my docker image to you we know it's going to work right how it behaved on my machine is it's going to behave exactly in the same way on your machine or in the back end so that's really cool and therefore it's become really really popular the problem with docker in that sense and and i love containers in general to bits but the problem that you have there it's it's can get quite bloody right because in order to give my application across to be run then there's an underlying operating system that is required then i need to put my application on top of that and and these things get quite big quite quickly it's quite a bloaty experience but actually what i'm really want to do is just hand across my application here take this piece of code that i've written and run that now i want you to think about this let's say i was an infrastructure company let's say i was a google or i was maybe maybe i was a bank for example and we'll come into a couple of those examples in a second if i handed you across my c plus plus code or i handed you across my rust code and said could you run that on your infrastructure please my guess is you're probably gonna say no and why are you gonna say no because security right you don't know what's running in that code base you're not gonna go yeah i'll run that for you because it could do anything right it's it doesn't have that sort of sandboxing type of capability now i know in the past that we'd be looking well isn't this the problem that java was trying to solve and the answer is yeah that that that probably was what java's trying to solve and it has the java vm and then you could argue that you could hand across your code and run on other machines but but in the same way java's quite big and then you can access anything and and therefore from a security perspective are you really going to run somebody's java code just because they handed that across and i think the answer is no now web assembly changes all of that because webassembly is quite small it's a sandbox type environment i write my code and then it's going to produce this webassembly file now of course that can be scanned we can look for any vulnerabilities but because it's a sandbox type environment any access you want to give to the outside world is really governed right you need to explicitly say this is what i'm calling and you can allow what you have access to when you're on webassembly and then similarly if you want to call into a webassembly module you need to specifically say what you're exposing to the outside world that makes it portable but it also makes it largely secure so the idea of handing across my webassembly module and saying hey can you run this in your ecosystem and been able to say well you're allowed to call this method you're allowed to call that method um and you're allowed to call out to this method over here that's kind of that's a sort of a really kind of secure type of environment and in fact i could probably draw this out on the ipad so if i let's let's take an example let's say i wanted to um convert a number or something like that right so i you could imagine this sort of web assembly module here right and then you know you've got this sort of execute environment the the sort of the caller so they're going to make a call in and you are going to expose what methods you would expose to this calling routine so it could be something like convert number i don't know why you would call that you pass in a number you get a result right so you and then it's going to come back with whatever the answer is but maybe in order to do that conversion you need to call something else out on the outside world so maybe you need to call some sort of api over here or you need to call another service or maybe you need to call another module well in the same way is the webassembly module exposes what it can call to the outside world then it's got the ability to call things you know in es6 module type formats to the outside world too so you could start to define a set of interfaces a little kind of module routine that says okay you can call this you can call that you can call this and that gives you this ability to talk to the outside world and when i mean the outside world it could be within the environment you're executing in or it could be the internet as a whole via pre-defined interfaces right and that becomes important because therefore you're controlling access into the module and you're controlling access out of the module as well so what does that mean well that means that becomes super great for things like integration so let's say i was wanting to create a [Music] some sort of api integration gateway or an api uh integration bus of some sort well you can start to imagine a world where i as a a consumer right can be able to take my piece of code my webassembly module and say okay when i get this type of message coming in i want you to execute this module and then your module will do whatever it needs to do maybe it'll add five to something maybe it will change some of the json values maybe it'll do a calculation maybe it'll go and call another service that it's allowed to access maybe it can go and get a key or go get a balance or something do some integrations and then do the result why that's important is because you're now in a sandbox environment so rather than me even handing across docker containers which i'm quite sure most hosting companies or integration platforms saying oh call a docker container or i don't think so well now with a webassembly module because you've got this controlled access in it now you can see that becomes the integration platform of the future so if you're writing something like uh an api integration bus or something i can absolutely 100 see in the future that you will have that ability to throw in webassembly modules which you'll be able to integrate write your own routines and code for i i'm 100 positive of it now if i take that into sort of real use cases beyond technology use cases then that becomes disruptive in certain industries so one of them could be e-commerce for example think of all of these commerce engines up in the cloud you know and there's loads of them um i won't mention any names um but you know i actually will mention a name so shopify is probably a good example because they do this already today so one of the things shopify does is they have the ability for you to load up a web assembly module and then execute a piece of code in the back end as part of your e-commerce workflow why is that useful well let's imagine this for a second they're running all of this ecommerce platform right so you you've got the ability to get items in your catalog you can add things to cart you can do a payment workflow all of that stuff is is is handle the standardized modules but what if you want to do something different let's imagine any e-commerce you want to make a check to see if you have inventory before um you complete an order workflow or maybe maybe um you want to check that somebody is from the right country so let's say you're selling things to everybody but perhaps maybe in a country maybe in denmark you don't you don't have the rights to uh some sort of image or something so therefore you want to exclude that or maybe you need to do an additional fraud check or something for certain countries over other countries so you start to have these customized workflows that are specific to your products so therefore how how do you allow customers to to edit and change those workflows in the back end so that you know when when you're selling your goods then you've got the right level of customization well you're not going to allow somebody running a shop to come and change your back end engines that's crazy right that how is that a sort of uh pass or a sas type service but what you could allow them to do is write custom bits of code which you could hook in and just fire those hooks you know on the kind of workflow you know uh add to cart could be one removed from car and then it can call a web assembly module that you've provided and because those web assembly modules are sandboxed then and they're tiny and they're not really going to be affecting the back end infrastructure and they're secure and you're and and and you've got predefined uh internal you know calls to which functions you're going to make available and you've got pre-determined calls outbound that they can make then therefore you can allow customers to upload their own modules and and then execute them as part of the workflow so that's one scenario um so i think that's going to be huge as i said shopify is already doing that i see every e-commerce engine in the future uh doing that as well second one is banking and i think it's a really important one which is if you look at things like bitcoin today or ethereum or any type of uh blockchain based finance system then they have this thing that is called smart contracts which is at the heart of things so what happens in this case is is when you're doing something on the blockchain you can write a piece of code so maybe you're issuing an nft or something like that and and therefore you can write a piece of code which adheres to this smart contract now depending on the blockchain some of them use webassembly today some of them use other languages but the concept is the same that you are able to write code in a sandbox and secured way where you can control the interfaces that go in and out and that could absolutely change banking going forward well what do i mean by that imagine on your bank account for example that anytime an incoming payment happened you could execute some sort of customized workflow so for example let's say i get um i get paid by my company right so you know then on the sixth of the month my company pays into my account when that money comes in i have a piece of code that looks at that incoming payment and then transfers parts of that money to the various places so maybe it pays my electricity bill it pays my um my gas bill maybe it pays my sports club membership and and does that kind of things on order that becomes really really powerful because you are then able to start being less dependent on things like direct debits standing orders etc to make your payments but you can then start to control your finances and customize how you make your payments with your own logic and code and you could imagine that being super powerful for something like business banking right so maybe you get an incoming payment and you need to go and look up uh if if what the reference code is who the customer is whose invoice system needs to be done well again think about this for a second could you imagine a banking platform if you hand it across a c-plus plus piece of code or a rust code and said hey can you run this on your infrastructure there you go no get out of here i'm not doing that but if you're handing a secure controlled piece of code that's running in sandbox which really is only able to interact with your accounts and others and be able to do those custom integration could that work yeah and and that's how things like blockchain work today already so i think that becomes a super powerful use case the last one that i probably want to talk about is in the back end side of things is probably things like docker itself a lot of people are saying webassembly could disrupt docker itself and actually it could because one of the cool thing about containers is of course the ability to be isolated but you've got that level of isolation already in web assembly the things that are missing is the ability to interact with file systems etc and that's why a new web standard has been created called wassie which allows you to interrupt with file systems and uh interrupt with uh some of the other types of stuff that you might need from a kind of unix perspective and and therefore that gap between what docker is doing from an isolation and what is possible from a web assembly perspective is going to become smaller and smaller so maybe in a few years time what you're going to see is webassembly start to challenge containers and docker for back end isolated portable code bases as well now the last thing i want you to think about and i think it's the final use case is edge services and again we are seeing this a lot today so if you don't know what edge services are it is going to be thing and this is super important in this 5g world it's this ability to run code on devices that are close to you now that could be a sensor it could be um some sort of local device like a raspberry pi or something it could be your phone or one of the things we're seeing uh huge at the moment is cdn so if you don't know what a cdn is it's a content delivery network and the big ones are things like akamai cloudflare fastly etc and and those edge networks have basically compute power spread across different countries so where if we look at sort of cloud platforms like azure or amazon today they are they've got their main data centers and again they're in different countries but but these cdns these edge networks um have lots of points of presence in lots and lots of different countries throughout the world so when you're making a call especially for data that's cacheable etc then if you've got your code or you've got your data or your images or whatever on one of these points of presence is closer to you then rather than going off to the sort of central backend cloud platform it can be served up from a server that is much much closer to you in the network and because of that reduced latency you're going to get that faster and that's the point of scalability and performance what we're seeing edge network cdns especially uh do is start to allow webassembly modules to be uploaded onto their network and that's important right because the sort of things you can do on cdns is is simple things like you can transfer uh you can do that sort of back end integration stuff so you can maybe route code to various devices you can check to see if somebody's subscribed to an article you can do image optimization you can do check for authentication tokens so all the basic scenarios we described earlier but it becomes more powerful in a webassembly world because if i can take my webassembly module and run that on that edge network then i can start to include even more powerful pieces of code maybe i start compressing my data before i send it to my back-end platforms maybe i do actual code execution maybe i run some machine learning or something on those edge networks too the the possibilities become endless that perspective which is why we're seeing all of these cdn companies use this now that gets us into a world where my the same web assembly module i could run a browser i could run on an edge network i could run on a cloud and i can start to have my code being portable and connecting and talking to various parts of my network so it this idea of code being portable and transferable and used in different scenarios really becomes available in a world of web assembly whereas doing that in a javascript world or a c or a c plus plus world not so much right you you wouldn't be allowing somebody to run your dynamic language and sort of transfer that across the world and say hey yeah just from my javascript code you'd be like from the security perspective i don't think so my friend and then the same with c plus right if you think of all a pointer logic etc you're not going to want to run that in a sandbox fashion so you know so webassembly opens up all of these possibilities and probably the last reason again for these edge networks is webassembly modules are really tiny really small restocker containers can still be quite big right you still have operating systems underneath that yeah you can create things on scratch but but there is still a bloat with containers and you don't have that bloat with web assembly modules so therefore in edge networks and these tiny devices small memory uh small cpu power webassembly modules is is really gonna rule the roost and and be able to run that code and it's super suitable for portable workloads anyway that's the end of the why um hopefully i've given you a good few use cases hopefully i've given you a good few examples and maybe inspired you but i'm hoping you get where i am at the moment which is web assembly is going to be absolutely massive and i think it's just going to be a game changer over the next few years and more and more what we're going to do is going to involve web assembly whether it's in a kind of end-to-end scenario or whether it's one of these hybrid scenarios anyway hope you've enjoyed this video and speak soon you
Info
Channel: Chris Hay
Views: 1,077
Rating: undefined out of 5
Keywords: chris hay, chrishayuk, introduction to webassembly, what is webassembly
Id: lwAQiE7bU-8
Channel Id: undefined
Length: 29min 49sec (1789 seconds)
Published: Mon Aug 23 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.