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 represents one of the most fundamentally interesting and transformative technologies to have emerged in the last several years and its impact is likely to be felt for years. At its core, it is simply a set of standards supported by the major browsers, software vendors and programming language enthusiasts. It is an attempt to allow the Web to be a target platform for existing software development beyond the world of hundreds of interdependent JavaScript libraries. It is an attempt to manifest the long-standing goals of being able to have zero installation apps that are also performant, secure and as useful as desktop and native applications.

What emerges is a world where you will be able to choose your programming language and have the subsequent code be able to run with near native speed on just about any platform out there. It is the fulfillment of a promise we were given many years ago but with the experiences we have had in the meantime to make it more likely to succeed.

Any organization out there will benefit from the ability to write less code that works in more places for longer. Existing applications can be brought to the Web often merely by recompiling them. But also, existing Web application development can be extended into new markets that were previously unhandled due to some of the limitations of JavaScript as a programming language.

We will focus on the use of WebAssembly in the browser, but we will also give the attendees a peak into what is happening with respect to WebAssembly out of the browser as well.

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

By the end of this live, hands-on, 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 is 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 the 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 are not 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

  • Prerequisites What prior knowledge or experience is necessary?
  • Familiarity with JavaScript and conventional Web development languages, standards and tools
  • Familiarity with the basics of a language like C or Rust will be helpful but not a strict requirement

Recommended preparation:

  • There is no special setup, but in order to take part in the course exercises (optional) you will need a modern browser that supports WebAssembly https://caniuse.com/ - search=WebAssembly and have the ability to run a small web server via Python, nginx, etc.

Recommended follow-up:

About your instructor

  • Brian Sletten is a liberal arts-educated software engineer with a focus on using and evangelizing forward-leaning technologies. He has a background as a system architect, a developer, a security consultant, a mentor, a team lead, an author, and a trainer and operates in all of those roles as needed. His experience has spanned the online game, defense, finance, academic, hospitality, retail, and commercial domains.

    He has worked with a wide variety of technologies such as network matrix switch controls, 3D simulation/visualization, Grid Computing, P2P, and Semantic Web-based systems. He has a B.S. in Computer Science from the College of William and Mary. He is President of Bosatsu Consulting, Inc. and lives in Los Angeles, CA. He focuses on web architecture, resource-oriented computing, social networking, the Semantic Web, scalable systems, security consulting, and other technologies of the late 20th and early 21st Centuries.

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