run Clojurescript via %magic in an iPython notebook?

315 views
Skip to first unread message

Lee Spector

unread,
Jul 22, 2015, 12:35:36 PM7/22/15
to clo...@googlegroups.com

It is apparently possible to run javascript via "magic" commands in iPython notebooks (https://ipython.org/ipython-doc/3/interactive/magics.html).

I assume that this would make it possible also to use Clojurescript, but I don't know what would be involved. I have a fair bit of Clojure experience but little experience with Clojurescript or Javascript, and I'm new to iPython. Does anyone have experience with this or interest in looking into it?

I am familiar with the wonderful Gorilla REPL, which provides a similar notebook-like environment for Clojure (http://gorilla-repl.org), but my question here is in the context of a course in which I'll be teaching Python. It might be both fun and useful to sneak in a little Clojure/Clojurescript from time to time.

Thanks,

-Lee

Peter Denno

unread,
Aug 16, 2015, 8:52:08 PM8/16/15
to Clojure
Hi,

I'm interested in this too. However, I have virtually no experience with Javascript. The place to begin the investigation, I think, is with the new, more general implementation of iPython notebooks, Jupyter (https://jupyter.org/). Note that there is even a Clojure kernel for Jupyter; thus the ability for users to run clojure notebooks. But that's not what I'm after. Like you, I'm interested in using Clojurescript in the notebook rather than Javascript as means to add custom capabilities. Since Clojurescript compiles to Javascript, I don't think getting things to work will be hard. There are a few jupyter project repositories (very active and probably not yet stable) for things that seem related. Take a look at the repositories under the jupyter project, https://github.com/jupyter , but note that many of these repositories are only a few weeks old. 

Regarding the old implementation of iPython notebooks, there is a bit of a tutorial on integrating notebooks with Javascript here : https://jakevdp.github.io/blog/2013/06/01/ipython-notebook-javascript-python-communication/  I tried it; it partially works. As the author points out, it is obsolete as of iPython 2.0. The current release of iPython is 4.0.0. So it is useful for thinking about the basic concepts.

Reading some of the developer discussion on jupyter, it appears that they are using a React-like framework called Phospor. This might be good for Clojurscript development, enabling easier use of figwheel (which I've read about, heard good things from other developers, but have not myself used yet.)

Hope that helps, 
  Peter

Lee Spector

unread,
Aug 17, 2015, 11:32:50 AM8/17/15
to clo...@googlegroups.com

Thanks Peter -- I'll take a look at this stuff.

-Lee
Reply all
Reply to author
Forward
0 new messages