
CoffeeScript 1.7.0 - jashkenas
http://coffeescript.org#changelog
======
jashkenas
There's also a nice writeup of some of the more user-visible changes available
here:
[https://gist.github.com/aseemk/8637896](https://gist.github.com/aseemk/8637896)

~~~
jashkenas
_(couldn 't edit parent, so)_

Top 3 things tl;dr

Paren-free chaining (think jQuery or d3):

    
    
        bar = svg.append 'rect'
          .attr 'fill', 'papayawhip'
          .attr 'width', width
          .attr 'height', 0
          .attr 'y', height
          .attr 'data-hover', data.slug
    

Ellipsis for soaking up matching parameters, even if you don't want to name a
variable:

    
    
        [first, ..., last] = arrayOfStuff
    
        lastArgumentFn = (..., last) -> last
    

... and generally improved source maps.

~~~
kaonashi
Nice… I had been using '__', but it seems like this will allow you to use it
multiple times in a parameter list.

~~~
couchand
It's even cooler than throwaway names [0]. You can index from the back:

    
    
      arr = [1, 2, 3]
      [..., two, three] = arr
    

or look for node-style callbacks...

    
    
      myFun = (..., cb) ->
        cb()
    

But you can't use it multiple times. That would allow for ambiguous syntax:

    
    
      # disallowed
      [..., whatAmI, ...] = [1, 2, 3, 4]
    

[0] [https://gist.github.com/aseemk/8637896#expansion-in-array-
de...](https://gist.github.com/aseemk/8637896#expansion-in-array-
destructuring)

------
elwell
Let's all take a moment to reflect on the elegance of the grammar.coffee file
[0]. Notice how the function named 'o' provides simplicity as it plays well
paren-less function calls.

[0] - [https://github.com/jashkenas/coffee-
script/blob/master/src/g...](https://github.com/jashkenas/coffee-
script/blob/master/src/grammar.coffee#L70)

~~~
aroman
Wow that is insanely beautiful to my eyes — thanks for pointing this out! Only
thing that might make it better would be a litcoffee version :)

~~~
elwell
Thanks for pointing out litcoffee.

------
neals
Is coffeescript still hip? I used to read a lot about it on here, maybe a year
or two. Where is it at? Mainstream?

~~~
L8D
There has been a development of hate towards CoffeeScript in most JavaScript
communities. CoffeeScript seems to be very popular in the non-JS communities
that need to write JavaScript, like in the Ruby and Python web development
communities. CoffeeScript was designed for non-JS coders to feel a lot more
comfortable writing JS.

~~~
vectorpush
_There has been a development of hate towards CoffeeScript in most JavaScript
communities._

This is FUD. CoffeeScript _is_ JavaScript, and if you come into CoffeeScript
thinking it works like ruby just because it looks like ruby then you're in for
a rude awakening.

Personally, I'm a fan of CoffeeScript's streamlined syntax compared to
JavaScript.

For example:

    
    
      describe 'when the universe exists', -> 
        it 'should be active', -> 
          expect(universe.active).toBe true
    

vs

    
    
      describe('when the universe exists', function(){
        it('should be active', function(){
          expect(universe.active).toBe(true);
        });
      });
    

It's no surprise that newcomers are sometimes inclined towards CoffeeScript
since one the biggest obstacles for a budding javascript programmer is the
seemingly incomprehensible labyrinth of brackets, parenthesis and semicolons
(not to mention the confusion that ASI adds to the picture) that one must
endure to grok the language. Of course, it's not really _that_ hard to
understand, but CoffeeScript filters out a lot of "syntax" making it easier
for a newcomer to tackle the meat of the application. Less is more.

~~~
nickfargo
And moreover,

    
    
        describe 'syntax after upgrading', ->
          it 'should be even meatier', ->
            expect parentheses.required
              .toBe false
    

Very tidy.

------
davidbanham
Updated the wrapper.js script we use to run uncompiled coffeescript files in
node. It now checks for the existence of .register() and calls it if it's
available.

[https://gist.github.com/davidbanham/8678004](https://gist.github.com/davidbanham/8678004)

------
winslow
I absolutely love CoffeeScript, with how it structures classes and functions
makes sense (plus the python like syntax was a big plus for work). JavaScript
seemed to unorganized, unclear, and cluttered for big projects.

~~~
thinkpad20
I do a fair amount of coffeescript work and every time I see the compiled
source I'm so glad that I'm writing in coffeescript. It's not just that it
makes certain JS gotchas almost non-issues (almost! there are still several
things that can trip you up), it's that it makes clean, concise and correct
programming so much easier. There are a lot of things, like curried functions
(`f = (a) -> (b) -> result`) or testing for membership in a list (`if foo in
[a, b, c]`) which one is much more likely to use in coffeescript than
JavaScript because the syntax is so much nicer. Having good syntax doesn't
just make it easier to read and write, it promotes good habits and discourages
bad ones.

~~~
smrtinsert
If I weren't coding ClojureScript now I would at least be in CS. CS is nice,
but Clojure is just too strong a language.

~~~
thinkpad20
I still need to try out ClojureScript. I've heard great things. I prefer the
coffeescript syntax, though...

------
Kerrick
This should make consuming promises a lot more readable!

    
    
        api.get 'comments/1'
        .then transformComment
        .then (comment) ->
          appendwithEvents comment, 'click'
          cacheComment comment
        .fail console.error

------
tieTYT
> Leading . now closes all open calls, allowing for simpler chaining syntax.

I feel like this is an important improvement, but I don't really understand
what it means. Can someone elaborate on what this means and how it works? How
did things used to be different?

~~~
bobbyi_settv
It would have been nice if their code example for this feature showed how the
code would have looked in the prior version of Coffeescript.

~~~
xixixao

      $('body')
      .click (e) ->
        $('.box')
        .fadeIn('fast')
        .addClass '.active'
      .css 'background', 'white'
    

If I omit as many parentheses as possible. Also for the other example:

    
    
      result = range(1, 3)
        .concat(range 4, 6)
        .map((x) -> x * x)
        .filter (x) -> x % 2 is 0

------
ilaksh
I love the paren-free chaining but

>When requiring CoffeeScript files in Node you must now explicitly register
the compiler. This can be done with require 'coffee-script/register' or
CoffeeScript.register(). Also for configuration such as Mocha's, use coffee-
script/register.

Since I have not been specifying my CoffeeScript version, I have a feeling
this update is going to break a lot of my Node.js code. Am I right?

~~~
xixixao
If you are running your code via 'coffee' or if you are compiling your code to
JS this won't affect you.

------
drinchev
The greatest thing that I found in 1.7.0 is a step towards JSDoc with better
comment support :

    
    
        ###*
        # Test
        ###
    

will be compiled to

    
    
        /**
         * Test
         */
    

And until now

    
    
        /**
        # Test
        */

------
ajayjain
What does %% do? The documentation says: a %% b is the same as (a % b + b) %
b, but what is the difference between "true mathematical modulo" and the
standard modulo?

~~~
paradoja
I guess: -2 % 6 = -2, but -2 %% 6 = 4.

~~~
btmills
Yep. I think the name for it is true or Euclidean modulo. Here's the pull
request that introduced it and two other new operators:
[https://github.com/jashkenas/coffee-
script/pull/2887](https://github.com/jashkenas/coffee-script/pull/2887)

------
yanivt
Woohoo! Been wanting to chain without parens for a while. Much appreciated
change!

------
brokenparser
// for integer division instead of comments? Are these guys on crack?

~~~
yefim
# has always been for comments. What are you talking about?

~~~
oblio
Furthermore, # has been used for comments before //, so he's even "wronger"
than he probably thought :)

