decaf icon indicating copy to clipboard operation
decaf copied to clipboard

Decaffeinate

Open petrbrzek opened this issue 8 years ago • 4 comments

Is this the same project https://github.com/decaffeinate/decaffeinate or different?

petrbrzek avatar Jun 15 '16 13:06 petrbrzek

They are different. They take different approaches to the same problem.

eventualbuddha avatar Jun 15 '16 17:06 eventualbuddha

@eventualbuddha If you can elaborate on the differences, that would be much appreciated.

rmacklin avatar Jun 16 '16 19:06 rmacklin

In short, decaf maps the CoffeeScript program structure (AST) into a JavaScript program structure, then generates JavaScript based on that.

On the other hand, decaffeinate uses the CoffeeScript program structure to modify the original CoffeeScript source code to change it to become JavaScript source code.

There are pros and cons to each approach, so which one you use depends on your priorities. Decaf is simpler and may be less likely to produce code with syntax errors. Decaffeinate preserves comments and formatting as much as possible.

One other thing that is different that isn't a matter of approach is that decaffeinate is more actively developed and runs daily against several popular open source CoffeeScript projects and runs their tests in some cases, which helps identify issues in decaffeinate.

eventualbuddha avatar Feb 20 '17 19:02 eventualbuddha

Thanks for the reply @eventualbuddha. Even before you answered, I experimented with both and I ended up liking decaffeinate's output more (as you said, the comments/formatting were better preserved, which was desired). I successfully converted several dozen CoffeeScript files to ES6 with quite readable diffs! Great tool 👍

rmacklin avatar Mar 28 '17 05:03 rmacklin