Java ME, or micro edition, has been available on small phone handsets and other embedded devices since the specification was approved in 2000. It saved space with a very limited collection of class libraries and other tools. Today, most of the focus is on Java SE Embedded, which is much closer in capability to the Standard Edition. Developers can use the latest features of the Java 8 platform and then move their code to a smaller, embedded device.
Most of the computing resource savings with Java SE Embedded comes from stripping out the classes needed to display information when the machines can be configured to run headlessly, without a monitor or keyboard. All of the communication goes through the network.
There are multiple open-source projects, such as Pi4J and BlueJ, that show how the embedded version of Java runs well, even on chips that seem limited.
The syntax is cluttered with punctuation, and there are a million different little mistakes you can make, but the language is still the first choice for many programmers who write for the lowest layer of software, the one closest to the hardware. The language hides nothing from you, and that means you can fiddle with every part of the code to squeeze out the best performance from an underpowered device. Every bit can be flipped. Every value on the stack is available. Just don’t make a mistake, because there are few safety nets.
Victor Berrios is the chief technical officer at the ZigBee Alliance, a group that supports the ZigBee standard, which links small devices. “From what we see in the market, C remains the language of choice for constrained devices,” he said. “These typically do not include a ‘commercial’-level OS but rather a basic task-scheduler type of resource management also coded in C.”
More advanced or bigger devices with full operating systems still use plenty of C code, he added, but he said that other languages such as Java are starting to be used just as frequently. When a smartphone comes from Apple, much of the programming is still done in Objective C, but this will probably be gradually replaced by Swift (see below).
It started as a scripting language to glue together real code, but it’s increasingly used as the main language for many developers. When small devices have enough memory and computational power, the developers are free to choose the language that makes their life easier and that is more and more often turning out to be Python.
Kinman Covey, a microcontroller developer, says that Python is both easy to learn and supported by a large, helpful community. The syntax is clean and simple, attracting a greater range of programmers. The language is often the first choice for social scientists and biologists, for instance. When they need a smart device in the lab, they’re happy to use a language they know, Python.
“Python is the language of choice for one of the most popular microcontrollers on the market, the Raspberry Pi,” said Covey. Much of the training literature is written in Python, and many schools use the platform to teach computer programming. If the project is relatively simple and there are no great computational demands, it’s possible to build effective tools from the same boards and libraries that are used in elementary schools.
There are also versions designed to be even smaller. The MicroPython board and software package is a small microcontroller optimized to run Python on a small board that’s only a few square inches.