The Internet of Things framework requires a good and dependable programming language. If you look at many of the tools today, you really only have 2 or 3 popular options in this space: do barebones C/C++ or have a NodeJS integration, which lacks modular support cause they are generally designed to work with only one particular device. Let me introduce you to using Go as part of your IoT solution. As a relatively new language that was inspired by C roots without all of its dangers, built in concurrency sweetens the deal further by allowing you to define goroutines that plug straight into your embedded devices. The concurrency model here is much easier and safer to implement. Remember the last time you had to deal with pthreads along with the mutexes, condition variables and semaphores?In Go, all you really need is basic understanding of goroutines and channels. [caption id="attachment_1393" align="aligncenter" width="300"]
Slide from Sameer Ajmani’s “Program your next server in Go” talk[/caption]
Go has great built in features and officially supported packages that can be imported easily via the Go package manager. This will help developers get ramped up faster and ship faster and more elegant code with much less development time. Ken Thompson and Rob Pike, along with a bunch of really talented Google engineers are working hard on the Go project. To the best of my understanding, I wouldn’t be surprised if they want to adopt Go for implementing higher stake projects within the company. By having a giant tech company vouch for it further strengthens the community’s trust in building better quality software with this programming language.If you do have certain preferences for external packages, there are currently x many packages that can be integrated easily into your application by calling go get: ….. Many of which are very well supported with an active growing community.
Rust and Go being Contenders?
I don’t think so.Both languages were made for very different use cases. Both are great systems programming languages without the headaches of memory allocation and dangling pointers. However, it’s probably Go’s intention to not be part of the embedded toolchain. It was not designed to replace embedded C, but more towards handling the communication layer to and from these devices. The garbage collection in Go makes it less ideal for it to implemented at the embedded device level, but great for people seeking greater control of resources without paying too much overhead for such features.Rust, on the other hand, aims to go deeper than that. It might/might not live in the device driver level, but only time will tell if it does make its way down to that level in your stack. The syntax is a lot more strict, but that also gives it a steeper learning curve than Go. Nevertheless, features such as having variables immutable by default forces embedded developers write safer code.
This was a language that I picked up during Hologram’s monthly Hackday, which we all work on interesting projects that could benefit us and the community as a whole, then share these experiences with you. My project was to learn Go and build a simple Go library for our Cloud APIs. We’ll be adding many more cool features to it in the coming months, so we hope that you’ll be as excited as we are about it!I hope that this will streamline your development time in integrating your cellular connected devices with your Go stack much more easily without having to know the underlying implementation of the REST APIs. I am a recent graduate, and it was a great experience to work on such a huge project after being here for only a little over 2 months. We have benefited a lot from using an internal stack is primarily run using open source software. Today, we are happy to announce that we’re open sourcing our Go library. We look forward to working closely with the open source community and expand on upcoming features that you would like to see.