WebAssembly in Action

Book description

WebAssembly in Action teaches you how to write and run high-performance browser-based applications using C++ and other languages supported by WebAssembly. In it, you’ll learn to create native WebAssembly modules, interact with JavaScript components, and maximize performance with web workers and pthreads. And you’ll love how the clearly organized sections make it a breeze to find the important details about every function, feature, and technique.

Table of contents

  1. Copyright
  2. Brief Table of Contents
  3. Table of Contents
  4. Preface
  5. Acknowledgments
  6. About this Book
  7. About the Author
  8. About the Cover Illustration
  9. Part 1. First steps
    1. Chapter 1. Meet WebAssembly
      1. 1.1. What is WebAssembly?
      2. 1.2. What problems does it solve?
      3. 1.3. How does it work?
      4. 1.4. Structure of a WebAssembly module
      5. 1.5. WebAssembly text format
      6. 1.6. How is WebAssembly secure?
      7. 1.7. What languages can I use to create a WebAssembly module?
      8. 1.8. Where can I use my module?
      9. Summary
    2. Chapter 2. A look inside WebAssembly modules
      1. 2.1. Known sections
      2. 2.2. Custom sections
      3. Summary
    3. Chapter 3. Creating your first WebAssembly module
      1. 3.1. The Emscripten toolkit
      2. 3.2. WebAssembly modules
      3. 3.3. Emscripten output options
      4. 3.4. Compiling C or C++ with Emscripten and using the HTML template
      5. 3.5. Having Emscripten generate the JavaScript plumbing code
      6. 3.6. Having Emscripten generate only the WebAssembly file
      7. 3.7. Feature detection: How to test if WebAssembly is available
      8. Real-world use cases
      9. Exercises
      10. Summary
  10. Part 2. Working with modules
    1. Chapter 4. Reusing your existing C++ codebase
      1. 4.1. Using C or C++ to create a module with Emscripten plumbing
      2. 4.2. Using C or C++ to create a module without Emscripten
      3. Real-world use cases
      4. Exercises
      5. Summary
    2. Chapter 5. Creating a WebAssembly module that calls into JavaScript
      1. 5.1. Using C or C++ to create a module with Emscripten plumbing
      2. 5.2. Using C or C++ to create a module without Emscripten plumbing
      3. Real-world use cases
      4. Exercises
      5. Summary
    3. Chapter 6. Creating a WebAssembly module that talks to JavaScript using function pointers
      1. 6.1. Using C or C++ to create a module with Emscripten plumbing
      2. 6.2. Using C or C++ to create a module without Emscripten plumbing
      3. Real-world use cases
      4. Exercises
      5. Summary
  11. Part 3. Advanced topics
    1. Chapter 7. Dynamic linking: The basics
      1. 7.1. Dynamic linking: Pros and cons
      2. 7.2. Dynamic linking options
      3. 7.3. Dynamic linking review
      4. Real-world use cases
      5. Exercises
      6. Summary
    2. Chapter 8. Dynamic linking: The implementation
      1. 8.1. Creating the WebAssembly modules
      2. 8.2. Adjusting the web page
      3. Real-world use cases
      4. Exercises
      5. Summary
    3. Chapter 9. Threading: Web workers and pthreads
      1. 9.1. Benefits of web workers
      2. 9.2. Considerations for using web workers
      3. 9.3. Prefetching a WebAssembly module using a web worker
      4. 9.4. Using pthreads
      5. Real-world use cases
      6. Exercises
      7. Summary
    4. Chapter 10. WebAssembly modules in Node.js
      1. 10.1. Revisiting what you know
      2. 10.2. Server-side validation
      3. 10.3. Working with Emscripten-built modules
      4. 10.4. Using the WebAssembly JavaScript API
      5. Real-world use cases
      6. Exercises
      7. Summary
  12. Part 4. Debugging and testing
    1. Chapter 11. WebAssembly text format
      1. 11.1. Creating the game’s core logic using WebAssembly text format
      2. 11.2. Generating a WebAssembly module from the text format
      3. 11.3. The Emscripten-generated module
      4. 11.4. Creating the HTML and JavaScript files
      5. 11.5. Viewing the results
      6. Real-world use cases
      7. Exercises
      8. Summary
    2. Chapter 12. Debugging
      1. 12.1. Extending the game
      2. 12.2. Adjusting the HTML
      3. 12.3. Displaying the number of tries
      4. 12.4. Incrementing the number of tries
      5. 12.5. Updating the summary screen
      6. Exercises
      7. Summary
    3. Chapter 13. Testing—and then what?
      1. 13.1. Installing the JavaScript testing framework
      2. 13.2. Creating and running tests
      3. 13.3. Where do you go from here?
      4. Exercises
      5. Summary
  13. Appendix A. Installation and tool setup
    1. A.1. Python
    2. A.2. Emscripten
    3. A.3. Node.js
    4. A.4. WebAssembly Binary Toolkit
    5. A.5. Bootstrap
  14. Appendix B. ccall, cwrap, and direct function calls
    1. B.1. ccall
    2. B.2. cwrap
    3. B.3. Direct function calls
    4. B.4. Passing an array to a module
  15. Appendix C. Emscripten macros
    1. C.1. emscripten_run_script macros
    2. C.2. EM_JS macros
    3. C.3. EM_ASM macros
  16. Appendix D. Exercise solutions
    1. D.1. Chapter 3
    2. D.2. Chapter 4
    3. D.3. Chapter 5
    4. D.4. Chapter 6
    5. D.5. Chapter 7
    6. D.6. Chapter 8
    7. D.7. Chapter 9
    8. D.8. Chapter 10
    9. D.9. Chapter 11
    10. D.10. Chapter 12
    11. D.11. Chapter 13
  17. Appendix E. Text format extras
    1. E.1. Control flow statements
    2. E.2. Function pointers
  18. WebAssembly in Action
  19. Index
  20. List of Figures
  21. List of Tables
  22. List of Listings

Product information

  • Title: WebAssembly in Action
  • Author(s): Gerard Gallant
  • Release date: November 2019
  • Publisher(s): Manning Publications
  • ISBN: 9781617295744