Live data from Hacker News

Replace CoffeeScript with ES6

robots.thoughtbot.com

11–20 of 178 posts

Re: Replace CoffeeScript with ES6

#11
post #3

Yes and no. Although we get some fantastic features, one of the most critical- the ability to neglect parens and curly braces- is lost in es6. I'm working on an es6 project right now and still prefer coffeescript.

It sounds like it would be relatively easy to write a preprocessor to do only this

Re: Replace CoffeeScript with ES6

#13

Note that self = this is kind of a legacy hack for binding 'this'. ES5 has Function.bind https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

If you want to call something that increases performance by 50% a hack, feel free, but I'm going to use that hack until that's not the case.

Re: Replace CoffeeScript with ES6

#14
post #7

I give credit to CoffeeScript with really helping to push the ES specs forward and think it helped introduce more people to JS and grow the ecosystem. Heck, I used it for a year, liked it, and had it change some of my approaches to writing JS. That said, I hope it slowly fades into the background as more people go back to vanilla ES6 or go with something more powerful such as TypeScript (or Flux). With the progress a…

It's also possible folks will continue forking and improving CoffeeScript so that it keeps up with future releases of vanilla js (which is actually what I hope will continue to happen). Folks like me who come from a Ruby / Python background really don't like brackets and declaring variables, so things like Coffeescript, LiveScript, CoCo, etc. are wonderful tools even despite their occasional moments of weakness.

That being said, you're absolutely right, folks who write in Coffee should also absolutely eventually learn all the tips and tricks behind vanilla js also if they don't want to be bogged down.

Re: Replace CoffeeScript with ES6

#19
post #2

Why not both? This makes a good argument for ES6, but CoffeeScript's fundamental changes to syntax are just preferred by some.

Because one day ES6 will run in browsers without a build step.

In my experience all non-trivial frontend project I've worked on have ended up with some kind of build step (minification, linting, concating, ect), with or without a compile2JS language.

This isn't an issue for node projects as you can simply `require` the `coffee-script/register` module and node handles coffee scripts for you via normal `requires`.

Re: Replace CoffeeScript with ES6

#20

Note that self = this is kind of a legacy hack for binding 'this'. ES5 has Function.bind https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

It can also be nice when you're writing instance methods on a prototype. for instance:

    var Person = function(name) {
      var self = this;
      self.name = name
    };

    Person.prototype = new function() {
      var prototype = this;

      prototype.sayHello = function() {
        var self = this;
        return "Hello\n\n-- " + self.name;
      };
    };

    var me = new Person('Peter');
    console.log(me.sayHello());
Obviously that's a pretty contrived example but it illustrates the idea. It makes it really clear exactly what "this" means at different points in your code. As a bonus, if I had to reference the current context inside of a prototype method, "this" is now available.
Post reply on HN