Let's talk about Coffeescript

coffeescript
#1

I think Coffeescript is a nice language, but why is it going to the waste? why is its usage decreasing.
I think Coffeescript is better than JavaScript. Even after ES6 you can still write bad code in JavaScript, and BTW if you write ES6, ES7, you’re already compiling it to ES5, then why not compile Coffeescript to ES5?

I want to listen to what others say about Coffeescript.

Thank you!

#2

One argument that I’ve seen is that once es6 (and then es7) is supported by all browsers, you won’t need to run any transpilers at all.

I actually don’t see what coffescript provides over es6, unlike, for example, typescript.

#3

In my opinion, CoffeeScript is not different to JavaScript. Its just a different textual representation. Its pretty much like the difference between “1e6”, “1 * 10^6” and “1000000”.

CoffeScript does bring nothing new to JavaScript. It lets you run into the very same pitfalls, does have the very same std library, nothing more nothing less.

Its just a different set of syntax.

1 Like
#4

Yes, that’s a great point, but even then your Coffeescript’s generated ES5 will work correctly. :slight_smile:

#5

But why would you want to use obsoleted es5 when you can send a smaller bundle of es6 to the browsers without any shims?

1 Like
#6

Now this is the point. So if it’s like so, then there is no point in learning/using CoffeeScript, and this is the point which makes other languages like TypeScript, Dart or ELM more important than CoffeeScript.

#7

One thing more:

Does coffeescript only have the good parts of JavaScript (JavaScript the good parts), or the whole JavaScript? Because if it’s build on top of only the good parts, then it’s better than JavaScript.

#8

JavaScript the Good Parts is a moving target.

For example for “turning methods into functions” the semantics of the this object context dictates that you have to resort to

this.myMethod.bind(this);

before you hand myMethod over to be used as a function/handler. Once Class field declarations for JavaScript becomes standard (likely ES2019) a definition inside the class like:

myMethod = () => {
  // ... whatever
}

will be sufficient - no extra binds necessary. You can use this feature today with Babel.

With CoffeeScript lagging in adoption of ES.next features you would be actually be isolating yourself from some of the “good parts”.

While there is still something useful in the tc39 pipeline, transpilers are here to stay.

But having effectively embraced cross-compilation, why not add something of even greater value like sound static typing …

4 Likes
#9

I fully agree with @peerreynders. The methodName = (foo, bar, baz) => { ...} syntax might take a little getting used to, but it is just as readable as any other syntax.

If you want to have a more safe JavaScript, I think it is smarter to look for tool like e.g. flow which adds static type-checking in an opt-in fashion, that should reduce the amount of bugs.

2 Likes
#10

So, crazy idea, would it be possible to design a language that has the power of typescript and the simplicity of coffeescript?

I mean the appeal of coffeescript (at least for me) has always been its terse syntax: the ‘->’ for functions and being able to omit braces and parentheses. If we could somehow get static typing to integrate with those features of coffeescript would anyone be interested?

#11

I actually think that PureScript might be close to what you are looking for, since it has typing similar to to typescript (but even stronger, since it is an ML-based typing system), and allows you to use the syntactic sugar you’d like to use. :slight_smile:

#12

TypeScript, powerful typesystem? This statement fails at the moment when you realize that string is an alias to any

#13

What do you mean by this? I’ve been working a lot with TypeScript and I don’t understand what you mean. Sure “any” is escape latch to do anythign, but how is string an alias of “any”?

#14

Hmm… I can’t reproduce the issue, but I’m sure that about a year ago when I did some typescript on exercism let foo: string = 1 was possible, even though 1 was automatically coerced to "1".

Perhaps typescript has moved past that point in the meantime? Or my setup was borked back then?

#15

I have no idea, might have been a bug. It should have been an error something along that you cannot assign something of type 1 to type string.

#16

I think it’s called BuckleScript :slightly_smiling_face:

1 Like
#17

So… OCaml? ^.^

OCaml can even compile to the web via a couple of different ways too.

This is one of the OCaml->JS systems, makes very readable and pretty javascript, the other one is JSOO, which can compile a lot more than BS, but it puts out rather unreadable javascript. :slight_smile:

#18

FYI:

as a reaction to

Why would you NOT use TypeScript?

1 Like