News for hackers. Stuff that matters.
Re:Announcing CoffeeScript 2 by city41 on Monday September 18, 2017 @12:12PM (#15277118)
I can't imagine CoffeeScript will see much adoption these days as most people seem to think ES6+ is "good enough". I miss how concise functions are in CoffeeScript and also miss being able to do object literals without the braces. But there's no chance at all in convincing my team to adopt it, as modern JS really is "good enough".
Re:Announcing CoffeeScript 2 by jashkenas on Monday September 18, 2017 @12:18PM (#15277174)
And that's totally fine! I don't get a chance to use it much these days either.

But for the folks who still do — or have existing codebases — this update is for you.

Re:Announcing CoffeeScript 2 by munificent on Monday September 18, 2017 @01:32PM (#15277813)
I think it's worth remembering too that the reason JS is "good enough" for most these days is because of all of the great language features that you and friends put into CoffeeScript and which then got adopted by JS.
Re:Announcing CoffeeScript 2 by ethagnawl on Monday September 18, 2017 @05:13PM (#15279651)
This is not said often enough. Thanks, jashkenas!
Re:Announcing CoffeeScript 2 by anythrow123 on Monday September 18, 2017 @01:20PM (#15277715)
I still use CS every day on multiple projects. IMAO CS is one of the best non-typed languages out there. It's really sad that so many modern/babel JS proponents fail to see the beauty of it.

I hope that this release (and hopefully future releases) will help to keep CS alive. Thanks to all contributors!

Re:Announcing CoffeeScript 2 by jonnytran on Monday September 18, 2017 @12:24PM (#15277226)
Thank you! I love CoffeeScript! It's been so sad to see it slowly fade away in favor of, in my opinion, inferior and uglier things. I -- and many others, I'm sure -- appreciate this update a great deal. I hope I get to write beautiful CoffeeScript code again soon.

To parent post, why should we settle for "good enough"?

Re:Announcing CoffeeScript 2 by madeofpalk on Monday September 18, 2017 @12:37PM (#15277332)
> To parent post, why should we settle for "good enough"?

Because it's an actual standard and benefits from wider mindshare and support.

Re:Announcing CoffeeScript 2 by tmzt on Monday September 18, 2017 @12:30PM (#15277274)
Hey, I'm working on a template language that compiles into Redux + IncrementalDOM. Part of it involves a pipeline syntax similar to underscore or lodash. I'm wondering what you would consider a modern equivalent of those two libraries using native methods, iterators, etc. or if vanillajs is sufficient now.

If anyone wants to take a look it's at tmzt.github.io/isymtope and github.com/tmzt/isymtope

The #cleanup-symbols branch is much further along and has a mostly working TodoMvc.

Re:Announcing CoffeeScript 2 by jashkenas on Monday September 18, 2017 @12:43PM (#15277385)
Hmmm. If you're doing the compilation yourself, I'd imagine you could rely on what browsers provide these days, and compile to what you need. For the kinds of data transformations that templates tend to need, I wouldn't imagine that you'd really find a utility library to be necessary. Check out the Svelte output, for example.
Re:Announcing CoffeeScript 2 by acemarke on Monday September 18, 2017 @01:18PM (#15277697)
Very intriguing! I'm a Redux maintainer - please feel free to ping me if you've got any questions on the Redux side of things.
Re:Announcing CoffeeScript 2 by clairity on Monday September 18, 2017 @01:33PM (#15277819)
i really wanted to like coffeescript, but the idea of compiling, transpiling or any other kind of piling of javascript just rubbed me the wrong way. this is true of scss, less and other css flavors too.

i understand the problems these tools are trying to solve, but i don't like that you have to learn two (or more) grammars and syntaxes, and the quirky interactions between them, to get those benefits (because you can't debug one without debugging the other). it's a lot more cognitive overhead for what amounts to a little syntactic sugar.

standard es-whatever javascript needs to be "good enough", and, despite my disdain for using coffeescript, the improvements that coffeescript induced in javascript are heartily welcomed.

Re:Announcing CoffeeScript 2 by 8ytecoder on Monday September 18, 2017 @02:02PM (#15278064)
If you automate it and it's part of your deployment pipeline, you'd hardly notice it's there. We use both SCSS and CS via Rails and it's a breeze. The occasional times when I don't understand why something is not working I go to the coffeescript website and read the transpiled code and it's usually obvious what's going on.
Re:Announcing CoffeeScript 2 by clairity on Tuesday September 19, 2017 @05:04PM (#15288786)
yes, i have dependencies that use both scss and coffeescript, so it's part of the deployment pipeline. i just don't like using them much myself =P
Re:Announcing CoffeeScript 2 by tedmiston on Monday September 18, 2017 @11:30PM (#15281584)
> it's a lot more cognitive overhead for what amounts to a little syntactic sugar.

This isn't really accurate with respect to meta languages like SCSS that add new features not present in the underlying language, like variables.

You really are missing out on a lot by not using the meta languages.

Re:Announcing CoffeeScript 2 by clairity on Tuesday September 19, 2017 @05:07PM (#15288811)
yes, variables are nice. hopefully the glacially slow integration of them into css proper (css custom properties) will arrive soon: https://developer.mozilla.org/en-US/docs/Web/CSS/--*
Re:Announcing CoffeeScript 2 by molszanski on Tuesday September 19, 2017 @02:14AM (#15282188)
> the idea of compiling, transpiling or any other kind of piling of javascript just rubbed me the wrong way.

Well, this is how a lot of JS (if not most) is done today anyway.

Re:Announcing CoffeeScript 2 by jmcgough on Monday September 18, 2017 @01:05PM (#15277594)
I miss some elements of coffeescript (the existential operator was really cool), but I think in some ways it served its purpose: large parts of it were lifted for use in es6.

These days we have typescript as another option, and I feel like there's more gains from that than the syntactic niceness of coffeescript.

Re:Announcing CoffeeScript 2 by tootie on Monday September 18, 2017 @04:33PM (#15279267)
I honestly think both ES6, Coffee and the like are going in the absolute wrong direction. Every release replaces more keywords with punctuation marks. That's the reason the community abandoned Perl. How much productivity do I gain by replacing "function()" with "() =>"? Round and round we go.

Before anyone tells me, yes I know the semantics are slightly different, but muddling the semantics with arcane syntax is not an optimal solution.

Re:Announcing CoffeeScript 2 by awinder on Monday September 18, 2017 @09:18PM (#15281082)
I’m going to tell you anyways :-D. function() { ... }.bind(this) is the correct comparison to () => { ... }, which is not only a productivity gain but a readability gain.
Re:Announcing CoffeeScript 2 by city41 on Monday September 18, 2017 @05:26PM (#15279746)
I think the comparison to perl isn't fair. It's pretty accepted that () => is a function type construct. It mimics lambdas and function calls in many other languages. Perl did really crazy stuff like storing regex results in obscure global variables.

As for () =>, it can make a big difference in scenarios like `myArray.map(a => a.foo)` versus `myArray.map(function(a) { return a.foo })`

Re:Announcing CoffeeScript 2 by fineline on Monday September 18, 2017 @06:28PM (#15280252)
>> Every release replaces more keywords with punctuation marks.

I can't think of any other examples. Closures get used heavily in JS and arrow functions do make their use quicker and more concise, as well as fixing `this`. Compared to other languages like Scala, OCaml, Elm and Haskell, with symbols for functional combination and pipelining, pattern matching, and whatever you call the thing where you can miss out parameters and use underscores in function bodies in Scala ... JS is relatively light on symbols.

Re:Announcing CoffeeScript 2 by sandstrom on Monday September 18, 2017 @01:11PM (#15277640)
This is true (few adopting coffeescript), but CoffeeScript influenced much of todays ES6+, so it still lives on :)
Re:Announcing CoffeeScript 2 by camus2 on Monday September 18, 2017 @12:36PM (#15277319)
The only reason most people used CS was short hand function declaration and classes, It really made writing javascript easier as dealing explicitly with prototypes is a pain in the ass AND it also eliminated differences between browsers when it came to JS implementation (yes IE8 was still a thing back then).

All these things are irrelevant today.

1/ Most of CS features are supported by javascript

2/ ECMASCRIPT spec is big and complex. Learning another syntax on top of something every front end developer should know is a wasted effort in my opinion.

Re:Announcing CoffeeScript 2 by DiThi on Monday September 18, 2017 @12:56PM (#15277517)
> The only reason most people used CS was short hand function declaration and classes

And for loops (which double as list comprehensions). And the existential operator. And "this." shorthand. Among other reasons. To my team it's also more clean-looking than Python (which used to be my favourite language), esp. when using a good syntax highlighter like Atom's (or at least that differentiates function calls, like Github's).

Yes, there's not much difference now from ES6 regarding features, but for some of us it's still worth it.

Re:Announcing CoffeeScript 2 by melling on Monday September 18, 2017 @12:24PM (#15277223)
I was browsing the CoffeeScript docs and everything looks much more concise. It seems like your code would half the size. Have people done real world comparisons on large code bases? Rewrites?
Re:Announcing CoffeeScript 2 by williamdclt on Monday September 18, 2017 @12:48PM (#15277434)
We did. And had to "decaffeinate" everything a few months later because it is hell to work with implicit returns, objects without brackets, no spread operator, significant whitespace, no variable declaration keyword...

It really is a matter of taste, but the large majority of us didn't like it. It is pretty, but I felt like fighting against the language all the time (implicitly returning an bracketless object is not something that's easily readable)

Re:Announcing CoffeeScript 2 by DiThi on Monday September 18, 2017 @01:08PM (#15277611)
> implicit returns

In my experience it has only been a problem when porting existing code bases. We only had to be a bit careful putting a return after a for loop at the end of a function so it doesn't build a list unnecessarily (otherwise implicit returns of unused random values don't hurt). For clarity, one of the few rules we have is to use return explicitly when a function is more than a single expression.

> objects without brackets

The language allows it but it doesn't mean you must use them. We have a loose style guide where we forbid a few confusing uses (like bracket-less one liners or returned objects). So loose it's shorter than this comment.

> no spread operator

It always had a spread operator (except for the first month of life). It's just called splat instead of spread, like in Python. Now it also allows ES6 syntax which is very similar (...foo vs. foo...).

> significant whitespace

That's not a bug, it's a feature ;)

> no variable declaration keyword

In the last year or two, that only bite us once. If it's more frequent than that your functions are way too long.

But as you say, it's a matter of taste.

Re:Announcing CoffeeScript 2 by twykke on Monday September 18, 2017 @01:37PM (#15277865)
some colleagues of mine have complained about the significant whitespace being difficult to understand. i can't argue with something subjective like that.

however i like to point that our entire codebase, CS, JS, TS, Python, Java, Swift, 100% of it already has significant whitespace.

...it's just that the JS/TS/Java also have curly brackets.

Re:Announcing CoffeeScript 2 by pmontra on Monday September 18, 2017 @10:19PM (#15281293)
I'm not sure I understood. I don't know about Swift but do JS and Java have significant whitespace?
Re:Announcing CoffeeScript 2 by jonnytran on Monday September 18, 2017 @10:30PM (#15281341)
No, twykke is saying that in almost every language, even ones that don't technically have significant whitespace, people still use coding conventions and style guides that restrict whitespace to match the curly braces. Some people even use automated commit hooks to reject commits that don't follow the guide.

The end result (or arguably, driving force) is that even in languages where whitespace isn't significant, people read the whitespace, not the curly braces. So the curly braces are basically redundant noise.

Re:Announcing CoffeeScript 2 by pmontra on Monday September 18, 2017 @10:39PM (#15281369)
Ok, thanks.

I agree about { } being mostly noise but I think they are the lesser evil. I'm making most of my money with Python and I still believe significant whitespace is a very bad idea. The Ruby alternative of using end is better even if not super elegant (and Ruby is my language of choice). It's on par with curly braces. After 30+ years of programming I still have to find a satisfying solution to the problem.

Re:Announcing CoffeeScript 2 by jashkenas on Monday September 18, 2017 @01:27PM (#15277773)
From the perspective of how it was intended to be used, you've got it exactly right. Just because you can implicitly return a braceless object, doesn't mean you should.
Re:Announcing CoffeeScript 2 by twykke on Monday September 18, 2017 @01:45PM (#15277928)
i tend to use an explicit return except in one-line functions; there are plenty of CS features you can forgo if you don't think they benefit you.
Re:Announcing CoffeeScript 2 by fivesigma on Monday September 18, 2017 @01:34PM (#15277836)
This mirrors my experience as well. Try having a relatively simple piece of code exhaust all available memory because CS was kind enough to turn a simple loop into a clusterfuck of epic proportions all because you forgot to return null on a function that well, doesn't need to return anything. Then you go and decaffeinate the entire thing, actually look at the JS output and your jaw drops at the amount of useless crap that your "syntactic sugar" added. Is it really worth it?

This could easily be fixed by adding a -!> operator that disables implicit returns, but no, they are so opinionated that a change like that will ruin their perfect little universe. I know that there are forks that add this sort of functionality among fixing some of my other gripes with CS but my point still stands: I'm not going to invest my time into a cult.

Re:Announcing CoffeeScript 2 by cookiecaper on Tuesday September 19, 2017 @03:14PM (#15287904)
Yes, CoffeeScript is chaos. I've found that CS's biggest proponents can be heard to say "Let's just replace it with a custom thing I'll build this weekend" much more frequently than normal. Surely this is coincidental. ;)

The old joke was that Perl is a write-only language, and CoffeeScript et al are essentially thought experiments for how deep into the write-only abyss people are willing to plunge as a non-joke. It's no mystery that CS primarily attracts people who heavily discount the importance of long-term maintainability.

The core issue seems to be that some people have conflated prescience with elegance. We must stop deluding ourselves into pretending there are languages that can read our minds. Put your intent in the code, avoid ambiguity. If the answer is not obvious and consistent, do not rely on either the computer or the human to extract your intent from the ether.

Re:Announcing CoffeeScript 2 by cos_ on Tuesday October 03, 2017 @01:45AM (#15390433)
Speak for yourself! :)
Re:Announcing CoffeeScript 2 by fiatjaf on Monday September 18, 2017 @02:10PM (#15278129)
Oh, object literals without the braces, how much I miss you!
Re:Announcing CoffeeScript 2 by hasenj on Tuesday September 19, 2017 @12:19AM (#15281743)
I don't miss how "concise" it is. Concise syntax usually means "fun to write, hell to read".

It's not that ES6 is good enough; it's that CoffeeScript is actually "bad".

Re:Announcing CoffeeScript 2 by DiThi on Tuesday September 19, 2017 @11:25AM (#15285449)
I find idiomatic CS easier to read than idiomatic JS. Matter of taste.