Hacker News new | ask | show | jobs
by jordwalke 3920 days ago
This looks really cool, I look forward to following the project.

I'm curious, if you wanted your unikernel to be running in a JS VM (I'm not sure what the primary motivation would be[deployment?]) why not take the approach of just compiling the type-safe MirageOS into JavaScript (possible because MirageOS/OCaml can also compile into JS). Unikernels are attractive because of, among other reasons, increased security. It's pretty well understood that a powerful type system (such as Mirage's use of OCaml) would be useful in reducing accidental security vulnerabilities as well. Come to think of it, I'd much rather trust mission critical server infrastructure to OCaml that compiled to JavaScript, over JavaScript. At the end of the day, you'd still be able to use it from within js via `require('OS')`, but its implementation would have had more bugs/vulnerabilities prevented by the type system.

3 comments

Thanks for pointing this out--it brought my attention to the author's Irmin backend, based on the browser's implementation of IndexedDB:

https://github.com/talex5/irmin-indexeddb

That said, trying out this demo [1] of Cuekeeper gives an IndexedDB error message on Firefox 40.0.3 on Linux; perhaps IndexedDB is somehow not enabled.

[1] http://roscidus.com/blog/cuekeeper/

On additional huge benefit to having a statically typed reflection-less language for a unikernel would be that dead code elimination becomes rather a lot easier. (You'd need whole-program analysis, but that's pretty doable for the ML's of the world, see e.g. MLton.)
I'm confused. If you're writing OCaml in the first place, why not just directly run it on MirageOS?

The obvious benefit of a JS VM unikernel is that you get to write your application in JavaScript...

It's not clear to me and I don't have any experience with unikernels, so please accept my grain of salt and I apologize if I misspeak.

If you're starting with MirageOS, then obviously makes sense to just run MirageOS a bare-metal hypervisor. But if you're starting with the assumption that you will be running in a JS VM, then you have two options: build a unikernel in JS, or compile one to JS. The later option (MirageOS compiled to JS) also happens to leave open the possibility of easily being ran on a bare metal hypervisor with the unikernel implementation itself also running on bare metal (without a language level virtual machine) - because OCaml executes without a language level virtual machine (it's more like C++ in that sense).

> The obvious benefit of a JS VM unikernel is that you get to write your application in JavaScript...

What are some reasons why that would be a good thing in the case of unikernels? (I'm genuinely asking) The type system and invariants that it enforces are one of the things that makes OCaml based unikernels such a compelling idea to me. JavaScript, although I obviously find it useful for many things, doesn't seem to have as much appeal in this case.

Relevant to security: See MirageOS's Bitcoin Pinata project: http://amirchaudhry.com/bitcoin-pinata/

Edit: Again, it's still cool to see this project, and it's a great way to get more people experimenting with the idea of unikernels.

> What are some reasons why [using JS] would be a good thing in the case of unikernels?

The same reason it would be a good thing to use JS under any circumstances: there's already a huge supply of developers familiar with it and its ecosystem, it's available on pretty much every platform (now including at least one dedicated unikernel environment), it's a natural fit for web application development, and so on.

It's clear why unikernels and OCaml go together so nicely: immutability is a concept central to them both.

That said, the affordances of using a unikernel seems fairly orthogonal to the choice of language, IMO.

> it's available on pretty much every platform

And now so is OCaml, Elm, PureScript, C++, and anything else that compiles to JS.

> it's a natural fit for web application development, and so on.

Now that other languages are beginning to compile to JS, they are also becoming increasingly natural for web app development.

> there's already a huge supply of developers familiar with it and its ecosystem.

This is definitely true.