Re:Jupyter C Kernel
by gh02t on Thursday August 10, 2017 @03:02PM
(#14982979)
This looks like it doesn't share any context between cells, am I right? So I can't use functions defined in one cell in another.
[ Parent
| on HN ]
There exists a jupyter kernel for cling, which allows this (also this is C++ not C)
Yes, and it is quite good: https://github.com/root-project/cling#jupyter
I find it invaluable
Re:Jupyter C Kernel
by jasongrout on Thursday August 10, 2017 @08:23PM
(#14985628)
Here is another one in development: https://github.com/QuantStack/xeus-cling
It would be interesting exercise to compile cells into object files as they are entered and load them dynamically into a persistent process, doing needed linking etc on the fly in-memory. You'd also need to generate a header file from the current in-memory symbol table and implicitly include that in compilation.
That might actually work relatively well for simple cases. But I imagine there would be a ton of problematic edge cases, considering that with C you can end up with all sorts of weird stuff.
Re:Jupyter C Kernel
by williamstein on Friday August 11, 2017 @10:14AM
(#14989834)
The %cython mode for Sage notebooks (which I wrote in I think 2008??) does precisely that by generating a random-named Python shared object libary and importing it into the runnig Python process after each evaluation. There's a similar (%%cython?) mode for Jupyter notebooks.
Re:Jupyter C Kernel
by dgfgfdagasdfgfa on Thursday August 10, 2017 @06:35PM
(#14984992)
If you protect it appropriately, you've basically re-implemented exec.
However, every cell would need a main() function or it wouldn't do anything. Or you hold onto a main function from previous cells, perhaps overriding it, and make the notebook confusing as hell, defeating the point of notebooks
Re:Jupyter C Kernel
by brendanrius on Thursday August 10, 2017 @04:51PM
(#14984118)
It does not yet :)