Hacker News new | ask | show | jobs
by uranian 3290 days ago
You mean only ES2016 from that list?

> Producing readable code is certainly the intent!

This is hilarious! Transpiling from the most readable JS alternative to ES6? Then you need to clean up some things, making it ready for yet another transpiler called Babel? And then everything is OK?

Show me how you are going to make this pretty:

  if does.that?.prop?.exist then console.log 'yes, no crash!'
1 comments

> You mean only ES2016 from that list?

No, I was intentional about my description. People tend to be informal when talking about JS versions, and all five of those terms might be used to describe decaffeinate's output. IMO it's best to just say that decaffeinate produces JavaScript, and not any particular old version of JavaScript.

> Show me how you are going to make this pretty

Soak operations (anything with a question mark) are probably the hardest to convert to JavaScript, especially when they're chained. Here's what decaffeinate gives today:

http://decaffeinate-project.org/repl/#?evaluate=true&stage=f...

And here's an open bug with thoughts on making those look better: https://github.com/decaffeinate/decaffeinate/issues/336

But many people have still found decaffeinate useful since the vast majority of real-world CoffeeScript (at least from what I've seen) tends to convert pretty well, and even in difficult cases, it's better to safely get it in JavaScript first and then clean it up than to rewrite everything by hand.

  if (__guard__(does.that != null ? does.that.prop : undefined, x => x.exist)) { console.log('yes, no crash!'); }
  function __guard__(value, transform) {
    return (typeof value !== 'undefined' && value !== null) ? transform(value) : undefined;
  }
oh my..

This was 1 line of CS, how to clean this up without a chance of creating bugs?

How on earth is ESxxx an improvement on CS anyways? It's just not true, it's a leap back.