Instantiations has been working with IoT (Internet Of Things) technology alongside the VAST Platform for a few years at this point. As a result of this research and development, we're improving VAST and finding new technologies to complement it (one of them you'll read about in this post). Outside of R&D, we're sponsors of the large and rapidly growing RIoT community while we continue to present on various topics at IoT events and conferences.
When we started our IoT research, we knew VAST (VA Smalltalk) had unique features that were not only appealing for "traditional" application development, but also for certain types of IoT projects. Some of these features include advanced debugging, an efficient ARM just-in-time (JIT) compiler, and GPIO access. Some of our customers are already using VAST with IoT, and these features have been really useful for them.
While VAST is a powerful Smalltalk implementation, it does have its limits though. As our long-time users know, it requires an operating system (OS), like Windows or Linux, to function. Therefore, the smallest and simplest hardware that can be used with VAST would be categorized as a "single board computer" (SBC), for example, a Raspberry Pi.
Running the combo of VAST/Linux/SBC may be suitable for some IoT projects that require powerful hardware for data processing, complex domain logic, etc. However, this stack may not be preferred for other projects when only simple logic and exceptionally long battery life are needed. In cases like these, using an operating system like Linux is not practical, and a microcontroller may be the best (or only) option. Luckily, microcontrollers like the ESP32 can be found for as little as $2 USD while also providing decent hardware performance.
Here's the problem though: When working with microcontrollers, the development experience can be difficult and/or time-consuming when using languages like assembly, C/C++, or MicroPython. While they certainly have their merits, these languages (and their resulting dev experiences) may not be ideal for many types of IoT projects. With Instantiations' history of creating user-focused development tooling, we saw this imperfect situation and asked ourselves the question:
How can we have a rich development experience for microcontrollers that feels similar to using VAST?
Similarly, Toit wants to change what's possible with microcontrollers. They believe in the need for more productive, higher-level programming experiences for IoT systems, and as a result, Toit developed a new programming language and runtime.
This language, also named "Toit", is an object-oriented programming language that's specifically designed for IoT and that can run at the microcontroller level. Additionally, they offer an robust cloud-based device management platform.
Instantiations shares this vision. We believe the IoT development experience can (and should) be better, and that:
Toit is a huge step in the right direction. It's the richer development experience on microcontrollers that we've been waiting for.
Providing an in-depth review of any programming language would take a lengthy paper or even a complete book, so in this post, we'll just focus on some concepts that we really like about the Toit language.
To our knowledge, Toit is the first and only high-level object-oriented (OO) language designed from scratch for IoT. While MicroPython is a lean version of Python that can be used on microcontrollers, Python was not designed specifically for IoT. As another example, C++ was not designed for IoT either, and some consider it to not even be object-oriented!
Toit is memory-managed. In other words, it has a garbage collector (GC). Yes, a GC at the microcontroller level! Like most OO languages, it runs on top of a virtual machine (VM), so it's decoupled from the hardware it runs on (at the time of this post, the best supported hardware for Toit is the ESP32 microcontroller). This makes programming in Toit safer and prevents firmware errors that may cause the device to become non-functional.
Toit code definitely seems simple at first glance, and the syntax is clear once you read the documentation. It features classes, interfaces, and even blocks/closure (Smalltalkers will love this!).
It also includes multiple built-in libraries for accessing the GPIOs, serial, crypto, HTTP, etc. Even multi-tasking is possible, which is incredible considering it's a high-level language running on a $2 microcontroller!
One could argue that a high-level OO language like this may run slowly. However, as a reference, it's around 20 times faster than MicroPython.
Very importantly, Toit offers a Visual Studio Code plugin that has code complete and syntax highlighting as well as the ability to manage devices, serial connections, projects (a feature of the Toit cloud platform), and so forth.
For answers to more common questions about Toit, check out their developer FAQ.
As we said earlier, Toit is not just a programming language. It's part of a bigger ecosystem that includes a whole platform and cloud services with the ability to manage your code and devices. In some regards, this is similar to Microsoft Azure IoT, Balena, or Particle.
To start with, it has 2 concepts regarding the scope of your code: programs and apps. A program is like a short snippet of code that is executed just once and discarded immediately after. An app is usually a larger piece of software that is deployed on the device and persists on it. You can even define multiple deployment details for apps like how frequently each app should run.
Both programs and apps run on top of a virtual machine (which functions like firmware). That's why the very first time you want to run something with Toit you must first provision the hardware. Once the provision is done, the device will automatically connect to the Toit cloud when it boots.
Something great about the Toit platform is the ability to update an app over the air. As previously mentioned, the provisioned devices will automatically connect to the cloud (either via Wi-Fi or cellular) and that means that you can update the running apps of a desired set of devices at any point. This is done from the Toit command line tool (available for Windows, macOS, and Linux).
Toit devices can also be configured to support what is called deep sleep to save power consumption. However, when the device wakes up, all the Toit-collected data is pushed back to the cloud. The deep sleep mode combined with the ability of apps to decide how frequently they run, can allow an ESP32 to run on a couple AA batteries for years.
The Toit command line tool is not just for updating or deploying apps over the air. It allows you to provision the hardware, manage your devices, retrieve logs, run programs, and much more. With VAST's OsProcess framework, accessing this functionality through Smalltalk is easy and straightforward.
If you don't like the command line tool, then you also have a really nice user-friendly web console dashboard with a lot of graphics, information, and ability to manage and configure your fleet of devices.
It's important to note that both the CLI and this web console use Toit's own gRPC-based API, so the very same API could be used to implement your own "client" as well as serving other needs.
The more we work with Toit, the more we like it. Toit-enabled devices can work well with VAST to provide an energy-efficient way to collect and leverage real-world data, while keeping a similar object-oriented approach that we're all familiar with.
Toit has the potential to be as revolutionary to microcontroller programming as Smalltalk was to "traditional" application development.
Stay tuned for more information about the upcoming IoT Developer Day Event in March 2022 where Instantiations and Toit will be presenting this technology to the RIoT community!
Feel free to reach out to us if you'd like to get started with Toit or the VAST Platform for your next IoT project, or alternatively let's talk about how IoT technology could add value to your current VAST-based system.