4 ms·
This is why I don't use it. I know JS well, I can think in JS. Changing the syntax is fine but altering semantics in subtle ways would probably drive me crazy.
by badman_ting 13y ago
This is why I don't use it. I know JS well, I can think in JS. Changing the syntax is fine but altering semantics in subtle ways would probably drive me crazy.
- tomphoolery 13y agoIt doesn't really alter the semantics, if you recognize that CoffeeScript always adds `var` before variable assignments, you can just get around that by attaching a variable you want to share to a higher scope by using `this.whatever = 'foo'`. It's really not as hard as people make it out to be, but there are still plenty of killer reasons not to use CS (for example, if you don't feel like learning it...I mean JS is just as good, it does all the same stuff).
- calebio 13y agoI love vanilla JS, but I also love CoffeeScript. I think the thing that I love the most about CS is it's looping constructs (just the ability to iterate over an array without typing a for loop then another variable to get the item out) that have a custom step and when filter is pretty nice. That saves me quite a bit of time in the long run.
- emn13 13y agoIn modern JS (easily polyfilled), there are map, reduce, filter, and forEach for this. These have the further advantage of being more easily chained; however they're a lot slower too. One downside of coffeescript's loop comprehensions is that they generate fairly complex code whenever you use them in non-trivial ways, thus undermining coffeescript's key feature: easily readable (and debuggable) javascript.
- couchand 13y agoIf I really do need an explicit scope I find myself writing `foo = no` higher up which actually seems pretty natural, if a bit verbose (as many characters as `var `...)
- DougBTX 13y agoCoffeeScript doesn't always add var before assignments though, sometimes it does, sometimes it doesn't, depending on the variables in outer scopes. This has two assignments, but only one var in the compiled JS: a = 1 -> a = 2 This has two vars: -> a = 1 -> a = 2
- emn13 13y agoMuch worse is this gotcha: One variable: a = 1 -> a = 2 Two variables: -> a = 2 a = 1