O'Reilly logo
live online training icon Live Online training

WebAssembly First Steps

Safe, fast, and portable software development

Topic: Web Platform
Brian Sletten

WebAssembly—one of the most fundamentally interesting and transformative technologies in recent years—is designed to allow the web to be a target platform for existing software development beyond the world of hundreds of interdependent JavaScript libraries. It’s an attempt to manifest the longstanding goal of zero-installation apps that are also performant, secure, and as useful as desktop and native applications, creating a world where your code is able to run with near native speed on just about any platform out there, regardless of the programming language in which it was written.

Expert Brian Sletten takes you through using WebAssembly in the browser—giving you the power to write less code that works in more places for longer. You’ll also get a glimpse of what’s happening with respect to WebAssembly out of the browser. Join in to understand how to bring many existing applications to the web merely by recompiling them and how to extend existing web application development into new markets that were previously unhandled due to some of the limitations of JavaScript as a programming language.

What you'll learn-and how you can apply it

By the end of this live online course, you’ll understand:

  • What WebAssembly is and how it works
  • How it will impact software development in general
  • How it will impact web development in particular
  • How it will expand what’s possible in web development environments

And you’ll be able to:

  • Explain how WebAssembly allows you to develop fast, safe, portable code that can be deployed in a web environment
  • Build WebAssembly-enabled applications that run in the browser
  • Create WebAssembly modules in different languages
  • Incorporate tooling (compilers, builders) into your builds
  • Write code in languages other than just JavaScript that will run in the browser
  • Run applications such as SQLite in the browser

This training course is for you because...

  • You’re a developer in an industry that has problems that aren’t always a good fit for JavaScript.
  • You’re a JavaScript/web developer who wants to understand how WebAssembly will impact your career.
  • You’re an application developer interested in migrating your existing desktop and command-line applications into the web environment.
  • You’re in tech leadership and want to learn how WebAssembly will improve productivity, lower costs, increase security, and extend the value lifetime of written code so it can be used more widely and for longer durations.
  • You want to be prepared for the development environments of the future.

Prerequisites

  • A computer with a modern browser that supports WebAssembly and the ability to run a small web server via Python, NGINX, etc. (optional—required to participate in course exercises)
  • Familiarity with JavaScript and conventional web development languages, standards, and tools
  • A basic understanding of a language like C or Rust (useful but not required)

Recommended follow-up:

About your instructor

  • Brian Sletten is a liberal arts-educated software engineer with a focus on forward-leaning technologies. His experience has spanned many industries, such as retail, banking, online games, defense, finance, hospitality, and healthcare. His interests include web architecture, resource-oriented computing, social networking, the Semantic Web, data science, 3D graphics, visualization, scalable systems, security consulting, and other technologies of the late twentieth and early twenty first centuries. He has a BS in computer science from the College of William and Mary and lives in Auburn, CA.

Schedule

The timeframes are only estimates and may vary according to how the class is progressing

Introduction (15 minutes)

  • Presentation: We will establish the main goals for the WebAssembly initiative.
  • Q&A

Asm.js (15 minutes)

  • Presentation: We will discuss the path to WebAssembly through Mozilla’s asm.js proof of concept.
  • Exercise: We will ask the students to run an asm.js application in their browser
  • Q&A

WebAssembly Basic Concepts (20 minutes)

  • Presentation: We will discuss the basic structure of modules and functions and how to invoke behavior from JavaScript.
  • Exercise: We will ask the students to run a WebAssembly-enabled JavaScript app in their browser
  • Q&A

Introduction to C (10 minutes)

  • Presentation: We will cover an extremely basic overview of C. Just enough to make the next section make sense.
  • Q&A
  • Break (5 minutes)

WebAssembly and C (20 minutes)

  • Presentation: We will discuss the process of converting a C application into a WebAssembly application.
  • Exercise: We will ask the students to compile a C application to WebAssembly in the browser and then run it from JavaScript.
  • Q&A

Introduction to Rust (10 minutes)

  • Presentation: We will cover an extremely basic overview of Rust. Just enough to make the next section make sense.
  • Q&A

WebAssembly and Rust (20 minutes)

  • Presentation: We will discuss the process of converting a Rust application into a WebAssembly application.
  • Exercise: We will ask the students to compile a Rust application to WebAssembly in the browser and then run it from JavaScript.
  • Q&A

WebAssembly Memory (15 minutes)

  • Presentation: We will introduce the notion of WebAssembly Memory instances and how they allow us to emulate pointers and shared memory.
  • Exercise: We will ask the students to pass a WebAssembly Memory from the host environment into their WebAssembly module and use it to produce a result.
  • Q&A
  • Break (5 minutes)

WebAssembly Tables (15 minutes)

  • Presentation: We will introduce the notion of WebAssembly Table instances and how they allow us to provide dynamic linking between modules.
  • Exercise: We will ask the students to pass a WebAssembly Table from the host environment into their WebAssembly module and use it to produce a result.
  • Q&A
  • Break: 5 min

WebAssembly and wasm-bindgen (20 minutes)

  • Presentation: We will discuss the role of the wasm-bindgen tool in mediating the interaction between Rust and JavaScript.
  • Exercise: We will ask the students to build a Rust application that invokes browser behavior through wasm-bindgen-generated interfaces.
  • Q&A

The Future of WebAssembly (20 minutes)

  • Presentation: We will discuss the impending future of WebAssembly including WASI, WAPM, the Interfaces spec and the Bytecode Alliance.
  • Exercise: We will have the students run a database in the browser.
  • Q&A