Live data from Hacker News

Using Python and OCaml in the same Jupyter notebook

blog.janestreet.com

11–20 of 35 posts

Re: Using Python and OCaml in the same Jupyter notebook

#12
post #3

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…

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.

That's pretty cool! It would have been much better if it didn't need the #%% and just evaluated the top-level structure (like function definition) with jupyter.

Still just merging the notebooks into the editor is a big step. :-)

Re: Using Python and OCaml in the same Jupyter notebook

#14
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

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

[3] https://imandra.ai

Re: Using Python and OCaml in the same Jupyter notebook

#16

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…

Another complaint I have with jupyter notebooks is that they don't play nice with git. For this (and other reasons), I much prefer Emacs org-mode, or even running Python in Rmarkdown+Rstudio+reticulate.

I second emacs-org mode. It is extremely powerful though I don't know if it addresses GPs concerns. You could just execute the compiler etc against the actual program from within the code block and then "+CALL" in other sections to avoid the copypasta'ing I guess. I don't do very advanced stuff so I haven't run into problems with just using code in the blocks.

The main problem with emacs org-mode is that users probably need to use emacs, and lots of people have their own editor preferences, and while some have org-mode-alike's, they aren't as fully capable as emacs org-mode. Which is what Jupyter addresses by making the interface more accessible/editable to all.

That said, I think one of the most important factors that the linear notebook flow encourages is a focus on reproducibility, whether it's Jupyter or Org-Mode. I feel like overcomplicating the dev environment would make the much harder and would at least need to be planned for.

Re: Using Python and OCaml in the same Jupyter notebook

#17

Earlier quoted context omitted.

Another complaint I have with jupyter notebooks is that they don't play nice with git. For this (and other reasons), I much prefer Emacs org-mode, or even running Python in Rmarkdown+Rstudio+reticulate.

I second emacs-org mode. It is extremely powerful though I don't know if it addresses GPs concerns. You could just execute the compiler etc against the actual program from within the code block and then "+CALL" in other sections to avoid the copypasta'ing I guess. I don't do very advanced stuff so I haven't run into problems with just using code in the blocks. The main problem with emacs org-mode is that users probab…

You can also extract the code via tangling so you can run it outside emacs.

Re: Using Python and OCaml in the same Jupyter notebook

#18

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…

> 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.

We have solved this problem by providing 2-way sync between notebooks and libraries, using a system called nbdev:

https://www.fast.ai/2019/12/02/nbdev/

Re: Using Python and OCaml in the same Jupyter notebook

#20

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…

Notebooks are not for interactively developing large codebases, instead see them as extremely powerful scientific calculators and you'll understand their appeal.
Post reply on HN