A novel software architecture based on WebAssembly for web-based neuroinformatics
Presenting author:
Software is often limited to a single offline context. Here, we present a state-of-the-art software architecture that will permit the same low-level algorithmic functionality (written in C++) to be used in web applications via WebAssembly—obviating the need for software installation, command-line applications via Node.js, and Python and MATLAB toolkits via a custom interface layer. This architecture has four parts: 1) the computational layers, where the algorithmic functionality is implemented and exposed as functions, 2) the module layer, where this low-level code is tied together with parameter handling and documentation to create modules, 3) the user-interface layer for creating web-based user-interfaces and 4) the end-user application layer. The key advance in software architecture is in layer 1, where complex algorithms are implemented in C++ and made available to JavaScript/Python/MATLAB using custom wrappers. In the wrappers, the data from the scripting languages is serialized into flat arrays, passed to C++, and reconstructed back into data structures for processing. This process is reversed to native data structures in the scripting languages (e.g. numpy matrices). Last, the wrappers created automatically using custom scripts from specific comments in the C++ code. In the case of Python and Matlab, the C++ code is compiled as native shared libraries. For use in JavaScript, the C++ code is compiled to WebAssembly—a new binary instruction format designed as a portable target for compilation of high-level languages. This enables deployment in web applications (using web-browsers) and as command line tools using a JavaScript command line interpreter. The same WebAssembly shared library works on all platforms and browsers.