Programming for IoT
Programming for IoT is usually a polyglot (multiple languages) effort since the Internet-of-Things (IoT) is a system of inter-related computing devices that are provided with unique identifiers and the ability to transfer data over a network. The choice of programming-language depends on the capability and purpose of the device. IoT encompasses a variety of devices including edge devices, gateways, and cloud servers.
What are the popular languages for IOT?
Which languages are suitable for edge devices, gateways and cloud computing?
- Edge Devices - These are constrained-resource embedded systems. For very small devices (higher constraints), Assembly and C are the languages of choice. A better processor and more computing power on the device enables one to use C, Python, Node.js, Java. The focus is to minimize instruction count, and maximize execution speed and resource management.
- Gateways - Gateways manage communication and do analysis of data from many devices through several different buses. More languages can be run on these devices because of their increased computing power, including C, C++, Java, Python, and Node.js.
- Cloud - With the nearly unlimited computing capability that's available, frameworks like Apache Hadoop and HiveQL can compute and process large IOT datasets. Statistical computing and visualization can be done using languages like R or Julia.
What are the approaches used in IoT application development?
- Node-Centric Programming - Every aspect is programmed by the developer like communication between nodes, collection and analysis of sensor data, issuing commands to actuator nodes. Interaction between devices is explicitly encoded.
- Database approach - Every node is considered part of a database and the developer can issue queries to sensor nodes. Focus is on collection, aggregation and sending of data to the base station.
- Macro programming - Abstractions are provided to specify high-level communication.
- Model-driven development - Application development complexity is reduced by increasing the level of abstraction and by describing the system using different system views. The vertical separation of concerns (SOC) reduces app development complexity by separating platform-independent model (PIM) and platform-specific model (PSM). The horizontal separation of concerns separates different aspects of a system.
What are the features to consider when evaluating IoT programming frameworks?
The following features are relevant:
- Scalability - Programming frameworks that support diverse programming patterns that are able to perform load-balancing dynamically.
- Concurrency - Real-time communication between millions of devices and applications mean millions of concurrent connections. Thread locking is not efficient in such situations.
- Coordination - Programming language support for explicitly (control driven) or implicitly (data driven) orchestrating the role of computing elements.
- Heterogeneity - Programming framework gives guidance on how computations are mapped to the computing elements.
- Fault tolerance - Applications should be able to gracefully go from online to offline state as networks partition and heal their connections.
- Light footprint - In terms of runtime overhead and in terms of programming effort the framework should be light.
- Support for latency and sensitivity - In geographically distributed applications, pushing all computations to the cloud is not ideal. The programming framework has to handle these requirements dynamically.
What programming paradigms are suitable for IoT?
A programming paradigm is a way to classify the programming language based on its execution model. It should be kept in mind that a particular language can below to more than one paradigm. The following programming paradigms are suited for IoT:
- Functional - Functional programming helps solve the challenges of scalability and concurrency. Its preference for immutability, function composition, avoiding side-effects, less code, etc. avoid several IoT pitfalls.
- Dataflow - Dataflow programming emphasizes the movement of data. It models programs as a series of connections. Explicitly defined inputs and outputs connect operations. An operation runs as soon as all of its inputs become valid. Dataflow languages are inherently parallel and can work well in large decentralized systems.
- Event-Driven - Event-driven programming (events triggered by sensors, connectivity, or time) is well suited to IoT where devices spend most of their time in power-saving modes, wake up due to some event, process data, send it out, and go back to sleep.
Are there any specific requirements that the languages should satisfy to be used for IoT?
Developers can consider the following:
- Languages that support Functional, Dataflow, or Event-driven programming.
- Interpreted languages (Python) are slower than compiled ones (C/C++/Rust/Go).
- Type safety, memory management, no null pointer exceptions. Languages such as C and C++ use explicit pointers to reference memory. Incorrect pointer calculations can lead to buffer overruns and memory access violations.
- Availability of GPIO libraries.
- Libraries that support IoT protocols like Advanced Message Queuing Protocol (AMQP), Constrained Application Protocol (CoAP), Extensible Messaging and Presence Protocol (XMPP), OASIS MQTT, or Very Simple Control Protocol (VSCP).
Within languages, are there any specific variants, modules or libraries that enables IOT?
- In Python, "mraa" and "paho-mqtt" are useful for IoT. . MicroPython can be used on constrained devices.
- Java first appeared in the 1990s for a resource-tight embedded environment, requiring minimum computing power. Many of the Oracle Java ME Embedded APIs are targeted at the needs of embedded systems.
- Eclipse Mita is a new programming language designed to feel like modern programming languages in the vein of TypeScript, Kotlin, and Go. It helps scale from prototypes to commercial IoT deployments by transpiling to C code.
Could you share some best practices for IoT developers?
Choose a programming framework that promotes design reuse, implementation reuse and validation reuse in order to enhance software extensibility, flexibility and portability. To make distributed IoT microservices resilient, developers should be able to specify precise sequence of execution steps to be taken by compiled code, regardless of the order in which asynchronous event messages are processed.
Could you list IDEs, debuggers and tools for IoT programming?
- Eclipse IOT project (Kura) - This is a Java-based development framework for IoT applications.
- Arduino IDE - This IDE includes support for the C and C++ programming languages for programmable microcontrollers. It's a complete package with many examples and pre-loaded libraries.
- Raspbian - This IDE comes with many packages and examples created specifically for the Raspberry Pi boards.
- OpenSCADA - This project is a part of Eclipse IOT Industry Working Group along with Eclipse SCADA (Supervisory Control and Data Acquisition). It provides several libraries, interface apps, and configuration tools.
- PlatformIO - This is a cross-platform IDE that supports over 400 embedded boards, and several development platforms and frameworks.
- Choudhury, Ambika. 2019. "10 Best Programming Languages To Learn In 2020 For IoT Development." Analytics India Magazine, November 17. Accessed 2020-07-23.
- Cleary, Corey. 2016. "Functional Programming as the Paradigm for IOT." June 12. Accessed 2018-06-11.
- Delgado, Rick. 2017. "Why Java is the Language of Choice for the Internet of Things (IoT)." KD Nuggets. May 1. Accessed 2018-06-10.
- GOTO. 2011. "Dart, a new programming language for structured web programming." GOTO Århus conference. October 10. Accessed 2018-06-11.
- GOTO. 2015. "GOTO 2015 - Internet of Programmable Things - Kasper Lund." Goto Conferences. October 21. Accessed 2018-06-11.
- Gaurav, Kumar. 2017. "Programming Internet of Things using Contiki and Cooja." Open Source For You. June 17. Accessed 2018-06-15
- George, Damien. 2013. "Micro Python: Python for microcontrollers." Kickstarter. November 13. Accessed 2018-06-11.
- Harris, Ian. 2017. "Lecture 2.2: Compilation and Interpretation." Introduction to the Internet of Things and Embedded Systems, Univ. of California Irvine, on Coursera. Accessed 2018-06-12.
- Hoddie, Peter. 2018. "Moddable." GitHub. March 23. Accessed 2018-06-12.
- Intel. 2017. "Selecting Programming Languages for the IoT." Intel. March 20. Accessed 2018-06-10.
- Intersog. 2017. "12 Popular Programming Languages For IoT Development In 2017." Intersog, on Medium, February 22. Accessed 2020-07-23.
- Kobielus, James. 2017. "How to write event-driven IoT microservices that don’t break." Infoworld. June 30. Accessed 2018-06-10.
- Krill, Paul. 2017. "Microsoft's P language is aimed at where cloud, AI, and IoT meet." Infoworld. May 23. Accessed 2018-06-10.
- Krishnamurthy. 2016. "Chapter 5 Programming Frameworks for Internet of Things." Internet of Things: Principles and Paradigms by Elsevier Page 91-98. Accessed 2018-06-11.
- Lardinois, Frederic. 2017. "Google makes Kotlin a first-class language for writing Android apps." TechCrunch. May 18. Accessed 2018-06-11.
- Linux Foundation. 2018. "The Linux Foundation Announces an Open Source Reference Hypervisor Project Designed for IoT Device Development." The Linux Foundation. March 13. Accessed 2018-06-10.
- NI. 2007. "Why Dataflow Programming Languages are Ideal for Programming Parallel Hardware." Multicore Programming Fundamentals Whitepaper Series. National Instruments Corporation. November 1. Accessed 2018-06-11.
- O'Leary, Nick. 2013. "Version 0.2.0 released." Node Red. October 16. Accessed 2018-06-10.
- Patel, Pankesh. 2015. "Towards Application Development for Internet of Things." ABB Corporate Research, India. Slide 10 - 15. August 10. Accessed 2018-06-15.
- Press, Gil. 2014. "A Very Short History Of The Internet Of Things." Forbes. June 18. Accessed 2018-06-10.
- Ritter, Simon. 2013. "Top Ten reasons for using Java in Embeded Apps." Java Magazine. January 1. Accessed 2018-06-10.
- Saket. 2018. "5 Best Development Software(IDE) for Internet of Things (IOT) in 2018." January 14. Accessed 2018-06-13.
- Sharma, Archana. 2016. "The Most Popular IoT Programming Languages Today." January 22. Accessed 2018-06-10.
- Simone, Sergio De. 2016. "Microsoft Open-Sources P Language for Safe Async Event-Driven Programming." InfoQ. October 1. Accessed 2018-06-10.
- Skerrett, Ian. 2017. "IoT Developer Survey Results." Eclipse Foundation, on SlideShare, April 18. Accessed 2020-08-12.
- Slant. 2018. "What are the best programming languages for IoT (Internet of Things)?" Accessed 2018-06-10.
- Sola, Rajesh. 2017. "Open Source Software You can use for IoT Development." Open Source For You. September 20. Accessed 2018-06-15.
- Vrat, Satya. 2017. "IoT with Python : Essential Packages." February 12. Accessed 2018-06-10.
- Weichel, Christian. 2018. "Introducing Eclipse Mita - A Language for Embedded IoT." Eclipse Newsletter. March 1. Accessed 2018-06-10.
- Buyya, Rajkumar. 2016. Internet of Things: Principles and Paradigms. Morgan Kaufmann (Elsevier).
- Soldatos, John. 2016. Building Blocks for IoT Analytics. River Publishers.
- Beal, Jacob. 2015. Aggregate Programming for the Internet of Things. Computer.org
- Readability score of this article is below 60 (45.1). Use shorter sentences. Use simpler words.