n-riesco / ijavascript

IJavascript is a javascript kernel for the Jupyter notebook
Other
2.18k stars 187 forks source link

[DISCUSS] Implement `$$.restart` #154

Open n-riesco opened 6 years ago

n-riesco commented 6 years ago

In some cases, it may be convenient to restart the kernel while keeping the session (so that frontends like Hydrogen and nteract can continue using the session).


Re #117

ken-okabe commented 6 years ago

I'm a beginner user of IJavascript, and thanks for the great implementation of the node kernel for Jupyter notebook. Here's my thought using JupyterNotebook+IJavascript. In general sense of software design, I'm sort of surprised to find the software frequently requires to "restart the kernel" itself. For instance, "Run All Cell" for the second time generates SyntaxError: Identifier 'log' has already been declared and required to restart the kernel which takes for a while where inefficient and resource consuming process. It's merely a document, and I don't know the reason to restart the whole kernel. It's surely possible to "Run All Cell" without the kernel reboot, since opening new document with copying-paste the identical code can run properly without error (at least for the first time.) Rebooting the software should be the last thing to do in the software design I believe. Currently, I look for a work-around not to restart the kernel to avoid the syntax-error, and I barely could find there is "%reset" command for Python environment. https://stackoverflow.com/questions/35492914/reset-an-ipython-kernel-without-restarting This doesn't work for IJavascipt kernel mode, and I really want you implement $$.reset to reset environment variables instead of $$.restart.

n-riesco commented 6 years ago

@kenokabe Thank you for showing interest in $$.restart. In the meantime, I suggest treating Jupyter notebooks as if they were REPL sessions. In particular, for Javascript, I'd recommend the use of var (and avoid const and let) to define identifiers in the global scope.

ken-okabe commented 6 years ago

@n-riesco Thanks for the response. Yes, so far, I hack for a small patch to replace strings for const to var in NEL execution code. This is ok, since I deubg the code in IDE. However still, now ES6 is a language of block-scope and local variables, and so many adopted users of ES6 will see this const-syntax error for each re-evaluation of documents problematic I suppose. So please take this issue more seriously. Thank you.