Live data from Hacker News

Using Python and OCaml in the same Jupyter notebook

blog.janestreet.com

1–10 of 35 posts

Re: Using Python and OCaml in the same Jupyter notebook

#2
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).

Re: Using Python and OCaml in the same Jupyter notebook

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

Re: Using Python and OCaml in the same Jupyter notebook

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

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

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

Re: Using Python and OCaml in the same Jupyter notebook

#6

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.

Re: Using Python and OCaml in the same Jupyter notebook

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

PyCharm also has this integration. You can run python files with “#%%” delimiters for cells or Jupyter notebooks. I had issues with scrolling because opening the notebooks results in a split view with editor and notebook rendering.

Re: Using Python and OCaml in the same Jupyter notebook

#8

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.

Jupytext solves this for me completely. It is an extension to jupyter code which can be turned on (globally or per-notebook, with additional configuration options) which automatically syncs the notebook to a file which can be checked into git and has nice diffs. It is a two-way binding, so editing the file will include those changes in jupyter, and if you check out a file in that format it can be converted into a jupyter notebook on your side easily as well.

Re: Using Python and OCaml in the same Jupyter notebook

#10

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…

You mean something like Julia from Atom?
Post reply on HN