Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile 2 JavaScript language support #1

Closed
kebot opened this issue Aug 11, 2015 · 2 comments
Closed

Compile 2 JavaScript language support #1

kebot opened this issue Aug 11, 2015 · 2 comments

Comments

@kebot
Copy link

kebot commented Aug 11, 2015

Thank you for your cool things about iPython Notebook.

I just make two line modify to support CoffeeScript. It works!

  function run(code) {
    var compiledCode = require('coffee-script').compile(code, {bare: true})
    if(DEBUG) { console.log("SM: COMPILED: ```\n", compiledCode, '\n') }
    return vm.runInThisContext(compiledCode);
  }

But I'm not familiar with the architecture, I'm thinking how to make it support any compiler that exists(coffeescript, babel, etc...)

Here are some ways to do it:

  1. build-in compiler ijavascript --compile coffee, compiler can provided as plugins(such as ijavascript-coffee-plugin)
  2. I also see a Cell - Cell Type in the dropdown menubar, maybe add some custom cell-type there
Code(javascript)
Code(CoffeeScript)
Code(babel)
Markdown

To implement that, there are some points

  • async compiler support
  • is Cell Type in iPython pluginable?
  • Source Map Support
@n-riesco
Copy link
Owner

Thank you for the interest in this project.

Here's a brief outline of the IJavascript architecture:

  • IJavascript package implements a kernel for the IPython/Jupyter notebook.
  • NEL package runs Javascript on a Node.js session, but also provides auto-completion and documentation functionality.

The kernel in the IJavascript package is already language-agnostic. This means that it is possible to fork the NEL package and make it compile TypeScript, CoffeeScript, ES6, or even use a shell other than Node.js. Note, however, that NEL also provides auto-completion and documentation functionality and those would need updating for the new language.

This is how I suggest that a CoffeeScript kernel could be developed:

  1. Fork the NEL package
  2. Update the run functionality (see http://n-riesco.github.io/nel/module-nel-Session.html#run)
  3. Update the inspect functionality (see http://n-riesco.github.io/nel/module-nel-Session.html#inspect)
  4. Update the auto-completion functionality (see http://n-riesco.github.io/nel/module-nel-Session.html#complete)
  5. Once the forked NEL package is working, I would update IJavascript so that one could run the CoffeeScript kernel.

Note that:

  • your update of the run function in nel_server.js means that Session#run may require no changes.
  • Step 3 and 4 require replacing the list of JavaScript keywords with CoffeeScript keywords
  • Step 3 and 4 may require other changes to account for some of the CoffeeScript operators (e.g. ? and @)

As you see, the changes to get an initial implementation of a CoffeeScript kernel would be few.

I would be happy to help with the fork, so please, let me know if you go ahead.

@n-riesco
Copy link
Owner

n-riesco commented Apr 5, 2017

@n-riesco n-riesco closed this as completed Apr 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants