Mobile Web holds the future of embedded multicore
HTML5's Web runtime performance and Write Once, Run Anywhere (WORA) portability have the long-time Internet language speaking to embedded designers.
Mobile devices such as smartphones and tablets are the current buzz around the water cooler these days. A key technology at the center of mobile device innovation is HTML5, which enables new models of dynamically generated and contextual content. Several features of HTML5 show promise to help solve two of the biggest problems in embedded design: application portability and performance.
HTML5 is the fifth version of the HTML standard, a language for content downloaded from the Internet. HTML had humble beginnings in that it was originally used to create and publish textual and simple graphical information on the Internet. HTML5 has evolved to encompass much more; it aims to provide a complete application platform. Focus areas for this version of the specification include source code readability, multimedia, graphics, device access, performance, offline storage, and connectivity.
A typical HTML5 application comprises a combination of three main components serving different functions:
- HTML: Specifies page structure.
- Cascading Style Sheets (CSS): Documents styling and visual effects.
Three properties give HTML5 the ability to easily create dynamic and contextual content:
- Asynchronous support: Internet access is built into the language; it is second nature. External sources of information and content, such as the HTML5 picture in the sample, are easily accessed.
The trivial application detailed here does not represent all of HTML5’s capabilities. A more compelling example is seen at [Editor’s note: Browser must support WebGL to view page.] Other compelling HTML5 demos and tutorials can be seen at ., which presents a 3D model of a human body.
A potential embedded application for dynamic and contextual content generation is futuristic display boards in a shopping mall. Assuming sufficient security and agreed-upon privacy models, the display board identifies passersby, collects their purchasing preferences, queries the Internet for sales, and then feeds the information back to the passersby in the form of custom-generated ads. The three properties of HTML5 make it trivial to pass data and add new functionality to the application. In short, HTML5 provides first-class support for dynamic and contextual content.
One of the holy grails of software development is Write Once, Run Anywhere (WORA), which is the ability to write one version of an application that can execute on many different devices. Think of the advantages of being able to download one application and have it execute on any device regardless of whether it is running Android, iOS, or Windows 8. HTML5 makes this possible.
The application in Listing 1 would function similarly on an Android device, iOS device, and desktop computer, as long as the underlying Web runtime supports HTML5. A Web runtime is the program stack that translates the HTML5 program into the application the user sees. WebKit is the Web runtime used to power the HTML5 experience on a number of Operating Systems (OSs) and browsers including iOS, Safari, Android, Chrome OS, and the Chrome browser. An interesting site that summarizes different browsers’ compatibility with HTML5 is. Table 1 lists several browsers, their underlying Web runtime, and their HTML5 compatibility score. As can be inferred from the scores, browsers are still a ways off from conforming to the entire standard; over time this situation will improve.
Embedded scenarios around WORA are numerous. An embedded developer looking to migrate an application from one architecture to another would only need to focus on providing the same or compatible Web runtimes across platforms. The developer would have the flexibility to more easily adopt different architectures and OSs over a product’s lifetime.
Web runtime performance
HTML5 specifies Web Workers that introduce threads to Web applications and offer the ability to share work within one application. There are limitations with this approach in that the Web Worker does not have access to the Document Object Model (DOM), which is the internal representation of the Web page or application. Message passing enables communication between the main thread and a Web Worker.
Figure 2 shows a sample program employing Web Workers and comprising two files, main.js and task.js.
The need for multicore support in embedded applications has been documented for more traditional languages. It is apparent that when HTML5 is adopted for embedded applications, the demand for increased performance will exist as well.
The advent of embedded HTML5
The use of HTML5 in embedded is coming. For example, Mozilla’s Boot to Gecko OS targeting the automotive segment is programmed primarily via HTML5. However, embedded applications face some challenges in adopting HTML5. First, the ability to download text and execute it as a program is powerful, but is also a possible attack point for viruses and Trojan horses. Ensuring the security of HTML5 applications will be just as important as ensuring the security of today’s embedded applications. Second, API access to the embedded market’s unique array of devices and sensors will require some standardization work apart from mainstream HTML.
Challenges aside, HTML5’s qualities of dynamic and contextual content, increased performance, and portability across OSs will gradually lead to broad adoption across the range of embedded applications.