Cons of C++ for IoT
As mentioned above, perhaps one of the biggest obstacles for developers and companies who wish to adopt C++ is that it’s a very strict, very verbose, very complex language. This makes C++ quite difficult to learn, even for seasoned developers. To practice embedded development in your company, therefore, you’ll need the budget to recruit and retain developers with C++ knowledge and experience. If you don’t have those expert resources, you’re looking at longer development cycles and slower time to market with C++.
Additionally, because the language is so complex, maintaining your codebase can present significant challenges. We mentioned above that a lot of major companies use C++ — and ironically, another reason for this is that some of them can’t use anything else. If they used C++ to develop critical programs in the 80s and 90s, and it’s still working, there’s not much incentive to update it and risk breaking something.
For companies and areas where it’s possible to update C++ to a simpler language, however, the change may make more business sense and enable more agility. This is especially true where web development is concerned because languages like C++ lag behind web-based software technologies. A single line of code in a web ecosystem, for example, may execute more times in one day than its embedded counterpart will be executed over the entire lifetime of its hardware host. When you’re trying to develop and iterate an IoT application quickly, this can be a huge blocker.
Using Elixir and Nerves for IoT Development
So, if C++ isn't a perfect fit for all or part of your project, and you have the flexibility to adapt to another language and/or framework, what are the best alternatives? Here at Very, we use C++ in all the places where it makes sense for the project and the business goals, but we’re also huge fans of Elixir and Nerves — and we often use all of them together.
Elixir is a relatively young language built upon the principles of the much older Erlang, which was developed in 1987 for low-level, remote hardware applications. Much like how C++ takes many of its core paradigms from the original C, Elixir mimics Erlang in that it’s fault-tolerant, highly available, and supports “hot-swapping” — i.e., adding and changing program code while the program is running. These traits — plus the fact that Elixir has data immutability, is process-based, and encourages concise, testable code — make it an ideal language for developing embedded firmware.
Nerves, meanwhile, is an IoT development framework that applies the principles of web development, including tools for secure communication with web servers and tools for continuous delivery, to building embedded software in Elixir. When it comes to actually shipping to production and making sure your IoT devices continue to work after you release them into the wild (think: cellular networking, firmware updates, and security), Nerves is a great option because it’s resilient, reproducible, and reasonable. Nerves also offers some secret advantages — namely, that you can use the framework to sneakily trick your Elixir developers into working on embedded systems.
Choosing What’s Right for You
Whichever languages and frameworks you choose for IoT development, it’s critical that you’re thinking about all of the ways your choices can impact your project and ultimately your business. This pros and cons list is a great place to begin your research.
If you’re looking for a team with deep experience in embedded development to guide your next project, reach out to us today. We’d love to hear more about what you’re working on.