Frequently Asked Questions

If your question isn't answered here, we still want to help. Please contact us.

What's Moddable's vision for the future of IoT?

Moddable has an ambitious vision for the future of IoT products, one that puts users in control of the devices in their lives and that creates new opportunities to manufacturers, cloud services, and third-party app developers. Here's what we believe:

  • Users should control the IoT products in their world
  • Manufacturers should benefit from creating IoT products that give users more control
  • IoT products should safeguard the user's privacy and security
  • Industry standards make IoT products more interoperable and open
  • Displays make IoT products more functional and easier to use

To help achieve these goals, we created the Moddable SDK, a collection of tools for creating the software that powers IoT products. The foundation of our technology is the JavaScript language.

Read more about Moddable's vision for the future of IoT in Our Story.

Why JavaScript?

We want to augment traditional embedded programming with a more flexible, nimble, and open approach. JavaScript is an excellent tool to build apps for IoT products. Here's just some of the reasons:

  • Huge developer base: JavaScript is the most widely used programming language in the world. There are a huge number of existing JavaScript developers and it is a relatively easy language to learn.

  • Rapid development: JavaScript has proven extraordinarily productive for developers. Writing applications in JavaScript is much faster than writing applications in C or C++, and JavaScript is a much more natural fit for implementing many important features of IoT products like exchanging JSON data with cloud services and building modern user interfaces.

  • Reusability and maintainability: The reusability and modularity of JavaScript code make it a great language for building large but maintainable applications. The TypeScript dialect of JavaScript adds features for maintaining large projects with many developers.

  • Portability: JavaScript is a platform-independent language and designed to be very portable. This gives you the ability to run the same application on different target platforms, rather than starting from scratch for every new device.

  • Security: JavaScript does not have access to operating system functions or hardware capabilities by default. This allows the system designer to decide whether or not scripts can access the file system, sockets, etc. In addition, common security bugs in native code like uninitialized memory and buffer overruns are nonexistent in JavaScript.

What is XS?

XS is Moddable's JavaScript engine. Unlike the engines used in browsers, XS is designed to run on microcontrollers. Microcontrollers are highly constrained devices compared to modern computers and mobile devices, so XS focuses on minimizing size, rather than speed.

Despite its compact size, XS implements the 2018 JavaScript language standard with better than 99% conformance. This support is native to XS, using no transpilers or polyfills.

You can read more about the evolution, design, and implementation of the XS engine in this article. Note that some of the "to do's" in the Future section of that article have already been done.

How is XS different than other JavaScript engines for embedded?

XS is the only JavaScript engine for embedded that fully supports the ECMAScript 2021 standard—the same one used in web browsers today. It does so directly, without the use of polyfills or transpilation.

Other JavaScript engines for embedded follow the ES5 standard, which was released way back in 2009, perhaps adding a few features from more recent revisions.

In other words, XS is the only JavaScript engine for embedded that supports modern JavaScript language features like Asynchronous iteration, Object Rest/Spread properties, RegExp lookbehind assertions, and Promise.prototype.finally().

Moddable is also the only embedded engine provider participating in Ecma TC39, the JavaScript language committee. Moddable joined TC39 to help ensure that JavaScript remains a great language for use in embedded. Moddable helped to form Ecma TC53, a new standards initiative to define standard JavaScript APIs for use in Wearables and IoT, where cost, energy use, hardware support, and security have different requirements from the web platform.

What about TypeScript?

Because the XS JavaScript engine in the Moddable SDK supports modern JavaScript, TypeScript is fully supported as well. The Moddable SDK has integrated support for TypeScript:

  • Our build system automatically invokes the TypeScript compiler to generated JavaScript
  • Our xsbug debugger displays TypeScript source code when debugging, not transpiled JavaScript
  • Type declaration files (typings) are included for many Moddable SDK modules

Read more about our TypeScript support in our blog.

How is developing with XS on embedded different than JavaScript on the web?

The microcontrollers XS targets have much more limited memory and performance than the devices that power the web. That introduces several challenges developers should be aware of. To read more about some of the challenges and how we address them with the Moddable SDK, see the XS Differences document.

How does the Moddable SDK make JavaScript run well on constrained devices?

XS uses a many different techniques to minimize the use of RAM and ROM while delivering excellent performance of industry standard JavaScript.

Preloading

One of the key techniques XS uses to operate efficiently in memory-constrained environments is to compile and begin executing JavaScript. This sophisticated preloading process is unique to XS. The resulting byte code is downloaded to the target device together with the rest of the firmware. There are many advantages to this approach, including faster start up and lower memory use.

XS in C

Embedded developers are often hesitant about using JavaScript instead of C or C++ for performance reasons, and it is true that JavaScript will never outperform good native code. When necessary, we write functions in C and call them from script code using the "XS in C" API. We use XS in C for performance critical code and binding to native platform features. Developers can also use XS in C to create custom bindings. That said, you might be surprised by how well scripts perform so we generally recommend that you try scripts first and switch to C only if the performance is inadequate.

Which microcontrollers does the Moddable SDK support?

The Moddable SDK is written in portable C, allowing it to be ported to a wide variety of microcontrollers. Moddable currently provides supported ports for many common microcontrollers:

Does the Moddable SDK run in WebAssembly (Wasm)?

Yes, the Moddable SDK runs in WebAssembly. Build instructions are available. The build supports the XS JavaScript engine, most Moddable SDK tools, Poco graphics engine, Piu user-interface framework, preferences, and more. However, due to restrictions of the browser runtime, not all features are supported.

How can I get started with the Moddable SDK?

If you are an embedded developer new to JavaScript or a web developer getting started on embedded, our book – IoT Development for ESP32 and ESP8266 with JavaScript – is a great place to start. It is a practical guide to working with the Moddable SDK, filled with useful examples.

Check out our repository on GitHub. The Getting Started document describes how to configure the host build environments, install the required SDKs, drivers and development tools, build applications, and use xsbug, our JavaScript source code debugger.

There over 150 examples you can build for simulators on macOS, Windows, and Linux machines. To run the examples on a microcontroller, we recommend you start with a Moddable Two.

What embedded hardware should I use to get started with the Moddable SDK?

Moddable Hardware is the easiest way to get started. Each of our affordable modules includes a high quality display, a microcontroller, and wireless communication. Of course they are all fully supported by the Moddable SDK.

What licensing options does Moddable offer for the Moddable SDK?

The Moddable SDK is offered with two different licensing options:

  1. A Free and Open Source Software (FOSS) license
  2. A commercial software license

You can read more about our licensing options on our license page.

What's the best way to contact Moddable?

If you're an independent developer, we recommend you open an issue on GitHub. We'll respond as quickly as practical, and other developers can benefit from the answers to your questions.

For companies interested in the benefits of using JavaScript and the Moddable SDK to power your products, Moddable provides consulting services to help with design, implementation, training, and support.

You can also reach out to us on Twitter @moddabletech. Following us on Twitter is the best way to keep up with what we’re doing—we post announcements about new blog posts there, along with other Moddable news.

Use our Contact page to quickly get connected to the people and resources you need.