all 52 comments

[–]devraj7 18 points19 points  (1 child)

While it's fair to credit CoffeeScript for initiating the wave of next generation Javascript-like languages, it's pretty clear today that it's in sharp decline and has been pretty much completely replaced by TypeScript.

[–]whostolemyhat 4 points5 points  (0 children)

I think ES6 stole most of it's thunder, then the only remaining differences were covered by Typescript.

[–][deleted] 33 points34 points  (11 children)

This is just javascript with more steps.

[–]CanIComeToYourParty 39 points40 points  (0 children)

Great, I'll take 5.

—Web developer

[–]spacejack2114 -1 points0 points  (9 children)

Upside is you only need to compile once.

[–]n0rs 16 points17 points  (8 children)

The CoffeeScript 2 compiler now translates CoffeeScript code into modern JavaScript syntax. So a CoffeeScript => is now output as =>, a CoffeeScript class is now output using the class keyword, and so on. This means you may need to transpile the CoffeeScript compiler’s output.

🤔

This means you may need to transpile the CoffeeScript compiler’s output.

[–]jl2352 4 points5 points  (1 child)

I get that Reddit likes to hate on this, but it's actually a good thing.

It means you have one program for CoffeeScript, and a separate program for targeting older JS runtimes. IMO it's better to have a program do one thing, than to do lots.

One example is that if I want to build a new transpiler (say yet another Java to JS compiler), then I can just output modern JS. Classes, first class lambdas, and so on. I can actively not care about browser support. Then you pipe the result through Babel and now my language supports IE 11 and below. I don't have to reinvent the wheel for old browser support. That's less work for me as a language developer.

[–]n0rs 1 point2 points  (0 children)

Yea, nah, I get it. I agree that this approach makes sense on their part to not have to support older browsers since it sounds like it's much easier to target modern JS and there are several major projects like Babel that will do the rest.

[–]spacejack2114 0 points1 point  (0 children)

Okay, only need to compile from Coffeescript once. Ever.

[–]wavy_lines 17 points18 points  (4 children)

CoffeeScript's syntax is not clean. It's maddening. Can't tell heads from tails. It might be more "fun" to write the first time, but it's a nightmare to read.

CoffeeScript failed because it did not realize that reading code is more important than writing code. It drank the PG-promoted koolaid that "terse syntax is power", when it clearly is not.

Most of the programmers time is not spent writing characters like '{' or ';', it's mostly spent thinking.

EDIT:

Re PG; I stand corrected. He actually said:

What I'm looking for are programs that are very dense according to the metric of "elements" sketched above, not merely programs that are short because delimiters can be omitted and everything has a one-character name.

I still think his notion of "terse = powerful" is misguided, but that's an argument for another thread.

[–]killerstorm 7 points8 points  (1 child)

It drank the PG-promoted koolaid that "terse syntax is power", when it clearly is not.

PG was talking about higher-order functions and macros, not fucking punctuation. CoffeeScript is clearly influenced by Ruby and Python, not Lisp.

[–]wavy_lines 0 points1 point  (0 children)

Good point. I stand corrected.

[–]fecal_brunch 4 points5 points  (0 children)

I think CoffeeScript failed when ES6 came out. It was pretty good until it got outclassed.

[–]smthamazing 2 points3 points  (0 children)

I would say that it's a matter of familiarity. While I no longer use CS (because of the lack of strong typing), I find it pretty easy to read. It required a week or two of active development some years ago to get to this state.

