## 6 Key Challenges and Future Directions
### Limitations of Current WebAssembly Implementations
While Wasm has been designed to work alongside JavaScript, its ability to directly access web APIs has been a significant concern, especially for IoT applications. * **Restricted Direct Access to Web APIs*
* Wasm cannot directly access the web APIs that JavaScript can. Instead, in order to use these APIs Wasm needs to call out to JavaScript, which can be a cumbersome and inefficient process. This is due to the fact that Wasm runs in a sandboxed environment to ensure security, which inherently limits its ability to directly interact with the host environment. For IoT applications, this limitation can be particularly restrictive. Many IoT applications require real-time interaction with various system APIs for tasks such as device control, data collection, and communication with other devices or services. The current inability of Wasm to directly access these APIs adds an extra layer of complexity to building these applications. * **WASI and Interface Types*
* To address these limitations, two proposals are being developed in the Wasm community: the WASI and Interface Types. The WASI aims to provide a system interface for Wasm that abstracts away the details of the host system. This allows Wasm applications to interact with the system without compromising security. The WASI, however, is mainly designed for server-side or standalone applications, and does not provide access to most web-specific APIs. Interface Types, on the other hand, aim to define a way for Wasm modules to communicate with each other and with the host environment using high-level data types. This would allow Wasm to interact with web APIs in a more direct and efficient way
without needing to go through JavaScript. These two proposals, if accepted and implemented, would go a long way in addressing the current limitations of Wasm in terms of API access. * **Implications for IoT** The current state of Wasm's limited access to web APIs presents a challenge for IoT development. However, the advancements in the form of WASI and Interface Types bring a promising future. Access to web APIs in a more direct and efficient manner would enable developers to build more sophisticated, high-performing, and secure IoT applications using Wasm. * **Debugging and Testing Challenges*
* In light of its binary nature, debugging and testing Wasm applications can be more challenging compared to JavaScript. While a number of tools are available, they often provide less visibility and convenience than developers are accustomed to. As Wasm finds its footing in the landscape of IoT development, the challenges associated with debugging and testing of Wasm modules are becoming increasingly evident. These challenges stem from a few aspects of Wasm's design and the current state of tooling. * **Lack of Mature Debugging Tools*
* While Wasm's design is optimized for efficient execution, its binary format makes debugging a complex task. Compared to traditional programming languages, debugging tools for Wasm are in their nascent stages. While there are debugging protocols available, such as Dwarf for Wasm, they may not be as mature or fully featured as those available for other languages. * **Source Map Limitations*
* Source maps are used to map the compiled Wasm code back to the original source code, making debugging easier. However, the effectiveness of source maps can be limited by the fact that they only provide information about where the code originated, not how the compiled code is behaving. This can make it harder to debug complex issues that involve the runtime environment or interactions between different parts of the code. * **Interoperability Issues*
* Considering the interoperability of Wasm with JavaScript and other web technologies, debugging can be complicated by issues that span multiple languages and technologies. For instance, an issue might involve both JavaScript and Wasm code, requiring developers to use different tools and strategies to debug different parts of the application.