Building the C portion
The C portion of the application will aggregate transaction and category amounts. The calculations we perform in C could be done just as easily in JavaScript, but WebAssembly is ideal for computation. We'll dive deeper into more complex usage of C/C++ in Chapter 8, Porting a Game with Emscripten, but for now we're trying to limit our scope to what can be done within the confines of the Core Specification. In this section, we'll write some C code to demonstrate how to integrate WebAssembly with a web application without the use of Emscripten.
Overview
We will write some C functions that calculate the grand totals as well as the ending balances for raw and cooked transactions. In addition to calculating the grand totals, we need to calculate the totals for each category for display in the pie charts. All of these calculations will be performed in a single C file and compiled down to a single Wasm file that will be instantiated when the application loads. C can be a little...