Live data from Hacker News

Replace CoffeeScript with ES6

robots.thoughtbot.com

171–178 of 178 posts

Re: Replace CoffeeScript with ES6

#171
I'm surprised nobody has mentioned TypeScript. I've been using it in one of my projects recently (WebStorm even has a file watcher that works with very little set up on my Macbook).

TypeScript is pretty good at giving you a taste of ES6, it brings in a lot of features from ES6, such as the new classes, default arguments, generics, as well as a few of it's own features (interfaces, optional static type checking).

They ship it as a node module, so you can just "npm install -g typescript" and it's ready to go. As much as I dislike Microsoft, Typescript is something that seems to work well, and unlike Coffeescript, I can quite happily paste in standard Javascript code (even most ES6 code) and it won't break my source.

Re: Replace CoffeeScript with ES6

#172
post #92

The reason that I like CoffeeScript is that it removes, what I consider, the unnecessary boilerplate of JavaScript and replaces it with a shorthand equivalent and good conventions. I feel that CoffeeScript is better at representing the intent of JS than JS. I can visually sift through CoffeeScript and understand the code much quicker than normal JavaScript, which in my opinion leads to more maintainable code. I'm not…

Ex-Coffeescript ,now Javascript with lot's of Python experience guy here. The "I understand CS code much quicker" argument is a valid one theoretically, but In my opinion, it does not hold up practically that well. CS got one thing wrong that Python got right: There are many ways to do things. When writing CS, I understood MY CS just fine... but it always took me longer to understand the CS of other people. Sometimes…

> CS got one thing wrong that Python got right: There are many ways to do things.

I don't think this is necessarily true anymore, if it ever was. For hash-like datastructures in Python, please choose between object/dict/namedtuple/enum. In JS/CS all higher-level manipulations are dealt with through functions, whereas in Python depending on the situation you need factories, decorators, metaclasses and so on. And on a purely practical level people are moving away from the standard library (instead preferring arrow, requests, various unittest replacements etc.) but you'll still want to know the stdlib equivalents in case you encounter them in other code... and I can keep going like this.

I'm not saying this is necessarily a bad thing, sometimes one-size-fits-all just doesn't cut it, I just don't think Python can lay claim to being a simple language anymore.

Re: Replace CoffeeScript with ES6

#173
Braces combined w/ something like clang-format or gofmt are clearly better. Perhaps a really advanced editor (that most people don't use) could offer a similar experience for braceless (sig. indent) languages.

Short braceless code typesets beautifully, but you can probably get a similar effect w/ an appropriate 'braces highlight at lower contrast when autoindented as expected'.

Re: Replace CoffeeScript with ES6

#175

Earlier quoted context omitted.

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 illustr…

I don't like `var self` at all and I find there are vanishingly few places where you can't just bind a function appropriately, but one important thing to note, if you do go down this route, is that `self` is an alias for the `window` object, so if you happen to miss out that `var self` assignment at some point, you may get unexpected results. On that basis, if you must do this, I would suggest `var _this`, `var scope…

Interesting, I never knew that `self === window` – thanks for bringing that up. I'm not particularly attached to the name, just wanted to show an example where assigning `this` to some local variable is useful.

Re: Replace CoffeeScript with ES6

#176
post #163

Earlier quoted context omitted.

"it doesn't make JS a pleasure to work with yet (which seems to be the argument?)" My interpretation of what Retozi is saying is that CS just means that in addition to understanding JS, including ES6, you need to be familiar with all the different ways things can be done in CS. I tend to agree, especially as JS is becoming an improving with each release. What I'd like to see going forward is JS continuing to add sele…

My experience is the exact opposite. I find that CS removes a lot of the JS gotchas, and I'm not clear on the many ways that CS let's you do something, especially in comparison to JS. If anything it protects you a bit, by trying to enforce some of the "good parts". http://arcturo.github.io/library/coffeescript/07_the_bad_par... To each his own, but to me CS has been and continues to be a complete and obvious win over…

On the multiple ways, I was sure I read a post that documented them all and had me nodding along but can't find it, this one seems good though [1].

[1] http://ceronman.com/2012/09/17/coffeescript-less-typing-bad-...

Re: Replace CoffeeScript with ES6

#177
post #163

Earlier quoted context omitted.

"it doesn't make JS a pleasure to work with yet (which seems to be the argument?)" My interpretation of what Retozi is saying is that CS just means that in addition to understanding JS, including ES6, you need to be familiar with all the different ways things can be done in CS. I tend to agree, especially as JS is becoming an improving with each release. What I'd like to see going forward is JS continuing to add sele…

My experience is the exact opposite. I find that CS removes a lot of the JS gotchas, and I'm not clear on the many ways that CS let's you do something, especially in comparison to JS. If anything it protects you a bit, by trying to enforce some of the "good parts". http://arcturo.github.io/library/coffeescript/07_the_bad_par... To each his own, but to me CS has been and continues to be a complete and obvious win over…

On the multiple ways, I was sure I read a post that documented them all and had me nodding along but can't find it, this one seems good though [1].

[1] http://ceronman.com/2012/09/17/coffeescript-less-typing-bad-...

Re: Replace CoffeeScript with ES6

#178
post #163

Earlier quoted context omitted.

My experience is the exact opposite. I find that CS removes a lot of the JS gotchas, and I'm not clear on the many ways that CS let's you do something, especially in comparison to JS. If anything it protects you a bit, by trying to enforce some of the "good parts". http://arcturo.github.io/library/coffeescript/07_the_bad_par... To each his own, but to me CS has been and continues to be a complete and obvious win over…

On the multiple ways, I was sure I read a post that documented them all and had me nodding along but can't find it, this one seems good though [1]. [1] http://ceronman.com/2012/09/17/coffeescript-less-typing-bad-...

Out of all of those points, it's really just the commas and curlies that I've found can lead to some confusion, in my experience at least.

I haven't come up with a better approach than simply agreeing on a convention with your team though TBH. It's not too bad when everyone's on the same page and familiar with the gotchas (same could be said for most langs).

I put together a post comparing some of the syntax differences as it relates to building ReactJS components in case you're interested: http://rapin.com/blog/2015/02/03/reactjs-with-coffeescript/

Given that JS itself has quite a few different ways to do things though, it's kind of a wash.

Post reply on HN