Developing in a traditional embedded systems language such as C is hard, yielding long development times and slow time to market. Newer languages such as Java, Python, or PHP are easier, but do not provide a comprehensive end-to-end solution with a shallow learning curve and fast development cycle times. Instead, they require or encourage additional components such as a dedicated web server or database engine along with their additional administrative and maintenance requirements, which often represent the antithesis of embedded software.
We will show that Node.js provides a full-featured environment with a wealth of packages, a low learning curve, and the ability to rapidly develop compact, powerful applications.
Software development can be hard. Development in traditional languages such as C requires a lot of housekeeping tasks. Programmers new to these languages have a steep learning curve, as often these languages are not taught or highlighted as much in college curriculum in favor of newer languages such as Java that perform these tasks for you. Topics such as pointers and concerns such as manual memory management can take a substantial amount of development and debugging time for products of any complexity, taking away valuable cycles that could be spent on the functionality that sets the product apart from its competition. C does not have a package management system or standard repository to make it easier to get started, which means you will probably wind up writing a lot of support code on your own.
Newer languages such as Java are heavier weight and can require quite a bit of effort to adapt them to an embedded system – they are not “out of the box” ready, as evident by the work Google put into developing their own code to get a working Java system in Android. While Android may be suited for some embedded applications, the decision to use it is often driven more by developer skillset or the desire to use specific features that are already available. When these factors don’t align or portability, lightweightness, and a shallow learning curve for developers with other skillsets are of prime concern, Java and Android often just don’t make sense.
Issues like these can frustrate even the most seasoned developer.
Newer languages solve these problems in various ways, but finding a language that does so in a way that is best suited for embedded can be a challenge. For example, Java eliminates the need to deal with pointers and handles memory management for you. However, it also requires a large runtime consisting of code and APIs that the programmer must be familiar with before they can create their first application. Despite Java’s “write once, read anywhere” mantra, Java is really. The Java environment was originally conceived of as being a cross-platform, cross-device environment where one would write code once and run it everywhere. While this has certainly been true to a large extent on PCs, it has not been the case in the embedded market where early phones such as Nokia used special and often proprietary stripped down editions of Java that relied on device-specific frameworks. Android by Google defines Java to be the main language to program apps, but it took many man years of effort to create an environment suitable for compact devices, and Java apps written for Android are not portable outside the Android environment due to the use of these Google-specific frameworks.
How much work is it to create the prototypical, “Hello, world!” application in Java? That depends a lot on the widget framework you are creating it for: AWT, Swing, or perhaps even something else. And is it running in the browser, or as a Java applet? Or maybe you are developing for Android, in which case you must throw all that out the window and use Android’s own graphical user interface (GUI) frameworks, as well as learn whatever development environment is currently supported. Apologies if you were using Eclipse!
The Node.js way
Node.js is also lightweight. Install and use only the packages you need. There are no frameworks to learn to interoperate with before you can get started, just the API of whatever packages you require. Thanks to Google and the World Wide Web, there are dozens of tutorials on the more popular packages that you can use to bypass lengthy API references – get up and running right out of the box. The traditional “Hello, world!” app is literally as simple as:
Node.js is portable too, so you can install Node.js on your favorite desktop system, write and test the platform-independent parts of your code there, and then deploy on an embedded Linux board with a minimum of additional work.
Comparing Node.js with alternatives
A separate resource is provided for, which provides a guide for installing Node.js and writing a simple web server application.
Node.js speeds your time to market by providing a fast, agile environment in which you can focus directly on the problem to be solved and the application to be developed. Without extraneous tasks to worry about that are not related to the problem at hand, you can quickly find and utilize any of the thousands of available packages to avoid re-implementing the wheel. You can be up and running and on your way to success in minutes on Technologic Systems boards.
In future installments we will demonstrate, complete with sample code, how quickly and easily Node.js can be used to develop useful software on Technologic Systems boards. We will:
- Demonstrate how to expand our simple web server running directly on the board to provide access to various hardware features by interfacing with .
- Develop and implement a protocol suitable for Internet of Things (IoT) data logging using a Node.js server running on the board.
- Develop a simple data logger that logs sensor data from an accelerometer on a Technologic Systems board.
- Develop an environment in which logged sensor data can be analyzed and algorithms written and tested for processing that data in real time.
- Demonstrate the ease of using this sensor analysis tool to develop code to detect and respond to a .
- And more… Stay tuned to see even more practical uses of Node.js in developing uniform storage alternatives for embedded, user interfaces, and application development for touchscreens, and much more. If you’ve got ideas that you’d like to see us tackle, our engineering team would love to hear from you!