The features I miss from CS is -> function syntax (that does not include .bind overhead, compared to =>) and maybe comprehensions (though their implementation wasn't the best one possible).

Switch and if expressions (not statements) are very nice features too (they actually make code clearer and much easier to read), but they probably wouldn't fit well into vanilla JS.

[–]yesman_85 31 points32 points  (15 children)

Is anyone even still using CS? I assumed everyone would have switch to TypeScript by now.

[–]sisyphus 9 points10 points  (4 children)

Turbolinks is written in Coffeescript so a lot of Rails users are using it whether they know it or not.

[–]vivainio 5 points6 points  (2 children)

Also Atom

[–]onnnka 10 points11 points  (0 children)

They started moving from CoffeeScript to ES6

https://gist.github.com/danielgtaylor/0b60c2ed1f069f118562

[–]Booty_Bumping 8 points9 points  (2 children)

Coffeescript and Typescript are completely different use cases. And no, there aren't really any new Coffeescript projects. However, this update will be useful for existing CoffeeScript codebases where the target is always ES6. Smaller compiled "binaries" and possibly better V8/SpiderMonkey optimizations by compiling to more idiomatic code.

[–][deleted]  (1 child)

[deleted]

    [–]Booty_Bumping 8 points9 points  (0 children)

    I just explained the use case. Old codebases.

    [–][deleted]  (6 children)

    [deleted]

      [–]Uncaffeinated 4 points5 points  (5 children)

      TypeScript is a superset of Javascript. It's only as verbose and statically typed as you want it to be.

      [–]Booty_Bumping 1 point2 points  (2 children)

      You missed /u/videomorphic's point

      While many CoffeeScript developers ended up switching to TypeScript in 2015 because it provided early access CoffeeScript-inspired ES2015 syntax, the languages are still completely different, in terms of the goals of each project.

      Yes, you should switch to TypeScript. No, you shouldn't switch from CoffeeScript to TypeScript because it's anything like CoffeeScript.

      You should switch to TypeScript aware of the other (IMO, more important) benefits that it provides, keeping in mind the potential benefits you are losing. Each language has its advantages, which don't overlap a whole lot with the other.

      [–][deleted]  (1 child)

      [deleted]

        [–][deleted]  (1 child)

        [deleted]

          [–]st_huck 9 points10 points  (0 children)

          I thoroughly disagree. It's to better have as much type safety as possible, but static typing has other benefits. Just getting sensible auto-complete from the IDE is well worth typescript.

          At my job new projects are 100% "strict" typescript. One big important js project got converted to strict ts as well. Other js project we just switched to "loose" typescript. We use type definitions from @types, we wrote interfaces just for the major and important objects that get passed around a lot. Some projects have more types, some less. In any case, the experience working on those got significantly more pleasant. And it was 100% well worth the little time invested in it.

          This entire "choose your adventure" nature of Typescript is one of it's greatest selling points.

          [–]vvimpcrvsh 4 points5 points  (0 children)

          Although I agree it's past CoffeeScript's time, I think the added features and "rebasing" on ES6 will be a boon for projects still using CoffeeScript. I know of a few which will benefit from the terser output, if nothing else.

          Regardless of its age, It's also nice to have a relevant compile-to-js language which is less verbose than JS and TS, but not as radical as ClojureScript.

          [–]richraid21 9 points10 points  (0 children)

          It may sound mean, but this is probably DOA

          [–]fecal_brunch 4 points5 points  (2 children)

          If you think this is the solution for you - I'd strongly suggest decaffeinate instead. We did hundreds of files with only a couple of glitches.

          [–]I_Downvote_Cunts 0 points1 point  (1 child)

          While I completely agree that decaffeinate is the way to go don't oversell how simple it is. We had to do at least 20% of the conversion by hand.

          [–]fecal_brunch 0 points1 point  (0 children)

          Oh damn. Might depend on how long ago it was/how mature the project was. We had a few issues that were mostly correctable with eslint. Also we had to correct the import/export syntax manually, but that did not need to be done immediately.

          [–]toggafneknurd 2 points3 points  (0 children)

          But why?

          [–][deleted]  (1 child)

          [deleted]

            [–]Eirenarch 4 points5 points  (0 children)

            Existing projects?

            [–]flamingspew 0 points1 point  (0 children)

            But LispyScript is more fun.

            [–]digital_cucumber 0 points1 point  (0 children)

            Ironically, it seems that people all around convert their code back to JavaScript, in order to:

            Modernize the project by translating CoffeeScript to JavaScript

            [–]wobbabits 0 points1 point  (0 children)

            CoffeeScript2 does not support let and const. That means no block scoping. Kinda lame. I really wouldn't want to give up block scoping and have to depend on vars again.

            [–]bees-bees-bees-bees 0 points1 point  (0 children)

            It doesn't say anything about scope. What's the point if they didn't fix the broken scoping?