Hacker News new | past | comments | ask | show | jobs | submit login
NaCl/OCaml (OCaml as a client-side web programming language) (inria.fr)
30 points by budu on March 6, 2010 | hide | past | favorite | 10 comments



I'm very excited to see this. OCaml is a really pleasant language to work in. It's certainly not without its warts, but it's surprisingly easy to write mostly-functional code that's highly performant, expressive, and easy-to-read. I've actually been enjoying picking it back up again, this time trying to learn it "for real", and knowing I have an interesting environment to target makes it much more exciting.


Should work for any native code compiler, if I'm reading this right, just have to stay within what can be validated.

I think there's a very good chance of a GSoC project to modify Haskell/GHC's backend to work too: http://www.reddit.com/r/haskell_proposals/comments/b9oym/run...


I've found technical descriptions of NaCl, but still don't get what it would look like in practice. Does NaCl enable languages like OCaml to be used instead of JavaScript to manipulate HTML pages? Or is it like Silverlight, which has its own non-HTML UI widget library and runs within the browser? Or would it run outside of the browser entirely?


NaCl is a way to run native x86 instructions in a secure manner inside the browser. As such, it has more in common with Silverlight than JavaScript. The difference between NaCl and Silverlight is that you can use any language with NaCl, provided that it compiles to a verifiable subset of x86. The downside, obviously, is that while Silverlight runs just fine on any platform with a CLR, which in practice means desktops and Zunes, NaCl only runs on x86 systems that have the NaCl plugin installed, which currently means the dev channel of Chrome.

As such, I view NaCl more as a research project right now than anything else, but who knows? If Chrome OS takes off, NaCl would suddenly be a very serious target, even if no other browsers endorse it. Meanwhile, it's still fun to tinker with.


Thanks Gecko. What about UI? With Silverlight, one would write XAML to define a webapp's UI elements (e.g. forms). Is there a NaCl equivalent? (Please excuse my rudimentary knowledge of how things work under the hood.)


NaCl can talk to the DOM/JavaScript, or can draw things itself using a frame buffer. All demos I've seen use the latter technique.

As far as I know, there are currently no standard widgets. http://nativeclient.googlecode.com/svn/data/docs_tarball/nac... has a good overview of the APIs available. I had thought that at least a little OpenGL was available as well, though I don't see it enumerated there. I'm unsure whether that's because I'm wrong, or because it's simply not in the generated documentation. At any rate, given that the API is based around framebuffers, it'd be pretty easy to port GDK or a similar system to run in NaCl.


NaCL programs are x86 programs built with a special version of the GCC-flavor toolchain, provided by Google, which creates ELF binaries that are especially easy to analyze. Before being run, they're passed through a verifier. The major difference between NaCL x86 and bare-metal x86 is that NaCL programs can't call out to the operating system (or do anything outside their code segment at all).

Those limitations don't rule out most programming languages; NaCL-flavored Haskell should be just as doable.

The programs themselves do in fact live in a process outside the browser.

The big limitation with NaCL is that virtually none of your site's visitors will have it enabled.


Does NaCl enable languages like OCaml to be used instead of JavaScript to manipulate HTML pages? Or is it like Silverlight, which has its own non-HTML UI widget library and runs within the browser?

You can do it either way. Most of the demos draw the UI in NaCl itself (Flash/Silverlight style).


Hopefully once they get ARM-NaCl working, they'll be able to stick it on all the Android phones. It could actually take off.


Joh Harrop is a great guy, if you religiously like ocaml or F#. A True Missionary!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: