Simon Bisson
Contributing Writer

Jump into WebAssembly with Hippo

analysis
Oct 6, 20218 mins
Cloud ComputingMicrosoft AzureRust

Deis Labsโ€™ Hippo WebAssembly PaaS makes it easy to build and run portable WASM applications, whether theyโ€™re browser-hosted or standalone.

midair jump / leap / cross over / path / highway / road
Credit: Warren Wong

WebAssembly is an extremely promising new technology thatโ€™s getting a lot of interest from Microsoftโ€™s cloud-native computing teams, both in its Deis Labs subsidiary and in Azure. With new WebAssembly tools arriving rapidly, whatโ€™s needed is an environment where you can try them out.

Thatโ€™s why Deis Labsโ€™ release of itsย new Hippo WebAssembly platformย is so important. Built like many of Deisโ€™ tools to scratch its own itch, itโ€™s a way of quickly installing, managing, and running WebAssembly (WASM) code, whether itโ€™s browser hosted or stand-alone WebAssemblyย System Interface (WASI). Using its built-in channels in conjunction with a Git server, you can make and deploy different releases in one environment, keeping production, staging, and development builds separate while still only needing one Hippo server.

You can host multiple applications in Hippo. WebAssembly means theyโ€™re sandboxed by default, requiring explicit permissions to access the host system or external devices. Your code is also portable. Once compiled for WebAssembly, itโ€™ll run on any WebAssembly system, whether Windows, Linux, or macOS, or whether Intel, RISC-V, or ARM. Hippo gives you a way to build once, test once, and run your code anywhere.

Setting up Hippo on a development PC

Although tools like Hippo would be ideal for cloud-native operations, the current developer release has only been tested on desktop systems. I decided to try it out on a Windows PC running a recent build of WSL2, hosting Ubuntu. Deis provides instructions for running Hippo locally, with details for macOS and Linux systems.

There were some issues getting the prerequisites in place to run Hippo on a WSL2 Ubuntu 20.04 LTS system. First, I needed to install WAGI, the WebAssembly Application Gateway Interface. This installs easily enough, with a single binary in the downloadable tarfile hosted in its GitHub repo. Once download, unpacked, and moved to a user binary directory, it ran easily. I took the opportunity to install Rust, as I might need it if I had to recompile any of the Deis tools.

This step was perhaps the most difficult on WSL2, as it required a copy of the build-essential toolkit. Ubuntu 20.04 doesnโ€™t have the right set of dependencies for this, so I needed an alternative package installer that would allow me to downgrade certain key libraries to the appropriate versions. A Stack Overflow answer pointed me to aptitude, an alternative to apt that allows you to choose appropriate dependencies for an install and allow it to replace two low-level C libraries. I finally got build-essential installed, ready for Rust, using its setup scripts.

What is Bindle?

The main reason for installing Rust as part of a Hippo installation is for Bindle, Deisโ€™ WebAssembly packaging tool. Bindle is described as an โ€œaggregate object storageโ€ system. The metaphor its documentation uses is that โ€œBindle is the digital silverware drawer.โ€ We may all have some different objects in our silverware drawer, but we all use the drawer to sort and store silverware. Bindle does much the same for the artifacts that make up a modern application while providing a level of understanding of how applications are composed, based on how and where theyโ€™re used.

You can have a Bindle description of an application that contains elements needed for a sparse installation on a resource-constrained edge host (like a Raspberry Pi) and for a high-powered server at the heart of a public cloud. A Bindle client in an application host can take the elements and dependencies and deploy them appropriately. The result is an application-centric deployment model that avoids multiple builds using repositories and smart descriptions to deliver the right code to the right environment.

Once Bindle is installed, you can run it, using the defaults to set up a local Bindle server ready for Hippo to use. Next, I installed node.js, using the WSL instructions provided by Microsoft. This entailed using curl to download nvm, then running it to install both the most recent and long-term support versions of node. Donโ€™t use the Ubuntu instructions for installing node; they use a snap to install it, and snaps are not well supported in WSL2.

