Google Releases Native Client SDK (Dev Preview)

DZone 's Guide to

Google Releases Native Client SDK (Dev Preview)

· Performance Zone ·
Free Resource
After adding module support for several modern processor architectures in March, Google's Native Client (NaCl) project has moved past the research version and released a developer preview SDK that should allow you to start writing NaCl apps in minutes.  Native Client is a plugin framework for the browser that is carefully sandboxed, and runs directly on the operating system while leveraging modern hardware architectures.  It has modules for running native x86 and ARM processor code in the browser with a native execution sandbox that isolates the application from the browser and the host's regular processes (Unlike Netscape plugins or ActiveX).

The research version of Native Client was made available about one year ago.  It consisted of a source tree snapshot that developers could download and play with, but the download was pretty bulky. The Native Client SDK is much more lightweight, giving you access to powerful APIs and allowing you to write C/C++ that works seamlessly in Chromium.  It includes only the essential components for getting an app up and running.  These components include a modified GCC compiler to generate x86-32 or x86-64 binaries from C/C++, ports of open source projects such as zlib, Lua, and libjpeg, and some samples for developing with the NPAPI Pepper Extensions.

A developer can think of NaCl as a very small operating system.  It has the cross-compiling GCC tool chain that was just mentioned, POSIX support, and a basic multimedia interface for keyboard events, mouse events, audio, and video.  Web pages with the embedded plugin can be read or modified through the browser.  Anything you can do from JavaScript, you can also do from NaCl.

Another important part of the Native Client project is the Portable Native Client (PNaCl).  PNaCl splits the NaCl software execution into two parts to make it work on more processors.  It allows the browser to translate the portable representation into native binary for any type of processor without accessing the source code of the program.  The first step translates the developer's code into LLVM bitcode; a portable intermediate state.  The second part of the process involves the specific NaCl modules for each specific processor architecture, which is detected by PNaCl.  These modules then translate the bitcode into machine code for the correct architecture.  This is also the stage in which security checks are run.  Google is still trying to determine how much overhead is added by these translations and learning how to reduce it.  

Credit: Google

NaCl also shares the security concerns of JavaScript programs: NaCl applications can be deployed without notifying the user.  NaCl also gives web apps a gateway down to your hardware.  For security measures, NaCL has a code scanner and verifier that screens the code for unsafe instruction sequences when a program is loaded into NaCl.  
To start building your own NaCl applications, download a recent build of Chromium and the NaCl SDK.  You'll need to start Chromium with the --enable-nacl command-line flag to test apps and samples.  The SDK won't work with the Native Client browser plugins yet because NPAPI Pepper extensions are currently only available in Chromium.  Google will be updating the SDK frequently over the next few months, so stay tuned.

Check out this research paper on NaCl performance.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}