WebAssembly (Wasm) is a universal bytecode format that enables Java applications to run in web browsers and on edge devices, offering zero-install deployment, cross-platform compatibility, and the ability to write browser user interfaces in Java using the same language for both frontend and backend. Tools like CheerpJ, TeaVM, JWebAssembly, and GraalWasm enable Java-to-Wasm compilation, while WASI provides standardized system interfaces for server-side execution. This technology allows Java developers to leverage their existing skills for web applications, educational tools, and edge computing services, though current limitations include the need for glue code for system interactions and varying support across different Wasm versions and toolchains.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Java and WebAssemblyAdded:
So, good morning everyone and thanks for coming to our show here.
This is Jeff Martin, my co-speaker. Why don't you say something about yourself, Jeff? Hello.
I've been programming Java for 25 years now.
Started at Apple and I have my own little software company and uh >> [snorts] >> and moved to Java.
So, I'm Cay Horstmann. I'm My claim to fame is having written a Java book 30 years ago. It's now in its 14th edition.
And so, we're going to be distributing the work here. Jeff is the expert in doing all things with Java in the browser.
I know a little bit about using WebAssembly on the server.
So, [clears throat] that's how we're going to do it. What you see here, by the way, is a nifty application that runs Java in the browser. That shows a markdown as a presentation. So, we're eating our own dog food here. This is something that Jeff has put together.
All right. So, let's let's go through a few concepts. Before doing that, so [clears throat] you all know that that WebAssembly is a bytecode format that's it [snorts] runs a virtual machine. That's not the same thing as the Java virtual machine. It's its own thing. We'll talk more about it.
It runs in every browser. And so, today you can see it in the wild. There's popular applications from Google, from from Adobe.
>> [clears throat] >> Microsoft has a whole toolkit for building user interfaces that that get deployed through Wasm.
I'll show a couple of demos here for a few seconds each. Here we see you can run SQL in the browser. So, SQLite was implemented in WebAssembly. And so, now you can do your SQLite queries. Like if you wanted to teach it, for example.
Here we have [clears throat] a little application.
Oops.
Um that um it runs Pandoc. That's a document conversion format. You could upload like a Word file and convert it to to tech or whatever you conversion you want to do. And it's all in the browser. That means that that document is never processed somewhere in the cloud. So, it could have uh confidential information in it, for example. So, a nifty little application. And we'll actually come back to this application a little bit later. Um what >> [clears throat] >> what if you wanted to do some Python programming, but you don't want to actually install Python on on your uh computer? Um this thing here runs Python in the browser. You can type some Python code here, and then you can execute it.
Uh so, like if you wanted to run some activity with students, and you can't rely that they install anything, here you have it. So, running stuff in the browser is a perfectly good use case.
Now, um we kind of had Java in the browser at one point. And so, it's very different uh from from from WASM. So, in Java, uh what ran in the browser is a Java virtual machine. It does objects. It does garbage collection. Um it, of course, interfaces with the world. Um so, it can paint pixels. It can make network connections, and so on. Um and as we know, uh as I I know because I was around when applets were a thing. And uh you may not remember. Um it No, it takes a while to to get all of that started. Uh WASM, on the other hand, is a much much simpler virtual machine. Um and uh it starts a very fast. And um it uh does not have any system access at all.
Um >> [clears throat] >> so, um let's see. Why do we then care about having uh WASM instead of Java as a virtual machine? Well, of course, because WASM does run in the browser, whereas as we know, Java no longer does, sadly, right?
Um and also, we can do things outside the browser, as we'll see in the third part of this presentation. Um one can compile all sorts of languages into WASM. So, for example, JavaScript, Rust, Go, and C++. And then when they're in WASM, >> [clears throat] >> um you could call them from Java. Or conversely, you can compile Java into WASM, and then you can have your WASM your Java code that has now been compiled into WASM executed in certain environments.
So, there are two big use cases that we'll be looking at in this presentation. The first one is Java again in the browser through the power of WASM. That is Jeff's thing. Um and so you could use it for example, if you have a a web application. And if you don't love React, you could actually use your use your Java skills to write a user interface in uh that and then deploy it in the browser like that. Or you could and you'll see some fantastic apps that Jeff has produced. You can run all sorts of things in the browser that don't have any back end. They just run in the browser just like Apple's used to do.
The other use case outside of the browser is and that splits up into two sub use cases. We can have Java calling WASM. Um now why you might you want to do that? Of course, you could just use foreign functions, but we'll talk about why you might want to do that. Um and conversely, you can compile Java code into WASM, and then you can run it in certain environments that can execute arbitrary WASM. And of course, if they can execute arbitrary WASM, wouldn't you want to author it in Java instead of you know, some of those other inferior languages?
So, >> [clears throat] >> um one of the things that um I think when we need to wrap our head around this is that WASM is super limited. Um so, we're used to the Java virtual machine, which is very rich. Um and so the WASM virtual machine and it can has variables, it has gotos, it has arithmetic. Um it has a notion of linear memory, so you can a block of memory containing bytes.
Um and everything else you need to do by calling out to some external services.
Um so there's there's [clears throat] nothing there to paint pixels or anything or to connect to to socket. Um the only mechanism they have is a call out that you then have to supply somewhere else. We'll see many examples of that in the third part of the talk.
So and um so it people say that wasm is very safe because you can sandbox it.
And um it really can't escape much out of the virtual machine. And that's of course because it can't do anything.
Um contrast that with Java. Why don't we have Java applets?
Because Java can do all sorts of things and the attack surface was so large in the end that people came up with nefarious attacks whether it did serialization trickery and things.
There's a so much going on in the Java virtual machine and in the large class library that is attached to it that at some point Oracle just said, you know, we can no longer guarantee security of this. The browser vendors said we're taking it out of the browsers and so on. So wasm is is the other side of the spectrum where the security of wasm is because it can do so little. Um and then that's easy to sandbox.
So that does mean that you need some kind of glue code to to interact with with wasm. The glue code doesn't strictly have to be in JavaScript, but in all of the examples that we will see today it is in JavaScript. So anytime that you want to transfer something into the into the into [clears throat] wasm, you need to get it in some other shape, shuffle it into the the memory blocks. Conversely, when you call out of wasm into something else, there's usually some bridge code that's written in JavaScript. And that glue code can be substantial and it can be non-trivial to produce. Keep that in mind when we look at it a little later.
So, a couple of buzzwords that that will pop up um that >> [clears throat] >> there is a thing called and they all have have cute names. So, there's WAT, that is the WebAssembly text format. We will not actually see this today.
I've put in these links in case you you later want to download the slides and and dig a little bit deeper.
That's the same thing as the as the WebAssembly binary instructions, but just written in text.
Um there is a thing called wabt um that has tools. For example, wasm to wat will take your wasm file and turn it into that text file format. And this it has a bunch of other tools in there that we sometimes need.
More importantly, there is the WASI, [clears throat] the WebAssembly systems interface, where yeah, I told you before there's no way inside wasm to actually like read a file connect to a socket. And those things are now being specified and standardized in the WASI effort. So, um >> [clears throat] >> there are so-called WebAssembly components, mercifully not wac, um that standardize a component model. And the most important part of that is the is an interface type description. So, if you wanted to come up with some other way of calling from the wasm that does nothing into the world, then one can describe that with these interface types. Of course, all of this the things that are in WASI are being so described.
And it's important to know that this is all very bleeding edge. So, if if we look at um this wasm webpage, you see that there is all sorts of features and different runtimes support them to various degrees. And so, in practice, when you want to work with this today, that is something one needs to know about. The Wasm itself also, when we go there, we'll see that it too comes in phases. So, there's a 0.3, 0.2, and every tool that we'll be showing you today is at a different level of these things. And it makes it it [clears throat] So, today the kind of interoperability that eventually will be there is is still a bit of a struggle. All right. So, I'll turn it over to Jeff and he's going to talk about Yeah, so there there actually, if you know where to look, there's probably a dozen or more solutions of getting Java to the browser starting probably 15 years ago. GWT was one of the big ones and I think Google was the champion of that, but they've kind of morphed that into something called J2CL.
And and of course a lot of the Google Docs apps uh use it still. The big problem with it for us that love the pure Java is that they don't support the the the standard runtime.
So, we've limited for the browser section here, we've limited to three contenders that really seem to be care about what we care about with the runtime.
There's CheerPJ is an actual JVM in the browser and then so, I call it the the reigning champ because it's it's the closest to what we're used to on the desktop.
>> [snorts] >> And TVM is is the real scrapper that's been around for a while. There's one guy that works on this and it's a really amazing feat of engineering where where he takes your Java bytecode and turns it into JavaScript or WebAssembly or even C.
And and does the minimization.
Uh and actually let me progress to my slides here about um [snorts] Uh of course like so Cheerpj like I said is the full JVM. They took the OpenJDK and actually did a port and and then they're just on the back end implementing like the platform services that we expect.
And and so it actually just takes a takes your actual JAR file and you put a little wrapper around it and it it pulls in your JAR file, pulls in the JVM. Uh and it's really clever about it. It it uses byte ranges so it doesn't pull in the 80 megabyte runtime file. It might only pull in 10 megabytes of it uh [snorts] for most applications.
And then TVM like I said is a it takes a different approach is ahead of time. So it takes your your byte code and turns it into web assembly. Uh so you don't have to have the the just-in-time overhead. Uh and then they can also TVM does this amazing job of minimization.
It finds all the dead code. It only pulls in the parts of the runtime that you need.
And and then it does minimization as far as all the symbols to get that file as small as possible.
Uh and and then we have this new contender GraalVM web image and they're really taking the same approach as TVM but they're using the actual Java runtime.
And uh uh so it it uh will probably be a really good contender and a lot more bulletproof as far as getting consistency.
What runs on the desktop runs the same way in the browser.
So my hands-on here is compilers compilers compilers. For some reason, whenever somebody has one of these tools, the first thing they want to do is compile Java in the browser.
And and so every one of these tools has an example. And so here's our Java code in the browser, and you've probably seen a lot of tools like Java playground that you can type in Java code. And what they're all doing is a round trip to the server. So they're they're sending it out to the server, it's doing the compile, and then it's sending the the results back. In some cases, they'll run it and send just the the run back.
And but this is actually pulling in the pulls in the whole compiler, and it compiles it in the the browser or in the client. So you don't actually need a server for this other than a static website.
And I think I got my run there.
>> [snorts] >> And and I'll just show one other. The GraalVM is very similar to the TVM. I guess they're all very similar.
What's that?
Zoom in?
Oh.
You know, actually, I don't even really know how to do that. Is it just Zoom.
Yeah.
Yeah, thanks for that.
Okay, so that's the compilers.
>> [snorts] >> There you know, so of course there's just some undeniable benefits. So my little company ships ships apps, and you want to get apps into people's hands, and these days that's a little scary. You know, you you go to some site and there's an app, and it sounds promising, and you think, well, I download and install this. Do I trust these people? Is it going to download a 100 files and and hide things squirrel things away that I'll be carrying with me for the next 20 years?"
Uh so, it it's really nice as far as getting rid of barrier to entry to have something in the browser.
Uh >> [snorts] >> and uh yeah, and then you don't have to worry about those security concerns. Uh code signing was an issue for a lot of long time. I was chasing this with desktop apps where I write the app and and I have to get it you have to code sign it.
And that's jumping through a lot of hoops.
Uh [snorts] and you get real run anywhere. Then, you know, if you get it running in the browser, it runs on a tablet, runs on a phone, runs on a laptop.
A lot of cars will run on their console.
Uh and and then you get a great in the Java ecosystem, you get just the the the best of class running on the desktop. You'll hear JavaScript people complain all the time about they take their app to the desktop and they run it in Electron, and it's immediately a gigabyte uh you know, Chrome wrapped application.
>> [snorts] >> Uh but, of course, there's some downsides uh that that WASM uh as Kay said, is it's it's almost it's really designed to be as simple as possible and have as little as possible. And and of course, they're incrementally adding all the pieces we need, but but right off the bat, we don't have a file system uh in some of these tools. And and then the ones that do support Java file systems have emulated it, and they'll save it to like IndexDB. Uh so, it's it's local, so you can't get access to files on your desktop uh without adding an interface for that. Uh >> [snorts] >> but, there's ways around all that.
Networking is an issue in the Java world. We're used to saying, "Give me this HTTP uh URL." and getting the bytes.
Uh the the browser is not that way.
It'll It'll uh complain unless the target website is configured to allow it. Uh but there's ways around that.
There's the uh VPN type uh solutions or there's course proxy where you can you can take the URL and send it out to a a back-end server that fetches it and gets the bytes and gives it back.
Um but it is an issue. Uh when you're developing, backtraces can be problematic. Uh the these tools all will try to minify. Uh so, when you get a backtrace, it won't say uh uh the methods you're used to. You'll see little encoded strings in there.
Uh and transpiling can be time-consuming.
Uh we don't have this problem with ChirpJ cuz it's actually running the the JAR file uh out of the browser. But the other tools uh where after you get your bytecode or your JAR file in the shape you want it, you kick off the transpiler and it might be 20 or 30 second uh iteration. And and you know, Java, one of the great things about Java, I think, is is our development is so quick uh to iterate sometimes.
Uh and you lose a little bit of that if you're if you're really iterating with the browser.
So, uh let me show uh SnapCode here. Uh So, so this is a a pretty good uh complete uh application. So, first, uh just go into the to the website. So, SnapCode is a Java IDE. You know, and and a lot of times when people are getting started, the there's uh how do I get started with uh NetBeans or Eclipse or IntelliJ? And there's a you know, five-page instruction manual on how to get started.
>> [snorts] >> And uh in the browser world, we just say uh run it. So, just going to the website where we're reading the the materials, I can just hit playground. And so this differs from the Java playground in that uh there's no server. This is all static. It's all running uh in the on the client side.
And uh and it you know, we can type in our code here and it's already done a compile for us. And when I hit run, uh it'll run and it's running in the browser.
And [snorts] and this is a good example of a hybrid application where we've got Java and Java I mean HTML and JavaScript and then we've got Java client UI in the same page. Oh, Jeff, I didn't get that.
That button there? Uh-huh. Is that a Is that swing or what [snorts] is the button? Well, so it's on top of swing.
Snap code is written using my own Java UI kit.
And and the the benefit of having a custom UI kit is that it can run on the desktop. It uses swing and the graphics 2D object to render all the pixels. And in the browser, it can actually use the HTML canvas element and and and use the DOM APIs or the web APIs to get full native speed in the browser.
And it doesn't have to you know, download all of swings imaging libraries and and such like that.
>> [snorts] >> So that that is an option and then we'll talk DOM programming in a moment here.
And I'll go ahead and hit run run out from that same page and it it brings up the whole browser. I mean the whole application.
And and you know, hopefully it's up for my my UI aesthetics are not so good, but but it it can definitely look just like a real web application.
And you notice like the the launch time.
In fact, I'm going to be brave here and hit refresh.
And so it's launched the program. Now, the first time you do that, it pulls down 15 MB of runtime, but that's really not that much anymore. You go to New York Times.com and it's uh 49 MB download according to a blog I just saw.
Uh so, 15 MB, that's 2 seconds of YouTube video. Uh so, so a lot of people won't consider Java in the browser cuz they think, "Oh, it's prohibitive to to run the application." But really, a 1-second launch time, it often launches faster in the browser for me than it does on the desk on the desktop.
Uh [snorts] so, I'll just say new Java snippet.
And uh and I can just start coding here.
>> [snorts] >> And so, this is tries to have all of the the modern features uh and uh that a normal IDE has.
Uh but it should be a lot more approachable. Education often has a problem where they don't have desktops anymore. They've got Chromebooks. And so, they can't install on the computers they've got. So, the ability to uh uh to be able to bring uh up a a full IDE in the browser, that you don't waste a day doing the install.
And uh uh so, and and you know, we get full uh sophisticated applications. So, uh uh so, I'll just run through a couple quick things here.
Uh this is like doing a turtle graphics that uh let's see. Find my source file again.
Yeah, so I had the code for this turtle graphics here.
And I add the code, it does the compile behind the scenes for us, and and it's running uh inside of there. And then uh the this is something we see a lot with Python now. Like that gives me a little bit of Python envy. Uh with uh uh uh students can go into their Python and they can just type in a little bit of uh uh a few lines of code and get some graphs up.
>> [snorts] >> And you know, so now we can do that in Java.
And and so this is actually showing off WebGL bindings.
Uh and and so this exact same program runs on the desktop. And that's where all the development is. And so the development's super easy when it gets to a state that that uh I want to do a ship, I just uh take the exact same jar and put it on the web and it's done.
And I am quickly running out of time here as uh K warned me I would.
Uh let's see. Uh so so let me show a quick uh DOM demo. Uh so so when you want to talk to uh if you want a lower level than something like Swing or SnapKit, uh DOM uh all the tools with the Graal and the Chirp and and TVM lets you uh call out to uh uh to the DOM APIs.
>> [snorts] >> And so here we just say give me a window document. This will be familiar to anybody who's done JavaScript in the browser. And uh create a button and show the button. And so this will be a little underwhelming because the the the button looks like any other button.
>> I'm always terrible with this. This this is now This is a Swing button? Yeah. Oh no, this is so this is uh HTML. And uh you know, so we have so much stuff going on. You know, we've we've got uh the Chirp J JVM running. We've got SnapKit on top of that. We've got the compiler pulled in. And then we've got a child process. And the child process is an iframe. And the iframe's got an HTML document. And inside of there we've got our HTML button.
All right.
Okay. And uh and let me just go back to the slides real quick. So here's the DOM programming we talked about. And we talked about the the Java bridge. We can generally get straight to the web APIs with a with a bridge library, but there's also ways to just execute raw JavaScript strings.
I [snorts] just got a few slides here about getting started.
All these things are super easy. You just basically have a process that says turn my JAR file into byte code into web assembly and you wrap it in a little, you know, 10-line HTML file and it'll run.
Same thing with growl. So the in the slides you'll see this there's a pointer to the guide and and the guides are in general just one page long.
>> [snorts] >> And with that, let me go back to K for hands-on the other direction. So I need to switch laptops because um this I'm actually going to be running a few things here.
>> [clears throat] >> So So now we're back on the server. So you've seen that in the browser. This is pretty fantastic, right? You can run Java in the browser better than it has ever worked before.
You can write user interfaces in Java without having to use that that other inferior language that so far has been used for writing the browser. So lots of things can be done in a pretty elegantly and the technology really shines there.
Now let's get outside the browser.
So >> [clears throat] >> what is possible and I'll show you a couple ways of doing that. You can take any wasm code whether it originated from rust or go a C++ or whatever and you can call it from Java.
And so why might you want to do that? Of course you can call C++ code from well at least you can call C code from Java, right? With foreign functions or with good old JNI.
Um if you wanted to call Rust code from Java, that's not so easy.
Um and so now you can though do that um if you first compile it to to Wasm.
So one [clears throat] reason some people do this is because of this sandboxing.
They have some foreign code. So I actually talked to someone who says they get code from a customer that does some business logic, they don't really trust it. They put it in a Wasm sandbox so that they can run it inside their Java application.
Um so there's a few of these runtimes that enable this. One of them is called as Chickory. It's written in Java and so it runs Wasm. That means you can call it from Java and we'll see in a minute actually an application that does just that. Um it's [clears throat] kind of limited. It runs a WASI at at the 0.1 level. It doesn't have any support for exception handling, so that's a little uh icky.
Um there's GraalWasm. Um so with Graal we To be careful. So you showed us Graal WebImage. So GraalWebImage will turn Java into uh into JavaScript or Wasm that can be run in the browser.
GraalWasm will uh turn things will make it so that you can call Wasm from Java, that you can consume Wasm from Java. Um >> [clears throat] >> then there's GraalJS which lets us consume JavaScript from Java and they're slightly different. We'll actually be seeing GraalJS um in just a minute. So let's just So Graal does both both sides of the of our presentation.
>> Yes, it it's Graal's super confusing in that in that it it can uh consume Wasm and it can produce Wasm.
And they have slightly different code names for each of those things.
Um so yeah, keep keep slowing me down whenever I'm too fast for that.
Um all right, so let's let's run one demo. So, just a few days ago, I saw oh, Chickory is now available as a Quercus extension.
And I said, "Hey, so let's just make something with Quercus and Chickory."
And so, what I did is a thing that converts markdown to HTML um that is being called from a web application. So, this code now, unlike all of the things that Jeff has shown, will run on the server.
Um so, let me run this really quick. This is my terminal.
So, I'll I'll just uh start it up and go to localhost 8080 and we'll see when it comes. It'll It'll be there in just a second.
Here we go. Um so, here let me uh we have markdown input on the left.
If I type convert, then on the server, it will now have called um this web assembly module and converted the markdown to HTML and put it in an iframe. All of this happens on the server. You might say, "Well, what's with that?" And I'm just using it this as a proxy for there there is this conversion library. Someone has written it. It exists in WASM. I don't want to rewrite it. I'm just going to call it from uh from Graal. So, um the the code is Let's have a really short look at that.
Um is actually super simple. So, over here you see some some uh standard uh Quercus stuff where we're just calling some method, and that method is then implemented here.
Um so, it calls um by using the um the Graal bridge, it calls into uh into the WASM module, and the thing is not super confusing except there is a little weirdness down here where you're seeing a a [clears throat] callback where it uh it does some memory allocation that uh so I as the user of this have to supply little snippets of code that do odd things like allocating some block of memory.
Um and so how do I know that?
I had no idea. So I of course I asked ChatGPT and it did a very good job um to give me these little pieces of random-looking glue code. I mean one can figure it out um and it's tedious and time-consuming to do it um and um uh it just does something that when you have a project like that you think that you have this module that you can just call. Um there is a bit of work ahead of you. And so the next thing that I tried is I said well this markdown to HTML well that's small beer you can of course do that in Java. Let's take something more complicate complicated like Pandoc.
Pandoc is written in Haskell. Obviously it's not would not be all that easy to call it from Java. You could call it in a separate process but you can't just [clears throat] call it directly and sandbox it. Um so having that Wasm module of Pandoc I thought that's great.
So I talked to the Graal people and say well what would it take to run Pandoc inside Graal. And so they they made me a demo um because I couldn't do it um and um I'm not going to run it in the interest of time but uh we'll have a quick look at the code.
Um So um we we see a tantalizing-looking Pandoc Wasm library in here that is actually not the Wasm library that I downloaded from the site that I showed at the very beginning of the presentation because that library is uses a version of exception handling that Graal cannot take. But, the the guy from Graal [clears throat] said, "Not a problem. We're going to run it through one of these tools, and that'll rewrite the entire module to use a different style of exception handling that does work with the current version of Graal."
And then, I thought, "Oh, I'll just call because when you're using JavaScript, you just call one one JavaScript function, and it does the converse."
Okay, I was prepared that I might have to figure out how to get the the string into into bits and into into byte array and conversely out again. But, it turns out one has to do a lot more. So, they wrote me a bunch of glue code, which we say see here that that >> [clears throat] >> in in in JavaScript that loads this module. And I was going to show you so that you have an idea of the extent of what that thing is. So, that's kind of a pain that one has to do Sorry, this is a shell script that generates this. The glue The glue code is not that bad. Let me pull it up.
Here it is.
So, even when passing strings back and forth Oh, you have to put them into the memory. Yeah. So, this the string you have to then convert into byte array, and then you have to use whatever mechanism this particular configuration needs to put that into into Then, you have to to make the memory allocated, give a pointer to that thing to us.
That's the way it works. So, WASM really knows nothing but numbers and pointers inside byte arrays. So, the these pointers are are safer [clears throat] than C pointers in that they are tied to the You you can't overrun the block. So, that's why you have safety, but you do have to do that transformation somewhere. And so, what one wishes, of course, is And that is the promise that at some point these type definitions that are going to be coming that they can be transparently then proxied in Java. We're not there today. So, today there is this glue code that you have to do. But, no, this this promise is definitely there. All right. So, here um like I said, we see that some of this glue code. And so, I I asked um uh my friend there at Graal and said, "How did you write this?" And he said, "You know, the chatbots are pretty good at it." And >> [laughter] >> So, uh it's just something to uh to know about. All right. So, we can run a Wasm module inside a web app.
Um with you know, a bit of magic. And so, you would do that if for whatever reason you have this module that does some functionality, and you don't have it in Java, but you have it you know, in some other language, you compile it down to Wasm. There's another nice example that the Graal people give where they have an image processing library that was written in Rust, compiled down to Wasm. They call it and do some image processing on the server. Um and so, if you have that kind of use case or uh contemplate having it, that is an option.
All right. Um the other thing that one can do um is you can compile Java to Wasm, and then run it. How would you run it? Um well, [clears throat] there is there's some um uh systems [clears throat] that will run it. Um and I guess first I should say, how do you even compile from Java to Wasm? There's two ways. One is with Graal, and the other is with TVM. Um there's a couple of others that I mean, I've tried them. They they kind of work, but they seem to be more or less um I a single person who does it, or kind of abandoned. So, I think uh really Graal and TVM are a way you can use it. So, you can deploy it. And Cloudflare Cloudflare has like Wasm workers, you could deploy it there. You could deploy it with a thing called Fermion, um which [clears throat] uh was bought by Akamai.
And so, it'll run a Wasm module on their on that Akamai network. Um and so, they say it's a great thing, sandboxed, it's fast startup, which it really is, it's low resource usage, and wouldn't you want to be able to write these services in Java?
There's an API that supports Rust and Python very nicely, but it doesn't really do anything great with Java. What you can do is you can run your Java program just like you used to run a Pearl program in CGI. So you feed things into standard input, you read from standard output, and you make a if you you [clears throat] give the the call parameters through an environment variable. So as long as one can read standard input, write standard output, and read environment variables, you're good. So of course I had to try that, and I said, well, what can I do at the edge? Well, there is a need for a service that gives you a random joke.
And so in order to have another parameter, I also have like a random quote. And so I deployed this now to the Akamai network, and anywhere you can now have this at at a node near you.
So what did I have to do? I wrote the thing in in Java, used TVM to convert it, because for some reason Graal is not today ready to produce the kind of WASM that Fermion wants.
They will at one point be ready for that. All right, so I [clears throat] needed to again overcome some limitations that ChatGPT helped me out with, where I had to bridge, and in the interest of time I'm not going to show it now, but you can download all of that code, and it's kind of interesting to read. So if you actually have to do something like that, where you can make a bridge so that I can [clears throat] read an environment variable.
And so now I can read an environment variable, and I can go and and get my random joke.
See if I find it here.
I don't know, sorry. Um, I'll just run it locally.
>> It's not worth it. The jokes are no good.
Um >> [laughter] >> Oh, no cost.
But they're better in Java. Uh yes.
Okay. All right. Well, here you go.
I told [clears throat] you it's not worth it. All right.
So Um If it >> [clears throat] >> um So in summary, uh where we at? So on the browser things are good, right? Absolutely. So So I think um So we all agree uh in the browser things are good. On the server, you know, we have these two separate use cases. Java can call Wasm or Wasm can compile Java into Wasm so that it can be called. And both of them, you know, kind of work. There's tools that make this possible, but there really are challenges. So right now, the interface between your Java code and the rest of the world is super clunky. And it [clears throat] um it can get better, but it's not there today. The API access is by design limited. So the tools that we want we'll need to work on making that, you know, much more transparent.
It is not reasonable for a Java programmer to have to worry about, you know, uh how how to do that.
Um right now, there's a lot of incompatibility between the tools, >> [clears throat] >> what which versions of Wasm and Wasi they support, and uh also uh when you pick up a module in the wild on how it was produced. And so um there [clears throat] there's some bridging one has to do about that. So is it the future?
Um well, Charles de Gaulle famously said about Brazil, um Brazil is the country of the future and it always will be.
And depending on how you read it, right?
He was a diplomat. This could be a positive statement, you know, once that it has achieved its promise, it will always stay there. Or you could read it in a way that you know, saying a good luck. Um and [clears throat] so that is One part of what we're trying to do is evangelize, right? Yeah. It's not that it's too hard to make this work, but the it's a chicken and the egg situation of of where's the user demand? Where's the developer demand?
Yeah, so this could be great. Like Brazil. Um and uh so all the pieces on the arc kind of coming together. Um they're not coming together right now. So when you read a blog, um you know, read through the blog carefully um and see whether what the blog describes is is actually working today, whether the working is with a a bunch of bailing wire um and duct tape or whether it's not working at all. I did read one blog where they claim to run an arbitrary Spring Boot application on the edge in Chromium. And it simply is not possible to do that. They claim to have first translated to x86 instructions and then from x86 instructions to uh to Wasm. This is simply not a thing that one can do. And upon further inspection, it was of course an AI generated blog. Um so be very careful what what you read about.
So I hope we gave you um uh a few ideas on how to do reality checks on what what you do read. So browser AOK, um server work in progress.
Questions?
So um what first of all the advice for quite a few Brazilians at this conference? Yes.
>> [laughter] >> Yes, I I I told Bruno to put them all in another room somewhere.
>> [laughter] >> Um so how compatible across browsers is Wasm?
Extremely compatible. I I mean uh a lot of them are using the the same V8 engine.
Uh you know, so Edge and Chrome uh and and I think Safari, if they're not using it that I think they announced that they plan to.
Uh but it it uh it's been really consistent. Things that work on Firefox and Chrome, I try to test maps and and so far I've had no real issues.
Other questions?
Okay, well if you have more questions, um you know where to find us in the hallway. And if you have any actual use cases or anything that where you know more than we we do, you know, seek seek us out and we'd be glad to chat. Thank you. Thank you.
>> [applause]
Related Videos
Agentforce NOW AMA: Build with React and Salesforce Multi-Framework
SalesforceDevs
490 views•2026-05-28
How agent o11y differs from traditional o11y — Phil Hetzel, Braintrust
aiDotEngineer
450 views•2026-05-28
Re: 🗣️📍theprophedu📍2026 GST 103 CLASS (E-EXAM REVISION)
theprophedu
636 views•2026-06-04
WEB TECHNOLOGIES UNIT-2 | Degree 4th sem BCOM Computers web technologies unit-2 full explanation💯✅
LearnwithSahera
1K views•2026-05-29
More tests are always better? How to use AI to identify tests that bring little value
Alliance4Qualification
335 views•2026-05-29
Search Algorithms Explained in 60 Seconds! 🤖💨
samarthtuliofficial
218 views•2026-06-01
People of Game of Thrones using JavaScript DOM
AltCampus
296 views•2026-05-30
Instagram accounts got PWNed
EricParker
13K views•2026-06-03