Youโ€™ll need to install Rustโ€™s wasm32-wasi support for any Hippo-hosted Rust WebAssembly applications, as well as the yo-wasm Yeoman application scaffolding tools. This will allow you to compile Rust code to a WASI target, ready to run inside Hippo.

With those in place, I could now install .NET 5, first setting up support for Microsoftโ€™s Debian package repositories before installing both the .NET 5 SDK and runtime. You haveย two options for .NET runtimes: one with ASP.NET Core support and one without. As Hippo is a model-view-controller web application, you should use the ASP.NET version of the runtime.

Building and running Hippo

Once all the prerequisites have been installed, you can build Hippo. Start by cloning the Hippo GitHub repository into a local directory in your WSL system. Once itโ€™s installed, you can build and run the app, pointing it your local Bindle server by adding a BINDLE_URL environment variable. Itโ€™s a good idea to install Hippoโ€™s CLI at this point, as itโ€™s necessary for application development and deployment.

You can now connect to your Hippo server to test that itโ€™s working. You should find it on localhost on port 5001. If youโ€™re running a recent build of WSL 2, you should be able to connect to it from a Windows desktop browser using localhost, as Microsoft has finally fixed one of WSL 2โ€™s long-standing networking problems, proxying its virtual machine networking through Windows while still preserving its own IP address and virtual network switch. Thereโ€™s no longer any need for scripts to extract and share network addresses.

Before you can connect to the server, you will need to register an account. As itโ€™s running locally, you can choose any account details you like; just be sure theyโ€™re something you can remember since youโ€™ll need the details to build your first app. Once youโ€™ve created an account, log in. Youโ€™re taken to a Your Apps page with a Create New Application button.

Creating your first Hippo WebAssembly app

Although you can build apps for Hippo from the web UI, itโ€™s easier for now to use the command line. Make sure you have the Hippo CLI installed, as Yeoman will use it to build application scaffolding for you. Before you start, set environment variables for your Hippo account and password as well as for its endpoints. Yes, this isnโ€™t good security practice, but here weโ€™re just building and running test code on an isolated PC using software thatโ€™s not yet ready for production.

To build a basic hello world application, use the yo-wasm tools to build a WebAssembly Rust application. If you follow the script and enter the appropriate values, this will build and load source code into your Hippo server. Next use the Rust cargo tool to compile and test your WASI application. Once youโ€™ve got it running on the command line, you can use Hippoโ€™s CLI tool to push it to Bindle where it will be visible inside Hippo. Open the project, select your buildโ€™s development environment, and click on the link to run your code.

Thereโ€™s a lot to like in Hippo. If thereโ€™s one thing thatโ€™s been missing from WebAssembly, itโ€™s an effective Heroku-like playground to help you get started. Hippo may not be that playground yet, but itโ€™s certainly one you can use as part of your own development workflow now, even in its early stage. Being able to run it on a development PC is an added advantage, as thereโ€™s no need to rely on third-party systems. Itโ€™s low enough impact that it can be run as part of a WSL 2 environment, so you can take advantage of tools like Visual Studio Code, working with its remote development features to edit Rust code in WSL from Windows.

If youโ€™re interested in WebAssembly, Hippo may well be the tool you need to get started. It makes working with WebAssembly code simpler, bringing many of the different pieces needed to run a development into one place. Although itโ€™s still clearly an early release, thereโ€™s enough here to let you get started, making it an essential tool for anyone working with WebAssembly.

Simon Bisson

Author of InfoWorld's Enterprise Microsoft blog, Simon Bisson prefers to think of โ€œcareerโ€ as a verb rather than a noun, having worked in academic and telecoms research, as well as having been the CTO of a startup, running the technical side of UK Online (the first national ISP with content as well as connections), before moving into consultancy and technology strategy. Heโ€™s built plenty of large-scale web applications, designed architectures for multi-terabyte online image stores, implemented B2B information hubs, and come up with next generation mobile network architectures and knowledge management solutions. In between doing all that, heโ€™s been a freelance journalist since the early days of the web and writes about everything from enterprise architecture down to gadgets. He is the author of Azure AI Services at Scale for Cloud, Mobile, and Edge: Building Intelligent Apps with Azure Cognitive Services and Machine Learning.

More from this author