IPython notebook webapp discuss with a tornado webserver that act as a bridge with ZMQ to talk to kernels, kernels might be python, julia, haskell, OCamel, nodejs, ruby, scala ... for thoses that I know of. As long as a kernel comply to the message spec (and nice blog post about messaging protocol from the guy who wrote IHaskell) it is transparent for the frontend that just send strings/ receive results.
If you want a more stand-alone version you can look at Min's single cell demo. But basically you should be able to embed IPython's kernel.js
in a page, and just use IPython.kernel.execute(code, callbacks)
.
The exact way of how this work in the kernel differs from language to language. Python can natively do so as you can eval a buch of code in a specific namespace, for other languages I can't tell you exactly.
Instead of reinventing, I think re-using IPython's message spec and reusable component would make sens[1].
Also I've heard from reliable source that IPython want the ability to start notebook with languages in different languages, and that they also want some closer than a REPL (like QtConsole) in the browser[2].
[1] I'm biased, I'm an IPython dev.
[2] That something we often talk about, but we have some Python-ism we want to get rid of first.