 Hey there everyone so hopefully everyone's gotten some sugar and other things in them I get them up through that post-lunch coma and hopefully my talk does not put you in more of a coma So first off the title of this is wasm components the interchangeable parts of software so Brief introduction to myself. I like to have this is the thing of like why you should listen to me First off, I'm a director of customer engineering at Cosmonic. You've seen a lot of us today I am a restation by way of go being a gopher beforehand. I do a lot of go and then a lot of rest I'm a I'm one of the co-creators of Crestlet and Bindle So if you're here in this room, you've probably at least heard of Crestlet It was the first attempt to really try to do something with WebAssembly and unknown technology And then Bindle is a thing that we can talk more about on the side. I am an open-source maintainer I used to be a core maintainer of Helm I actually wrote a large chunk of Helm 3 along with some of the people here who are now at Fermion and then a couple others who I worked with like some of the folks from VMware who used to be at Benami. So I've done a lot of that. I've done Kubernetes things since Kubernetes 1.2 Lots of stuff with Docker for a very long time. So I built Kubernetes platforms at various companies and now I'm doing a lot of things with WebAssembly So that's a little bit about me. That's the background that kind of Goes into the talk itself. So here's what we're going to do. We're going to go through a brief history lesson first And after we talk about a brief history lesson, we're going to talk a little bit about wasm cloud and components. Some of this you heard from Brooks today This is also a bit of a follow on to what Luke talked about this morning I'm going to talk about the status quo of where we're at with wasm cloud And then what we're doing right now and why it actually matters for this whole components thing And then we'll talk about the challenges we faced and the future of components inside of WebAssembly So let's start off with a brief history of the 20th century. I tried to make that as a college class sounding as possible Just so I'm not actually going to make it boring. So At the very beginning of the 20th century in the United States There was two important manufacturing concepts that merged together and that was the assembly line hint hint and The the idea of interchangeable parts Now this is the definition of interchangeable parts directly from wikipedia. I did not doctor this to include these words like components and assembly I promise I pulled it straight from From wikipedia and put it on here and there's just a couple important things here They are parts or components that are that are identical for practical purposes um, so they're made to very specific specifications and it allows easy assembly of the new devices and um easier repair of the devices that do exist and that minimizes both the time and skill required Of the person doing said repairing or assembly That sounds a lot like what we want WebAssembly components to do if you were listening to luke's talk this morning And so what this looks like in practice with with component like when these were created is you had these part part diagrams that were spread out and they were created to be something that was basically like a um You could take any one of these parts and reassemble them and in the picture on the right you see an old like assembly line from the early 1900s in the united states and There were buckets of screws and bolts and things that were all the exact same size And you could just go down grab it and put it in And so because each part is produced to those exact specifications This is what this whole like these two things combining is what kicked off what people call the industrial revolution Now this whole lesson of what happened actually has surprising applications to software development as well And so we're going to continue with just a little bit of history lesson With about like where wasm is wasm cloud? And the different components that came through so if you think about it at this point enough software is created Probably on a daily basis that it is essentially like an assembly line all of this code reuses various pieces of someone else's code And honestly the best we've been able to do are apis and apis are nowhere near interchangeable parts Components have a little bit different work, but when I say apis I mean everything graph ql rest soap grpc doesn't matter That's that that's the way we've that's a communication protocol. That's not an actual interchangeable part And so where we've at like this is a history of the modern computing environment You saw this slide earlier with what brook said, but I want to expound just a little bit more on it We started right from like the old like blades in a data center I mean there's some of us I have done this too where you know like If you haven't if you haven't pulled a spinning disk out of a running server and had it wrenched the arm out of your Like your arm out of its socket. I don't know if you've lived life as a programmer, but um Anyway, so these are these are the kinds of things that like we started with and we've gone through this idea of a vm Which abstracted a little further in a container which built on top of that and then web assembly itself And so along this path we've gone really far along the path through usability, but we haven't gotten all the way there and as brooks had mentioned earlier wasm cloud is The is a system that allows us to abstract a little bit further and abstract out these non functional requirements So i'm going to talk a little bit about that once again You'll see these slides are similar because brooks and I wrote them together That's why he had these same ones, but i'm going to go into different details We've all talked about web assembly to death. We're all here because we know about it We know what it does These are the main things that we want to do with it portable secure small fast language agnostic all those different things Now the thing is is wasm is almost nothing without an application run time on top of it because at its very base level I'm talking the base level i'm not talking about all this other cool stuff that's going on It's numbers in numbers out. There's not there's not a lot more than that You you're you're that's how you're restricted to use a web assembly module And in our in our case what wasm cloud is an application runtime we've created It's a cncf project So this is entirely open source And i'm focusing purely on the open source here not cosmonic cosmonic is powered by wasm cloud But this is all the wasm cloud side of things And it's it's focused on removing that boilerplate code that boilerplate code that i've talked about that in the non functional requirements We don't care about And all this comes with this idea of horizontally and vertically scalable however we do it But the big thing here are these capabilities Now capabilities you'll kind of notice that this whole idea that we've talked about before the idea of capabilities is very similar To what luke was explaining with the component model This is a common problem in our industry the thing is is the component model Is all about the bits of pieces that get compiled to run on your machine What we call capabilities is the distributed form of that I want to have something that satisfies my the need for my my software and I want to plug it in And I want to do that in some way that is distributed And on top of that we write our actual web assembly actors the things that consume these data sources these capabilities And these all run on top of our lattice. They're the completely flat topology Distributed network that that is connecting every single wasm cloud host Application runtime This is the part that actually makes it distributed when you combine all this together you get the distributed capabilities on top Now i'm going to talk about the differences between those in just a second, but first i want to review. What are components? Like like I said luke already talked about this in depth But for our discussion here. These are just a few points to keep in mind First off components are these interchangeable parts. I've been referring to they allow us to glue different things together in the way we want them to Wasm cloud has capabilities which are these distributed components But we'll still see that there's underlying dependencies that can get compiled in So with that let's talk about the status quo. Where do things stand with wasm cloud right now From this part of the talk on i'm going into deep technical detail But you don't have to understand a lot about web assembly to to understand the concepts I'm going to talk about but this is going to be very practical about what we're doing So first off just the super high level of how this works. This is the current diagram of how things work inside of wasm cloud um Anything that's in blue is user managed code so it's code that the user is compiling or doing something with I mentioned we have this lattice the lattice is what delivers messages to and takes messages That are going out from an actor and sends them back out to whatever else it needs to be sent to and all of that runs inside of a wasm cloud host but You'll notice that there is this wasm bus rpc library that's in there this this library is a custom library We have to have that allows us to transmit this data properly It has all the encoding and a bunch of other things that are that are necessary for it to run Whenever you write an actor for wasm cloud you have to pull in this wasm bus rpc dependency And now it's only a few dependencies, but it's still not ideal because you're pulling in code that then if we have to update You have to update And that's the problem that got us here in the first place If you think the basic example I used to explain this to anyone who asks is think about the log 4j thing that happened Okay, because first off it's not about the bug. We've all written stupid bugs. I mean Let's be honest with ourselves. We've we've taken down production once or twice or ten times And so the the whole idea behind that was now. Oh, we had containers. We're all secure Well, okay now we have this core dependency that a bajillion things use And now we have to go update and recompile all the code and then recompile all the containers and then redeploy all the containers That is not what we want to do and we've managed to abstract out a lot of that with these capabilities We've talked about the ability to say oh, I want a key value store So let me let me just code against a key value store contract and then I'll choose how I connect it later But there's still underlying code that gets coupled in and that's something we don't really like to have And so what this ends up being this right here do not worry about the whole Everything that's in this code block. You don't have to do it. Everything here is going to be rust today You don't have to understand a lot about rust to understand what's going on here But you'll note at the very top these dependencies Okay, there's a couple of them. We have this wasm bus rpc and then we have the two different interfaces We have the interface http server that's in there and we have the interface key value And so it's still really simple. This is a simple actor that does It receives an http request It takes that path and uses as a key and then increments how many times that path has been hit Just a very simple example that takes an http server and then stores a stores a bit of data in a place And we have gotten it down like this is still really small. This is maybe 42 I think it was 42 lines of code. Um, I don't have the line numbers on there But these are these are 42 lines of code So we got it small But we have all of these things up top that are importing in Things that you don't manage and so What this also means for us is that if we want to do this for any language for every single language We need to support we have to generate interface type interfaces for them Release them and then also have a was in bus rpc for every single language. Now. Yes, we have some underlying api and codec stuff that you could use But that's not the ideal way for people to consume this So you can start to see this becomes very hard to scale out and it's a custom piece of code that we don't want to always handle So let's go into what we're actually doing and why it matters and now we're going to really get really get technical But once again always start back up at this high level Keep this diagram in mind as we jump into it because we're going to go into every like little detail on this thing about what's going on Now on the left is what I showed you before that's where we're currently at and what we are currently working on as in like right now is what's on the right With web assembly modules we can start splitting everything up So only the user managed code the actual business logic is all they have to write There's no other external dependencies. They have to pull in Um This is everything like all to be clear to to show kind of the benefit of what was in cloud does for you All of this other code around it all the other things that are not blue are things that was in cloud does for you You this is code. You do not have to write as a user We're just showing you everything in here. So you know what we're doing So i'm going to jump jump into some very specific examples starting at the top of this hdp server And once again, this is going to be a practical example of how we're implementing components You've probably heard a lot of stuff about components being like, oh, well components are only theoretical. Don't you know? They're new. They're not theoretical And so i'm trying to show you here how we're doing it And let's go into it. So first off to wit. I've been waiting all day to use that stupid pun So let's talk about Let's talk about wit files So wit files, I don't even know if they technically stand for anything anymore. Historically it comes from the wasm interface types proposal Um, and so that's where wit comes from But these wit files are how you define what you want your thing your contract your interface to look like and these are api They look like api definitions, but they are not api definitions. They're a bit different in practice when you actually use them So this right here for wasm cloud is a very specific entry point into any actor There is a receive method that has to be called in from an inbound message from that lattice that i've talked about And we've elided some things like there's some common types we're importing And then we just have this single receive that is a message that gets passed in and returns back out a raw payload That can then be parsed by the underlying system So this Uh wit file right here is our http server one Now a lot of these this is how we've defined it for now and as we continue as we all continue to use components This is where we start to standardize on similar interfaces that become shared across everybody and i'll get to To a little bit more about that later right now. This is what our http server looks like and You'll see we have the request the response and then some other little types that that help things out Um, and then at the very bottom you'll see the only method that we have for this contract is handle request It has to be something that receives an http request and returns a response So This slide this is what is all looking like in code. It's a very top This is the line from that original piece of code I I sent you so all of this that i'm showing underneath Replaces this whole dependency all of its sub dependencies everything else underneath it it replaces that line of code Inside the original block Now on the left once again, you do not have to understand all the code here I left enough for context for those who really want to dig into this later But what what you can see happening is we're just we're receiving this message We're matching to make sure it's a proper type. So this is wasm cloud specific codec matching And comes in and says okay. I'm going to pass this off to A handle request http server handle request So this magic http server and the implement implement wasm bus receiver at the top is coming from something called cargo component That i'll mention and this is just inside of our cargo dot toml file Only reason I put this is in this new world You're going to have to have something that tells you where your interface is at and in this case We're saying we are importing an interface called http server that we're going to call And we're exporting something called wasm bus receiver And so that's why this implements the function that we expected right this receive function receives a message And it is calling something in imports, which is the http server So this code will receive the message turn it into something the http server knows and then call an http server It doesn't know which http server it's calling right now. It just knows that something on the other end is going to implement that contract So we've talked about this high level http server one Now i'm going to turn this like into a sandwich the user ran is code is in the middle of the sandwich We're going to go to the other slice of bread and talk about the key value in the sender because they're very they're they're closely related So first off we have the wit files again now. Um, this is a very Dumbed down version of our key value interface that we're still iterating on That just has the increment function in real life This will probably have the get set delete types of things you'd expect from a key value function But for now we just for for proving this out We wanted to get it to this increment function So same thing single increment function. It takes a specific value returns a specific value back And at the bottom is a thing that is common to every single actor that runs in wasm cloud This becomes very important and i'll cover that in a second, but right here. It's this send function I want to be able to send something out on the lattice and same thing single function we define and then we're able to use So Code for this on the left is the key value dot wasm and beneath it You'll see the line of code that it entirely replaces from that first example and once again You're like oh well, it's just a line of code But remember that line of code includes that package whatever language we're running and it imports that package And all of the dependencies that that package pulls in so we've now removed that entirely with this with this method So you'll see that it implements the key value Thing that we've we've defined before in the wit file and it's calling a wasm bus send So basically this takes all the the incoming thing and says how do I turn this into a send Ascent method and I send it across the wire Now on the right Is the sender code now for our example, we're just giving it a handle to standard out In real life this will be connected to the wasm cloud host which will expose a function to it and it can call that function But right now just for simplicity. That's how we've done it. So this goes all the way down It gets this this raw message. It doesn't matter what the message came from Handles the message by sending it out to the host and then receives and returns data back Now once again, this sender is used everywhere every single actor that will ever run on a wasm cloud host will use this code But what's cool about components is let's say we have a bug in this You don't have to recompile your code. You don't even have to redeploy your code We just go don't and pop in the new component and it's ready to go And as components evolve will even be able to do i'm hoping we'll be able to do things like hot swapping But even if we don't this is a really quick We're just shifting it in and next time you call the the actual actor It's going to be using the new patched code and you did nothing And that's a really really powerful security feature and just very user friendly feature And again all of these different components could be written in different languages We could write this and see we could write the key value thing in python The top thing could be written in rust and it doesn't matter All of this code can then just be smashed together as a component because it's all compiled down to web assembly You start to see some of the all these benefits all come together that we've been mentioning about web assembly for such a long time And so This replaces a lot of our code as well So just a benefit for us and I mean it depends on the use case but for us This sender thing replaces a whole bunch of like data copying and serializations that we have to do to get things into the right format Whereas in with a component we're able to just talk directly to the host We're able to use typed functions and things that can come down into a host for us So this is this is a pretty big deal. But what does this all enable for us? So we started off With this idea of the hdb server. We moved to the key value Uh what dot was in the wasm bus sender? That's a lot of stuff But what does this actually enable us to do once again? I was giving all this so you know exactly what we're doing and why But what is it enable and why is it so powerful? Well, let's look at the key value counter This is the new key value counter That we had that comes out of this you'll notice that this looks almost identical to the one you had before at the very beginning But now there is zero wasm cloud specific code in here Luke mentioned something called virtual platform layering It might have just it might have just gone over people in between all the awesome details going on there But this is an example of virtual platform layering If we collaborate on these common contracts because most key value things everyone is using the same set of get set and delete Sure, there's some extended things people could do and and people are allowed to do that And wasm cloud you can create your own contracts and you can create your own providers and implementations But most people are going to use that same set of functionality and if we have those standard things There's nothing stopping someone from taking an actor. They've written for wasm cloud and running it in another system Because it uses those same imports And so another thing that's important to point out here is i'm writing normal rust code There's no there. Yes, there's some magic happening here There's going to be like the wit bind gen stuff in rust is really good and some other languages like iven showed It's not as good with the whole wit thing But it doesn't matter this generation might will happen and I know people get a little scared of the code generators But this isn't like The kubernetes code generators where you're committing this code This is something that can be generated on the fly compiled in and run and you're just writing normal code for your language and to To beat the dead horse again in wasm cloud. This is the only code you have to write You get all of this distributed goodness I've been talking about the whole putting together these different things across a huge distributed platform Just by writing this code and there's no mention of anything about scaling nothing about what you're connecting to none of those details And you can you can see in the code. It's just really simple. It says hi I'm implementing the h2gp server contract pretend i'm an h2gp server. Give me an h2gp request, please That's that first handle request function But then when you go down the line you see This thing that says oh key value increment towards the very bottom of that What key value nobody knows nor do they care and nor do most developer developers care when they're writing their code So we've been able to do this with components and what this allows us to do in the future is think about This is like layering components on top of components in a sense You have an actor That is running a stack of four different wasm components wasm modules that are glued together Turned into a final compiled like web assembly module For for sake of discussion here and it runs on a wasm cloud host But then you're able to then compose what it's connecting to just like you did with it at runtime To whatever thing you want to connect it to So we basically have components that make up an actor and then multiple actors that can talk to different providers And composed in the way that you want them to and scaled the way you want to have them scaled So just a few things about the challenges that we faced in the future. We're going for it to have finish up everything here So first off This diagram so I threw this together. This was a ragey diagram and on purpose Gluing this all together is a bit difficult now. I'm going to be honest Bailey I'm going to do a shout out to Bailey Bailey did a lot of this code too to help out Here and so she discovered a lot of these things and boy was it a little bit messy Uh, it's a bit difficult. So right now this is requiring three separate tools The blue line you see on here anything below it is what we do on a wasm cloud host But on the top we have to have this thing. We have to have cargo component They use this stuff with the wit files And then we have to use wit bind gen and wit component to actually glue the things together It outputs a wasm file, but that wasm file is Still labeled as wasm 32 unknown unknown because there's no official wasm 32 component thing yet So it's it's a component, but it doesn't say it is When you look at anyway, it gets a little complicated there and you think you've made a mistake But you haven't and then at runtime we have to pull down all the web assembly modules And put them together with wasm tools compose to get a final thing That's how we do it right now as like literally right now What we're trying to make it do to work ideally in the future this will continue to improve for us personally We've started to abstract this away for for our users behind wash build So this is not there yet, but we're going to be adding that all behind there So as these standards continue to improve and just be better overall and more solidified We'll start rolling into like just the full tooling, but it's still hidden behind for for our users behind a wash build command And then obviously the stuff underneath we're hiding just by virtue of being a host that's running it So that was the first challenge that I have listed here The second one is you have to use a runtime that supports the component model Which is wasm time and nothing else So that we all love wasm time. I mean that's not a slight against wasm time or slight against It's so new the only wasm time supports it. So you have to use wasm time if you're going to use components right now Things are still on the assembly line Sorry bad dad joke, but the thing is is we We're on the bleeding edge here people. So things are going to bleed And that's part of the issue of doing things with components right now is it is very very it's hemorrhaging edge So just make sure that if you go down this route, you know, that's what you're going to get into Um, also this talk is one of the few real world examples out there Um, there there's been some talks about it today, but like there there isn't a lot out there There's probably three to four examples of doing this for realsies not like oh look at this pretty diagram Which are great. This is one of the few real things that are out there That was why we wanted to give this talk It's because we wanted to show a real example for people to start following along with Even though it's far far far from perfect So those are those are challenges just keep that in mind I always like talking about those first we can talk about the positives here and where we're going The first thing is that we're going to be implementing this as soon as possible for wasm cloud Um, like so we don't want to have to make people include their own library like our own library for them to be able to write something We um, we we're gonna until this point until the point that we've actually fully implemented this We'll keep our our custom libraries as easy to use as possible But this is something that within the next few months. We're really trying to get some first drafts out with Like I said, this code actually runs. It wasn't worth showing the demo because all it does is print line some stuff but We're actually this is a real thing that exists Once we get this stuff out with wasm cloud We're going to use that to give any feedback back into the actual spec for components and how they how they work And then we're going to also contribute to it We want to help push it across the finish line just like everybody else in here We unlock components we unlock And solve a lot of problems for pretty much everybody here who wants to use web assembly And then we're going to work on things like having a wasm cloud world Now that isn't a theme park as much as we'd love to have that It is the world files that were being mentioned earlier We want to be able to like work within the world file things and contribute to that whole idea of having Requirements and virtual platform layering that goes along So here's some references. This is the same QR code that brooks had earlier. So if you already scanned it, don't need to scan it again That leads to our slack. We have some Linked to wasm cloud some more things about what our capability providers are and what our interfaces currently look like They're all there also just as a heads up We have if you're interested in learning how to do this We have a web assembly crash course on tuesday that bailey's putting on with me and a couple others from cosmetic and tonight after the Basically the happy hour at the detroit marriott There's details online with that qr code There's we're getting together with our friends at fermion to do a meet-up And it's meant to be a place where you can just try out the things that we're doing and that fermion's doing And just to have people who know web assembly all together in the same room So you can talk about whatever you're hacking on So That's all I have and I just want to leave it open for any other questions Questions for taylor. I hear so much about this dream of interchangeability Uh, but what's really the reality of that is that do you really see that as something that is You know this This this gold this big golden goal Yeah, so This is something I was as real and frank as I could possibly be with this talk This is what's in the way of us doing it. There's still a lot of work to be done But I do think this is doable and I think it will change the way we do software Yeah, so the question for those who are online or couldn't hear it is He asked well, it's doable, but will it be adopted and my answer to that is yes If we put in the effort that's why this talk is here because you know If if nobody puts an effort from this point those of us who are trying to use the component model Then it won't go anywhere like any other specification or technology we've ever used We could have said the same thing about docker when it first started But if we put in the effort here and and that's where where it's an invite to everybody If we if we get people in on the ground starting to do this You're able to influence it in a way That's for the good of everybody because you're bringing in different perspectives and ideas And so I do think this will become a real thing And even like outside of business like I'm just going to get personal here like yes This would be great for cosmonic the business This is going to be great for many people here and their businesses But for me as a developer I don't want to have to care about every single little piece and whether it compiles on my machine and which library I mean I'm sick of it and I think every developer is and so There is a Personal more emotion more emotional motive behind How this is how this is coming about because we are tired of it We've continued to make our lives better in some ways while still just like reinventing and papering over the same problems And here I see something where we can get a lot closer It's still going to have its edges. It's still going to have its problems, but I think we can get a lot closer than we did before Truth problem some Taylor I'm sorry. I'm going to take issue with that We've been hearing this rhetoric since Well 1995 at least the object oriented. Oh, it's lego. We'll be able to plug in components and it's never really clicked And I don't know what's different This time you gave the example, you know, you talk about interchangeable parts You gave the example of slotting in a bug fix sort of underneath someone's application Do you know what the compatibility implication is that it's it's not the same screw It's a slightly different screw, which you're telling me is better But maybe it's got maybe that additional Resilience is actually a problem for my failure cases. Who knows Yeah, and that's what's different. That's a really good question. Ivan. So Um, I know Ivan that wasn't a plant question. Um, so Um One of the things here is you can actually find a really good lesson in history So in the precursor to this whole idea of interchangeable parts people had tried doing this for years They had come up with custom ways to groove things and a couple other things that could be reuse and a lot of it A lot of the start was in wood The thing that I think is very different now Is that we have learned a lot since those days, you know, like j2 ee and All that kind of stuff that we've talked about before I think we've we've learned a lot from like what we did with containers And then what we did with kubernetes and we've taken those things and we said, okay Well, what can we do to make this a little bit more? um Wide open and you can you can see those those The thing is then we get into nuance and if you're new to web assembly the nuance might not be there But if you look and start to compare between like what the specifications look like and what you're able to do Um with with those specifications, you'll see that they are Still wide open and allow for that. Hey, I have this very slightly different thing And it accounts for that and so much so yes part of this is that we're not going to know until we know But I do think that there is An evolution that has occurred Between what we've tried in the past and now And the lessons we've learned from doing things like docker and putting together multiple docker containers and something and all those those kind of details have Have um really helped inform this and you'll see that it's at a different layer It's not based on a single programming language or a single underlying runtime with wasm You have the goal of all languages eventually and even now a good set of languages And then you have multiple run times underneath you'll notice that there's no like we talk about wasm time But there isn't like a oh is wasm time going to be the winner because that doesn't happen with web assembly you have Purpose built run times for what you need You have wasm time you have wasm or you have wasm 3 whammer wasm edge I can keep going and all of those things are used for different purposes, but they implement against the same spec So I think there it like there's always a danger of it being just another thing that falls on its face But I do think that we are doing something a little bit different than we have in the past And I think we were out of time training more questions on this one. So please join me in giving taylor a huge round of applause. Thank you taylor Our next talk is from adam