
Using Python and OCaml in the same Jupyter notebook - l-m-z
https://blog.janestreet.com/using-python-and-ocaml-in-the-same-jupyter-notebook/
======
pcr910303
The jupyter-notebook interface is IMO, not really suited for interactive
development. Notebooks enforce code to be broken up into pieces of cells to be
evaluated. The code must be written in a specific linear way to cater the
format of notebooks. Also the distinction between the code & notebooks are too
big, it's clunky to move between. You get to resort copy-pasting back-and-
forth. It's always frustrating when I try to do development in an interactive
way, and finds out that hooking on jupyter-notebook (whether the language is
Python or Node.JS or etc...) is the best way.

I think there should be a better integration between editors & REPLs,
something like Common Lisp & Emacs SLIME. SLIME queries a server running on
Common Lisp to incrementally compile & evaluate code from the editor (like
LSP, but not autocomplete queries but evaluation queries). I hope the LSP
protocol gains ability to evaluate code for languages with REPLs, it would be
awesome if it allows interactive development in multiple editors & multiple
languages (like how LSP is facilitating autocomplete).

~~~
dunham
For python, visual studio code has some of this integration. It still runs a
jupyter kernel, but will run "cells" directly from your source code file
(where the cells are delimited by "# %%" comments) and output to a separate
pane with a jupyter-driven repl in it.

I accidentally discovered this after exporting a jupyter notebook to python
and opening it in vscode.

~~~
snackematician
Emacs and Atom also support interacting with running Jupyter kernels when
editing scripts ([1], [2]). In a sense, notebook-less Jupyter kernels already
are the "LSP for REPLs".

[1] [https://github.com/dzop/emacs-jupyter](https://github.com/dzop/emacs-
jupyter)

[2] [https://atom.io/packages/hydrogen](https://atom.io/packages/hydrogen)

------
xvilka
Worth mentioning there is an emerging scientific computational framework
Owl[1][2] and interesting concept of using OCaml-based languages for more
formal protocol or logic description with Imandra[3].

[1] [https://ocaml.xyz](https://ocaml.xyz)

[2] [https://github.com/owlbarn](https://github.com/owlbarn)

[3] [https://imandra.ai](https://imandra.ai)

------
mark_l_watson
Really nice. Whenever I read a Jane Street OCaml blog article, I wish I had
the same thing for Haskell. Oh well, life is not perfect.

I have used the Haskell TensorFlow bindings, but the OCaml examples look more
straightforward.

------
nattmat
There is also a notebook project from Netflix called Polynote that support
Scala and Python interop. I think they opted for not making a Jupiter kernel
because of the need for fast code completion.

[https://polynote.org/](https://polynote.org/)

------
StreamBright
Why use Python though? Once you are rolling with an ML language wouldn't it
make sense to use the C++ interfaces of the machine learning/data science
projects that make Python interesting at all?

~~~
username90
Many python libraries C implementations doesn't have ergonomic C bindings,
they were explicitly made by python developers to be called from python so
porting them to other languages is usually pointless. They are user friendly
thanks to the large amount of python wrapper code, throw that away and you
don't have much of value left.

~~~
p_l
One of the worst examples is TensorFlow, which is really, really hard to use
from anything other than Python

------
shanemhansen
That's pretty cool. Reminds me of mixing blocks from different languages in
org mode.

------
vmchale
Neat! I love FFI and I love functional programming.

------
AzzieElbab
Very cool, but expected a pic of snake riding a camel

~~~
AzzieElbab
..on Jupiter

