Functional Programming for the Internet of Things: A Comparative Study of Implementation of a LoRa-MQTT Gateway Written in Elixir and C++ - Branch, Philip; Weinstock, Phillip (Electronics (Basel), 2024)
Networks for the Internet of Things typically use a gateway to provide connectivity between a low bit rate, low capability sensor network and the broader Internet. The gateway can be subject to very high traffic loads, many concurrent processes and needs to be highly reliable. Functional programming languages such as Erlang and Elixir have proven to be an effective programming paradigm for such scenarios, notably in large-scale telecommunications switches. In this paper, we report on our experience of developing a gateway between a LoRa network and an MQTT broker using the functional programming language Elixir and the more conventional language C++. To obtain an understanding of this approach to development, we first developed an initial prototype on a single-board computer using Elixir. We then developed the same system in C++ and ran experiments to compare the two systems’ performance. In order to understand the performance of such systems on low-end IoT devices, we then developed the same system on a low-cost ESP32 micro-controller in both C++ and Elixir. We were able to run the Elixir-based system on an ESP32 micro-controller but found that its performance was significantly poorer than the same system written in C++. We conclude that functional programming has great potential for the development of IoT systems, but work needs to be carried out to improve the supporting libraries and underlying virtual machines. We also note that learning to program in a functional programming language has quite a steep learning curve.