akabe / ocaml-jupyter

An OCaml kernel for Jupyter (IPython) notebook
https://akabe.github.io/ocaml-jupyter/
MIT License
292 stars 41 forks source link

Add a mention about the pip package ocaml in documentation? #167

Closed Naereen closed 3 years ago

Naereen commented 3 years ago

Have a look at this blog post by the author of this undocumented pypi ocaml package.

You can see here what it's capable of doing, and it's quite impressive!

Of course it's very limited, as the Pypi package does not rely on the system OCaml runtime but on a pre-compiled version which comes included in the Pypi package... so it cannot use external modules, and is much more limited in its integration with Jupyter, when compared with your (:sparkles: awesome) project. It does ship the entire standard library (see details).

On the other hand, it allows to use dynamically defined OCaml functions from Python, the same way it can be done for other languages lke Julia or R (see this blog post if you never saw these possibilities, or this one). For instance:

In [7]: import ocaml, numpy as np
In [8]: s2 = %ocaml List.fold_left (+.) 0.
In [9]: s1 = sum
In [10]: X = list(np.random.randn(100))
In [11]: assert s1(X) == s2(X)
In [12]: %timeit s1(X)
6.92 µs ± 110 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
In [13]: %timeit s2(X)
15.2 µs ± 243 ns per loop (mean ± std. dev. of 7 runs, 100000 loops each)
akabe commented 3 years ago

Thank you. I have read the post you mentioned. It's big advantage that we can use many python libraries for mathematics and visualization from ocaml. The author of the post seems to want to provide ocaml services for python users. I'm interested in use cases of pypi in practice. If jane street uses ocaml and pypi for data analysis, that is very cool application!

Naereen commented 3 years ago

Thank you. I have read the post you mentioned.

Thanks for your interest :+1:!

It's big advantage that we can use many python libraries for mathematics and visualization from ocaml.

Yes but honestly the integration of Python from OCaml is much more cumbersome than the other way around... Compare writing python_function = %ocaml <some OCaml code> to what is required for pythonlib.

The author of the post seems to want to provide ocaml services for python users. I'm interested in use cases of pypi in practice. If jane street uses ocaml and pypi for data analysis, that is very cool application!

Indeed!

akabe commented 3 years ago

What is the purpose of this issue? Has it been already solved?

Naereen commented 3 years ago

I'm not exactly sure what I had in mind opening this issue. I thought that maybe in the README of ocaml-jupyter there could be one line mentioning this blog post and Pypi package, saying something like this:

While ocaml-jupyter provides a complete kernel for Jupyter to work with OCaml in a notebook, independently of the Python backend or IPython kernel, some users might be interested in doing the opposite, and using some OCaml small ode from a IPython kernel notebook, inter-connecting it with their Python code. It is possible by using [this Pypi package], see [this blog post] and an example in [my demo notebook].

akabe commented 3 years ago

Hmm. I think the purpose of the README is explanation of usage of ocaml-jupyter, not providing complete comparison of related work. The description of pypi in README would be noisy if maintenance of the package possibly stopped, independently of ocaml-jupyter. In order to reduce maintenance cost, I want to omit needless information which has no effect to ocaml-jupyter's usability.

However, if someone writes a blog post about choices for using ocaml on jupyter, users will be grad.

Naereen commented 3 years ago

You're right. Your README does contain a comparison to IOCaml, but that's a very close project, so it's quite different. (by the way did you know about IOCaml-js, which compiled the underlying OCaml interpreter to javascript and provides a pure in-browser client-side notebook for OCaml? it's quite nice)