logo

JavaScript in WebAssembly? Why and How

Conference:  CloudOpen 2022

2022-06-22

Authors:   Michael Yuan


Summary

WebAssembly can be used as a secure container format to run microservices alongside other containers and VMs. The runtime can be made fully OCI-compliant and support JavaScript to make it widely adopted. However, there are challenges in supporting Node.js APIs and a community effort is needed to support JavaScript APIs.
  • WebAssembly can be used as a secure container format to run microservices alongside other containers and VMs
  • The runtime can be made fully OCI-compliant and support JavaScript to make it widely adopted
  • Challenges in supporting Node.js APIs and a community effort is needed to support JavaScript APIs
The speaker shared a demo of a website extension that interacted with TensorFlow using WebAssembly for inference. The Rust application interacted with the underlying TensorFlow library and the ROS library was packaged into JavaScript APIs. The demo allowed users to upload an image and receive a prediction from the TensorFlow model.

Abstract

As WebAssembly (WASM) is adopted in cloud-native applications, there are increasing demands to support JavaScript applications and libraries in WASM. That allows WASM runtimes, such as WasmEdge, to run serverless functions written in JavaScript and Node.js APIs. WasmEdge first wraps the C-based QuickJS interpreter in a Rust crate, and then compile it to WASM. The Rust crate allows developers to extend and enhance the JS interpreter to support ES6, CommonJS, and even NPM modules. It also enables developers to implement JavaScript APIs in Rust to improve performance. At deployment, WasmEdge can run as a secure container in k8s pods itself, as opposed to the heavyweight "Linux container + guest OS + node + v8" stack of JS tooling. Michael will walk you through the technical challenges and solutions to run JavaScript in WASM in this talk. Michael will present performance benchmarks and demonstrate complete examples running React SSR and Tensorflow inference in JS serverless functions.

Materials:

Post a comment

Related work





Conference:  Defcon 31
Authors: Mikhail Shcherbakov KTH Royal Institute of Technology, Musard Balliu KTH Royal Institute of Technology
2023-08-01

Conference:  Black Hat Asia 2023
Authors: Mikhail Shcherbakov
2023-05-11