Feeds

Google's Native Code browser tech goes cross-platform

Write web modules in C/C++ that run on both Intel and ARM

Securing Web Applications Made Simple and Scalable

Google I/O At its annual I/O conference in San Francisco this week, Google unveiled a new version of its Native Client technology that allows developers to deploy binary code for web applications in an architecture-independent way.

With the original version of Native Client (NaCl), developers could write modules in C or C++ and compile them into binary packages to be executed inside the browser at near-native speed. The initial release only supported 32-bit and 64-bit Intel x86 architectures, but Google added support for ARM in January.

The revamped version of the tech, dubbed Portable Native Client – PNaCl for short, pronounced "pinnacle" – still allows developers to target all three architectures, but now they can do so with a single executable package instead of compiling a separate package for each processor type.

It works by essentially breaking the process of compiling PNaCl modules into two steps. The PNaCl toolchain really only compiles the C/C++ code halfway, outputting LLVM compiler bitcode instead of native machine code. That bitcode is then packaged into a .pexe file for deployment.

The client browser handles the last mile itself, translating the bitcode of any .pexes it receives into whichever machine code format is appropriate for the platform on which it's running. That extra compilation step does add a bit of startup overhead, but not too much, and Google has been working to speed up the process even more.

PNaCl does have a few limitations, however. Unlike the earlier NaCl technology, PNaCl does not support linking with glibc, the standard C library found on many Unix-like systems. Instead, developers must statically link their PNaCl modules with the more lightweight Newlib library.

The new version of PNaCl, released on Wednesday, also introduces a new format for .pexe files. Modules created with older, experimental versions of the PNaCl toolchain will no longer work in browsers that support the latest version of the PNaCl spec.

That support is limited to Chrome version 29 or higher – which, for the time being at least, means only the bleeding-edge "Canary" releases of the browser. Fortunately, you can install Canary side-by-side with more stable versions of Chrome, so you're not forced to use it all the time.

Note, also, that PNaCl only works with Chrome running on Windows, OS X, Linux, and Chrome OS. Although it does support the ARM architecture, there is still no support for NaCl or PNaCl in Chrome for Android, so deploying binary modules for Android smartphones and tablets is out.

And the biggest catch of all, of course, is that Chrome is currently the only browser to support NaCl in any form, and it looks like it's going to stay that way.

For a while, it seemed as though the open source Firefox browser might be a likely candidate to adopt Google's tech, but the Mozilla Foundation has since come out strongly against the native-code approach, preferring to work on accelerating JavaScript execution through projects like asm.js.

That means web apps written using PNaCl will only run on Chrome, probably forever. But that's not all bad – as Google's Sundar Pichai observed in his Google I/O keynote, Chrome is the most popular browser in the world, after all.

And like the original NaCl, PNaCl is uniquely useful for organizations who want to use existing C/C++ code in web apps without translating their algorithms into another language, such as JavaScript. Few other tools let you do that as easily, which could make PNaCl's browser limitation a fair tradeoff, in some cases.

For more technical information on PNaCl and its architecture, you can consult Google's technical paper on the system. Or, if you want to just dive in and try the tools, you can find instructions and downloads at the PNaCl project's homepage. ®

Bridging the IT gap between rising business demands and ageing tools

More from The Register

next story
NO MORE ALL CAPS and other pleasures of Visual Studio 14
Unpicking a packed preview that breaks down ASP.NET
Secure microkernel that uses maths to be 'bug free' goes open source
Hacker-repelling, drone-protecting code will soon be yours to tweak as you see fit
Cheer up, Nokia fans. It can start making mobes again in 18 months
The real winner of the Nokia sale is *drumroll* ... Nokia
Put down that Oracle database patch: It could cost $23,000 per CPU
On-by-default INMEMORY tech a boon for developers ... as long as they can afford it
Another day, another Firefox: Version 31 is upon us ALREADY
Web devs, Mozilla really wants you to like this one
Google shows off new Chrome OS look
Athena springs full-grown from Chromium project's head
Apple: We'll unleash OS X Yosemite beta on the MASSES on 24 July
Starting today, regular fanbois will be guinea pigs, it tells Reg
prev story

Whitepapers

Designing a Defense for Mobile Applications
Learn about the various considerations for defending mobile applications - from the application architecture itself to the myriad testing technologies.
Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Top 8 considerations to enable and simplify mobility
In this whitepaper learn how to successfully add mobile capabilities simply and cost effectively.
Seven Steps to Software Security
Seven practical steps you can begin to take today to secure your applications and prevent the damages a successful cyber-attack can cause.
Boost IT visibility and business value
How building a great service catalog relieves pressure points and demonstrates the value of IT service management.