News for hackers. Stuff that matters.
Re:Announcing CoffeeScript 2 by ralmidani on Monday September 18, 2017 @12:54PM (#15277486)
CoffeeScript is still very relevant for me. I have two medium-sized Ember projects written in CoffeeScript (and Emblem and Sass--the original, indented variety, thank you very much).

I have been looking at React (will probably skip due to the patent license) and Vue, but cannot imagine going back to semicolons and (excessive) curly braces and parens.

If you married CoffeeScript just out of convenience (being able to avoid prototypes, bind, etc.), then it no longer serves much of a purpose. But if, like me, you fell in love with CoffeeScript's beauty, then no amount of ES6+ features will make it obsolete (as long as you can also keep using those features directly in CoffeeScript).

Re:Announcing CoffeeScript 2 by ripexz on Monday September 18, 2017 @04:08PM (#15279083)
With Vue.js you can use Coffeescript (alongside others) as well as SCSS, Pug, etc in single file components using lang="coffee" attribute in the script (or style or template for the others) tag. Need to add a couple more dependencies to your package.json but it works like a charm.

https://vuejs.org/v2/guide/single-file-components.html

Re:Announcing CoffeeScript 2 by rmetzler on Monday September 18, 2017 @02:53PM (#15278471)
I loved CoffeeScript, but I felt it was a double edged sword.

I would still use it though, if there were JSX style xml/html tags. But React changed everything for me and as a full stack dev, I can use only few frameworks on one level.

Edit: Ok, JSX is now supported. http://coffeescript.org/v2/#jsx

And I'm glad they broke the different behaviour of =>. It might need a fix in a lot of code bases, but this price is cheaper than having the mental burden of it.

Re:Announcing CoffeeScript 2 by rapind on Monday September 18, 2017 @05:40PM (#15279882)
I personally can't stand jsx, and coffeescript makes it so much nicer to avoid when using React. It's almost like haml / slim / jade / pug if you know what I mean.

I wrote a comparison about it a couple years ago: http://rapin.com/blog/2015/02/03/reactjs-with-coffeescript/

I'm not doing much react these days (cough elm), but I think it's still mostly relevant.

Re:Announcing CoffeeScript 2 by cies on Tuesday September 19, 2017 @10:58AM (#15285208)
Elm... And not to forget PureScript... and to a lesser extend ReasonML (by which you can still use React and JSX)... and Haskell/GHCJS. There are quite a lot of ways to seek refuge from both type scarcity and the "semicolon" line noise that was mentioned.

Here some benchmarks for several of the FWs that are popular in these languages (Elm has the FW built-in, ReasonML-React is missing but should be close to React.js).

https://medium.com/@saurabhnanda/benchmarks-fp-languages-lib...

Re:Announcing CoffeeScript 2 by desireco42 on Tuesday September 19, 2017 @10:14AM (#15284765)
Yeah, Elm is the bomb! Had to grin when I saw your comment. I am really happy with this refactor of Coffeescript but Elm is what I do.
Re:Announcing CoffeeScript 2 by ddlsmurf on Monday September 18, 2017 @06:11PM (#15280137)
I'm not a big fan of the new =>, it means the arguments variable will have parent scope in => but not in ->, it kind of erodes into coffeescript's elegance/consistency imho, unless I'm missing something ?
Re:Announcing CoffeeScript 2 by rmetzler on Monday September 18, 2017 @08:02PM (#15280758)
I never used => but when JavaScript introduced the fat arrow and made it different from the fat arrow in CoffeeScript, this introduced a mental barrier for me. By definition, the JavaScript fat arrow is the important one to know.
Re:Announcing CoffeeScript 2 by DiThi on Tuesday September 19, 2017 @11:19AM (#15285387)
You can always add an splat to use instead of arguments:

    (args...) =>
Re:Announcing CoffeeScript 2 by ddlsmurf on Tuesday September 19, 2017 @01:59PM (#15287090)
Sure, but there used to be a strong performance advantage when using the arguments variable with function.apply, also editing arguments' values affected named parameters' values (not sure that's desirable, but you know, semantics)
Re:Announcing CoffeeScript 2 by twykke on Monday September 18, 2017 @01:29PM (#15277780)
i also don't use CoffeeScript because of any 'feature' it has over standard JS but instead because of its concise but expressive syntax. it's less about what it does have/do, and more about what it doesn't have/do.

some small aspects of CS i forgo because they (in my opinion) are a little too concise such that they sacrifice readability, but all in all it has my favorite syntax of any language.

Re:Announcing CoffeeScript 2 by ralmidani on Monday September 18, 2017 @01:39PM (#15277879)
Exactly.

I personally think calling .map() on an array is more readable than an array comprehension. But since CS is "just JavaScript" you are free to use the native JS array methods (and even more elegantly, at that).

Re:Announcing CoffeeScript 2 by twykke on Monday September 18, 2017 @01:41PM (#15277904)
list comprehensions was exactly what i was talking about :) however i replace them with lodash and ramda, which benefit enormously from CS's lambda syntax
Re:Announcing CoffeeScript 2 by atom-morgan on Monday September 18, 2017 @02:15PM (#15278173)
I wish this line of thinking was more common. So many people feel forced to use parts of a language when you don't have to.
Re:Announcing CoffeeScript 2 by sgustard on Monday September 18, 2017 @07:27PM (#15280588)
CS breaks the ternary ?: operator which is a big headache for me.
Re:Announcing CoffeeScript 2 by igl on Tuesday September 19, 2017 @05:07AM (#15282922)
Everything is an expression. Including if statements. There is no need of such syntax abominations.
Re:Announcing CoffeeScript 2 by jashkenas on Tuesday September 19, 2017 @10:20AM (#15284813)
Bingo. Remember when you first first learned the ternary operator syntax? I recall thinking something along the lines of, "Wow, that's cryptic!"

    result = if condition then success else failure
Re:Announcing CoffeeScript 2 by sgustard on Thursday September 21, 2017 @11:35AM (#15304495)
Sure, but other coffee operations like x||=5 are also abominations. Brevity and purity are often at odds and the choices made by a language can be arbitrary.
Re:Announcing CoffeeScript 2 by dugmartin on Monday September 18, 2017 @03:08PM (#15278605)
I felt the same way when I switched from CoffeeScript to TypeScript but the type checking was worth all the braces, returns and lack of existential operator. If CoffeeScript added an (optional) type system I'd switch back in an instant.
Re:Announcing CoffeeScript 2 by GeoffreyBooth on Monday September 18, 2017 @04:02PM (#15279014)
It’s not elegant, but there is a way to do type checking in CoffeeScript: http://coffeescript.org/#type-annotations
Re:Announcing CoffeeScript 2 by Yaggo on Tuesday September 19, 2017 @05:36AM (#15283049)
This is cool! That being said, it would be very nice to have (optional) syntactically more beautiful type annotation. I assume Flow must be compatible with regular javascript, but CoffeeScript could take more flexible approach. I have no idea what the actual syntax could be, though.
Re:Announcing CoffeeScript 2 by ralmidani on Monday September 18, 2017 @05:08PM (#15279606)
Thanks for the link. :)

But wow, "not elegant" is an understatement.

Re:Announcing CoffeeScript 2 by kbp on Monday September 18, 2017 @03:59PM (#15278989)
> If CoffeeScript added an (optional) type system I'd switch back in an instant.

The home page talks a little about achieving this by using Flow annotations in Coffeescript source and then having the build system pass the Javascript output to Flow: http://coffeescript.org/#type-annotations

Re:Announcing CoffeeScript 2 by ralmidani on Monday September 18, 2017 @03:29PM (#15278769)
That would be really nice, but CoffeeScript will probably not be adding types unless they start adding them to JavaScript.

It is a dilemma, but so far I have gotten by without type-checking.

Re:Announcing CoffeeScript 2 by vanderZwan on Monday September 18, 2017 @03:46PM (#15278892)
Well, guess it's time for someone to build yet another layer of abstraction by writing a typed superset that compiles-to-CoffeeScript then!

(I'm joking, but actually.. why not?)

Re:Announcing CoffeeScript 2 by petecox on Monday September 18, 2017 @09:29PM (#15281133)
call it ToffeeScript - a dialect of CoffeeScript that transpiles to TypeScript?
Re:Announcing CoffeeScript 2 by jashkenas on Monday September 18, 2017 @10:32PM (#15281349)
I'm afraid you're a few years too late!

https://github.com/jiangmiao/toffee-script

Re:Announcing CoffeeScript 2 by rattray on Tuesday September 19, 2017 @03:50AM (#15282558)
You might like LightScript: http://lightscript.org

Good interop with Flow isn't quite there yet, though.

Re:Announcing CoffeeScript 2 by methyl on Monday September 18, 2017 @01:34PM (#15277832)
> cannot imagine going back to semicolons

Actually, Javascript does not require semicolons to be present. If you skip them, the only edge-case is when you try to start your line with `[` or `(`. In that case, you can prefix the line with `;`.

Re:Announcing CoffeeScript 2 by ralmidani on Monday September 18, 2017 @01:42PM (#15277909)
I like consistency. And I am paranoid. When I write JS, I always include semicolons. When I write CS, it is a non-issue.
Re:Announcing CoffeeScript 2 by pramodliv1 on Monday September 18, 2017 @03:34PM (#15278803)
> And I am paranoid

You should write tests when building a project in a dynamically typed language to alleviate some paranoia anyway. As long as you have decent test coverage and use a decent linter/formatter such as StandardJS[0] or prettier[1], you'll be fine.

[0]https://standardjs.com/ [1]https://github.com/prettier/prettier

Re:Announcing CoffeeScript 2 by sli on Thursday September 21, 2017 @10:35AM (#15303821)
Yeah, if your linter/build tool can't handle Javascript that doesn't have semicolons, it should be considered fundamentally broken and/or incomplete.

So the question to me becomes, if the build tool doesn't correctly parse the JS that's lacking semicolons, should you really trust that build tool with the rest of your code? You already know at that point that it doesn't handle your otherwise-valid semicolonless JS correctly.

Re:Announcing CoffeeScript 2 by acjohnson55 on Monday September 18, 2017 @09:57PM (#15281236)
It must be said though that CS has its own headscratchers in terms of parsing, if you choose to leave off all optional punctuation.
Re:Announcing CoffeeScript 2 by ralmidani on Wednesday September 20, 2017 @09:08AM (#15293298)
I agree. With great power comes great responsibility. Just because you can leave out all punctuation with CoffeeScript, it doesn't mean you should.
Re:Announcing CoffeeScript 2 by akvadrako on Monday September 18, 2017 @02:25PM (#15278257)
I consistently don't use semicolons in JS. It's just noise.
Re:Announcing CoffeeScript 2 by jdmichal on Monday September 18, 2017 @02:33PM (#15278317)
Omitting semicolons breaks the "delete a line in isolation" rule, unless you begin the line with a semicolon instead. Which is even noiser than just having them at the end of the line, where they are unconsciously glossed over by anyone who's ever worked in a language with C-derived syntax.
Re:Announcing CoffeeScript 2 by RussianCow on Monday September 18, 2017 @02:41PM (#15278374)
I hear this a lot, but in ~4 years writing JavaScript without semicolons, I've had to do this maybe two or three times. I just don't feel like starting a line with [ or ( is very common, to the point that it's a complete non-issue to me.
Re:Announcing CoffeeScript 2 by tga on Tuesday September 19, 2017 @01:01AM (#15281921)
In the majority of cases you can't "delete a line in isolation", because it's part of a program. You have to look around and understand what the impact of deleting that line will be -- and modify nearby lines as necessary.
Re:Announcing CoffeeScript 2 by vanderZwan on Monday September 18, 2017 @03:47PM (#15278901)
I have my VSC set up to automatically format and insert semicolons when I save. Saves a lot of hassle.
Re:Announcing CoffeeScript 2 by boubiyeah on Monday September 18, 2017 @04:03PM (#15279030)
And with Typescript (or a linter, I guess) you would get a nice red line on that 1 out of a million line where a ; is needed.

; are eyesores to an already fairly technical debt heavy/bloated language.

Re:Announcing CoffeeScript 2 by Bahamut on Monday September 18, 2017 @02:40PM (#15278369)
There is a nasty edge case if you concatenate scripts and use an IIFE in a script
Re:Announcing CoffeeScript 2 by rattray on Tuesday September 19, 2017 @03:55AM (#15282583)
There's more than just those edge-cases, but the others are rare in practice. They include +, -, `, < (JSX), ::, / (regex) and maybe a few others.

There's also some odd ASI issues within class bodies.

https://github.com/prettier/prettier/pull/1129 can be a useful reference (and tool!)

Re:Announcing CoffeeScript 2 by the_gipsy on Tuesday September 19, 2017 @07:49AM (#15283741)
also `{` after a return without value
Re:Announcing CoffeeScript 2 by andrei_says_ on Monday September 18, 2017 @07:45PM (#15280660)
I feel very much the same. My first language is Ruby and CS just clicked.

I continue using it in my Vue projects and it's a pleasure.

I appreciate the work the team has put into bringing elegance and brevity to my daily life.

Re:Announcing CoffeeScript 2 by TheAceOfHearts on Tuesday September 19, 2017 @10:29PM (#15290314)
Might I suggest trying out JavaScript Standard Style [0]? It has editor plugins and a CLI tool for linting.

You can write JavaScript just fine without semicolons. I used to be in the same camp, but Feross eventually convinced me to try dropping em. Despite being cautious and a bit skeptical, I tried it out in a few projects by removing all semicolons with a search and replace. In every single case, I encountered zero issues.

[0] https://standardjs.com

Re:Announcing CoffeeScript 2 by drumttocs8 on Thursday September 21, 2017 @09:31AM (#15303121)
Maybe it's just me, but I can't imagine dealing with scope without those little curly braces. They give a definitive beginning and end I can see, rather than trust my indents are correct. But maybe I just didn't give Coffeescript enough time to get used to it.
Re:Announcing CoffeeScript 2 by snarkyturtle on Monday September 18, 2017 @08:09PM (#15280790)
It's easier when you use something like Prettier which formats the code for you, same workflow as coffeescript except less work and possibly more readability.
Re:Announcing CoffeeScript 2 by alwillis on Tuesday September 19, 2017 @12:11AM (#15281714)
I just started a new project and decided to go back to the indented Sass syntax as well. Makes a nice compliment with CoffeeScript, Halm, Slim, etc.