Google Native Client - Part 1
blog.leafsr.com
blog.leafsr.com
Nobody should be pushing CPU architecture specific executables as a web standard. Yes, you can compile is for x86 and ARM, but that's incredibly short-sighted. What about PPC? MIPS? Some future architecture that hasn't been invented yet? Do we have to make a virtual machine then? Yes, you can also compile as LLVM bitcode, but then why give prejudicial preference to x86-32 and ARMv5? (Note the specific versions there) You might as well just ship as PNaCl and skip NaCl altogether.
PNaCl is an amusing evolution of web scripting: we've come full circle from a JVM thru Javascript back to a solution which is almost a JVM. To be cynical, it seems like an awfully huge project just to avoid writing Java.
Regarding alternatives to JavaScript, you can compile pretty much any language into a form that can run on the web, right now: C++, C#, Java, etc. (That form happens to be JavaScript.)
The PNaCl project[1] aims to distribute LLVM bitcode, solving this problem. You also gain the advantage that all programs can be JITed to exactly your processor spec.
If all NaCl apps would contain PNaCl/x86/ARM binaries I don't see a disadvantage compared to compiling other languages down to JavaScript (which is just as unreadable/proprietary).
Also it's certainly an improvement over native plugins that not only lack a sandbox, but are also tied to the OS in addition to the CPU. In fact, I suggest that browsers should adopt NaCl at least for plugins, maybe even allowing unrestricted access to the file system, camera, etc. and gradually phase out conventional plugins. Even without the security benefit this still gives us portable plugins.
Even if PNaCl worked today, and even if it gave good performance and portability, it would still not be standardized. The only way to get PNaCl into a new browser would be to use the current implementation (which defines what it is).
Having that implementation open source is a good thing. But it isn't as good as JavaScript which has a standard and multiple independent implementations. If you want to write a JS engine in Haskell, for example, you can do that. You can't do that with NaCl or PNaCl, you must use the existing code as is.
There is no standard or spec for NaCl, PNaCl or PPAPI. Those things are still being developed, and they change a lot (talk to people that develop for that API to get an idea of how things can change with each 6-week update of Chrome). To implement those, you need to basically "do what Google's implementation does." Trying to track that large and complex - and changing - implementation is practically impossible.
Compiling other languages to JavaScript imposes an unacceptable speed penalty. C++-to-JavaScript is not a viable platform for real applications, especially anything performance-critical.
Do you have numbers for the "unacceptable speed penalty" JavaScript imposes on compiled code? That's an honest question, I am curious to see benchmarks about that.
It's a great compiler IR though! This isn't a criticism of LLVM bitcode.
It's not a force-fit either. LLVM is designed to be a form from which machine-specific code is generated. The problem is only that different platforms have different conventions. But any modern 32-bit platform can use a given set of conventions if you want it to.
That won't be hell to debug.
I could be wrong, but I remember reading about it somewhere. Either way, it is pretty cool technology of which nobody else seems to want to support. Which is too bad, really.
Maybe there is also a NaCl backend for LLVM, I don't know ...
edit: I suppose a link should be presented.
http://www.chromium.org/nativeclient/pnacl/building-and-test...
Where is the "hello world" for writing a plugin/chrome-app in some other language?