Internet of things is here, and it’s going to be an era full of inventions and innovation. But one major player in the IoT is the programming languages used, that are going to provide both an interface to communicate with the devices we want to add to the network, and provide a processing mechanism for both the devices and the cloud CPUs to leverage the potential of IoT into the various aspects of life. It’s clear, then, without saying that choosing the right programming language that fits your usage and the system’s need is the right way to embark on the IoT journey.
One of the facts many people don’t know about Arduino is the fact that its USB port is actually a disguised serial port. Serial ports are a serial communication interface used in sending data across devices by sending that data one bit at a time, contrary to the parallel port that sends multiple bits at a time. Now, why is this a revelation, you might wonder, it’s because you can actually write custom code on your machine and interface (i.e communicate) with the Arduino board, sending or receiving data.
To know more about Arduino, one can always check out several online Arduino tutorials to make your learning curve more steep.
Today, we’ll focus on 4 languages that target the Arduino platform for the creation of IoT devices. These languages are C++, C, Python, and Ruby.
C++, along with C, is the most used programming languages in the Arduino world. The thing about C++ is the fact that it’s object-oriented, widely taught in introductory CS courses around the world, and is quite powerful. C++ is one of the very few languages that are able to interface with the hardware world out of the box, that’s why it’s widely used in writing hardware drivers. C++ possesses a wide range of libraries for all the different applications, from audio processing and web development to embedded systems and machine learning. A key feature that C++ provides is the fact that it allows memory management in the application, which is crucial for embedded applications where resources and especially memory is not as abundant as it is on your computer.
C++ and Arduino are quite a perfect match, and there is a ton of ready to use libraries so that you can just get going with your creative applications. Many of these libraries target Arduino’s IoT applications, such as ArduinoJson for decoding and encoding JSON, DueTimer which is a Timer library implemented in Arduino, TaskScheduler for multitasking in Arduino using C++. You can check more Libraries relating to C++, IoT, and Arduino here.
C is quite similar to C++, but perhaps one of the core and most obvious differences is the fact that it’s not object-oriented ( you can still write object-oriented code in C and workaround that fact.) C is also widely supported in the Arduino world, and in fact, Arduino is but a subset of C/C++. While many people find C incomprehensible and evil it’s got quite the reputation in the embedded world, even away from Arduino.
Python is the go-to choice for many people, as it possesses a clear and simple syntax and it’s quite easy to pick up. It might seem like a trivial advantage, but in fact, It’s really important, especially when people from different majors and with different interest decide to join the IoT revolution. Python is the second most used programming language in the world, according to Github in 2017. It’s also extremely powerful in the A.I and data science domains, which is going to play a big role in the IoT world. According to Arduino’s docs, it’s straightforward to communicate with an Arduino board using Python. There’s also a wrapper library called PySerial to use python serial capabilities with different operating systems. There’s also Python Bridge which is an application that allows you to communicate with Arduino.
Just like Python, Ruby is one of the easiest and most loved programming languages in the world. Although it might be lacking the performance aspects that C/C++ have, it’s quite well documented and possesses a great community. There are many gems ( libraries in Ruby) that make interfacing with an Arduino board in Ruby a breeze. There’s the SerialPort gem, The Arduino-firmata gem that implements the firmata protocol within ruby. There’s also the Dino gem that helps you get started easily with Arduino, and is quite similar to the Arduino language.
The best way to join the IoT revolution is to start building your own Arduino projects and check the Arduino Projects Hub for inspiration. There’s no one language that is going to make all others obsolete, and hence, you can simply pick the language that you feel most comfortable using. Real world hardware applications possess a high level of constraints and a limited amount of resources, and it would make things worse if you decided to use a language that you don’t really like.
This is a guest contribution by Saurabh Hooda. Saurabh has worked globally for telecom and finance giants in various capacities. After working for a decade in Infosys and Sapient, he started his first startup, Lenro, to solve a hyperlocal book-sharing problem. He is interested in product, marketing, and analytics. His latest venture Hackr.io recommends the best Angular tutorial and online programming courses for every programming language. All the tutorials are submitted and voted by the programming community.