Inside Google Native Client for x86 binaries
Call it crazy, but Google's experimental technology to run native x86 binaries in the browser shows lots of potential
Follow @McAllisterNeilLast week, Google announced a new version of its SDK for Native Client (aka NaCl, in a riff on the chemical formula for salt). For those who don't recall, NaCl is the technology I once called "Google's craziest idea yet." In a nutshell, it allows developers to deliver code modules for Web applications in the form of native x86 binaries that execute on the user's bare CPU -- no interpreter, no virtual machine, no nothing.
I called the idea crazy, but it's really crazy clever. As Native Client continues to evolve, I thought it was high time I checked under the hood to see how this nutball idea actually worked in practice. To that end, I downloaded the new SDK, fired up my toolkit, and put a few of Google's demo NaCl applications through their paces.
[ Peter Wayner explains how to develop HTML-based mobile apps and escape the app store. | Stay up to date on the key programming news and issues with InfoWorld's Developer World newsletter. Sign up today! ]
Old tools for a new kind of Web app
NaCl may support a variety of languages in the future, but for now, NaCl modules are written in C or C++ and compiled using a tool chain based on the Gnu C Compiler (GCC). The process will be familiar to Java or .Net developers, but Web developers who are used to interpreted languages such as PHP, Python, and JavaScript may experience a learning curve. (Even Java and C# programmers may be confounded by C's header files -- welcome to the good old days!)
I was a little dismayed by the complexity of the modules themselves. One of Google's examples was a trivial module that could return a number to the browser and reverse a string of text. That simple demo comprised 306 lines of C source code and 101 lines of JavaScript and HTML. Admittedly, a lot of that was explanatory comments -- still, "Hello, world" it ain't.
Once compiled, NaCl modules are not ordinary executables. They carry a .nexe extension, and they won't run on the server itself or anywhere outside the NaCl environment. The upshot is that it doesn't matter what platform you develop them on; I built the SDK's examples on a Linux workstation and served them to a Windows 7 client with no hiccups.









