Many people don't like that CS needs to be compiled. I don't see this as an issue since pretty much every application I work on these days is concatenated and uglified. So adding a JS compiler is already part of most JS application's build process. 6to5 is being compiled to ES5 anyway. Also, if you include in your build pipeline a source mapper, debugging is not a problem.
The "I understand CS code much quicker" argument is a valid one theoretically, but In my opinion, it does not hold up practically that well.
CS got one thing wrong that Python got right: There are many ways to do things.
When writing CS, I understood MY CS just fine... but it always took me longer to understand the CS of other people. Sometimes even longer than JS. This is such a huge drawback, and even if there is coffeelint, for teams, this is deadly.
A lot of devs need to read a fair amount of foreign code. Even worse a lot of coffeescript writers also need to read and understand a lot of JS code.
Understanding and reading YOUR code slightly faster gets mitigated by having longer to understand foreign code.
While some JS purists fail to see that Coffeescript has some benefits, CS people also underestimate how "quickly" you can understand JS code, if you're experienced. It's all about what your brain is trained to do.
In my opinion, with ES6, I would argue for most people (ceteris paribus) it just makes sense to read and write JS exlusively, if you want to maximize output-productivity of a full, practical project.
Shaving off a couple of seconds "understand-time" of your personal, well written CS vs well written JS will just not compensate other things that will take you longer to do with CS.
Of course you can reduce the JS verbosity with JSX instead... which again is introducing a pre-processor to the mix (one I personally am not a fan of, but w/e).
ES6 adds some sweet stuff for sure, but IMO it doesn't make JS a pleasure to work with yet (which seems to be the argument?).
I'm willing to bet it's not going to reduce the count in this list by much. https://github.com/jashkenas/coffeescript/wiki/list-of-langu...
I'm comfortable writing either as I'm sure many are, but when given the choice I opt for CoffeeScript.
P.S. Good luck telling someone using ClojureScript that they should switch back to Javascript.
I don't think this is necessarily true anymore, if it ever was. For hash-like datastructures in Python, please choose between object/dict/namedtuple/enum. In JS/CS all higher-level manipulations are dealt with through functions, whereas in Python depending on the situation you need factories, decorators, metaclasses and so on. And on a purely practical level people are moving away from the standard library (instead preferring arrow, requests, various unittest replacements etc.) but you'll still want to know the stdlib equivalents in case you encounter them in other code... and I can keep going like this.
I'm not saying this is necessarily a bad thing, sometimes one-size-fits-all just doesn't cut it, I just don't think Python can lay claim to being a simple language anymore.
Hopefully you realize that most Rubyists will strongly disagree and think that's not a "problem".
I know this might not sound like a big deal in the grand scheme of things, but I also don't think CoffeeScript really improves on js all that much, so the annoyances of source maps are just not worth it to me personally.
It's much easier to read indentation than it is to match up pairs of brackets in your head. In other languages, if the indentation doesn't match the brackets, you'll naturally read the indentation first and get the wrong impression of what the code does. In those languages, the indentation is supposed to match the brackets anyway. Why be redundant like that?
Your last paragraph makes little sense as you should never, ever be debugging a problem on live and I think minification has caused me a problem like twice in the 8 years since it's been popular. And it was pretty obvious when it did as the is wasn't even compiling.
Development builds should use concatenated and minified .js code. That verifies that the development build performs exactly like the production build.
You can use source maps to help with debugging.
CoffeeScript is a fun little experiment in what's possible when you take JavaScript semantics and try to boil down the user interface to a minimalist surface. But JavaScript will always keep on rolling onwards — and to the extent that future versions of JavaScript take any minor inspiration or reference or overlap with things that CoffeeScript already does, the more the better.
For example, see this talk from four (!) years ago: https://www.youtube.com/watch?v=QTj6Q_zV1yg
There's more than one way to skin the JavaScript cat.
In other news, CoffeeScript 1.9.0 came out yesterday — with support for ES6 generator functions. A-la Python, in CoffeeScript, a generator is simply a function that "yield"s.
> * CoffeeScript is an attempt to expose the good parts of JavaScript through syntax that favors expressions over statements, cuts down on punctuation noise, and provides pretty function literals.
That said, I hope it slowly fades into the background as more people go back to vanilla ES6 or go with something more powerful such as TypeScript (or Flux). With the progress around es6 and es7, gradual typing, macros, and other tooling around the language, I think CoffeeScript risks becoming a drag on getting people to learn modern JS and instead sticking with a language that has a lot of ambiguous constructions and fewer and fewer advantages over JS.
.my-div %h1 Some Text - some_ruby_code
vs the ERB of
<div class="my-div> <%h1> Some Text </h1> <% some_ruby_code %> </div>
As others have said, it's all fun and games until two people edit the same source file, one of whom has the dangerously incorrect opinion that tabs are better than spaces :-)
I use a lot of semantic whitespace languages (CS, Haskell, Python), and it's a tradeoff: you gain in terms of redundancy, true, but there's an additional human overhead of making sure everyone's got their editors set up correctly. The larger the team, and a fortiori the number of teams, the bigger that overhead is. Smacking people about the head with PEP8 goes quite close to solving the problem in the Python world, but CS's Rubyish commitment to TIMTOWTDI militates against that.
"It's like SASS vs. SCSS. Or Haml vs. ERB. I can't, for the life of me figure out why anyone would prefer more to less."
Because HTML and CSS, despite their verbosity, are linguae francae. A CSS file is valid SCSS by definition - a less technical prototyper person can give you their code (perhaps even generated code from some wysiwig monstrosity) and you can refactor over it to remove redundancy, enforce conventions etc using the special SASS sauce. The SASS syntax does not.
A HTML file, likewise, is already an ERB file. HAML is 'backwards compatible' with ERB/plain HTML, so far as I recall, but mixing the two syntaxes is very, very ugly and a dreadful idea, and I'm not sure if it's possible to mix the two in similar template languages (Jade etc).
Point is: there is a human factor involved in picking shinier toys. I like HAML/Jade type templates, and Coffeescript for that matter, but I am far more comfortable using them on small teams or solo projects.
That being said, you're absolutely right, folks who write in Coffee should also absolutely eventually learn all the tips and tricks behind vanilla js also if they don't want to be bogged down.
But the future of CoffeeScript is bleak because many software designers are beginning to understand the value of type systems, e.g. TypeScript and Flow, for building maintainable Javascript code bases, and this means CoffeeScript is out of the picture for good because its long term design goal is to remain a minimalistic language, and doesn't intend to support these ideas. There have been attempts[0] to fork it to add a legitimate type system to it so it can scale, but they have faltered. Aside from that, the way CS deals with variable shadowing[1] makes it risky to use in large codebases.
So when ES6 syntax is tolerable and stable, I will pack my bags and move over to the ES6 land with great regret. I wish I could stay in CS land for longer, but you have to put away childish things eventually.
------------
[0] https://www.npmjs.com/package/typed-coffee-script
[1] http://stackoverflow.com/questions/15223430/why-is-coffeescr...
It's also worth pointing out that CS and ES6 aren't really comparable technologies. ES6 isn't some newfangled preprocessor that simplifies syntax, it's an update to the standard which JS adheres to. CS is fundamentally limited because it compiles to ES5.1. When ES6 is implemented in browsers, CS will be able to do more.
-------------------
[0] elm-lang.org
it solves a lot of the problems that CoffeeScript is trying to solve without drastic syntax changes.
I cannot speak to authorial intent, but for me the majority of the problems CoffeeScript(and moreso LiveScript) solves are syntax ones.You can start using transforms that provide features other than ES6: https://6to5.org/docs/usage/transformers/
So from my perspective ES6 is the best of both worlds - the better syntax of Javascript and the features that Coffeescript gave you.
But it's not an objective fact that coffeescript's syntax is better. I prefer ES6. And even if you prefer coffeescript, it seems strange to claim that the most critical feature is purely aesthetic.
It seems better to treat JavaScript as admittedly not being the most powerful language in the world, and to treat the standard as a kind of RFC that only compiler writers have to think about. For most programmers it works to just use CoffeeScript (or Lisp or anything) without worrying about standards, just as JavaScript programmers don't need to worry about how their processor works.
Kind of a Java plugin that runs on web, instead of just tunneling through it.
This isn't an issue for node projects as you can simply `require` the `coffee-script/register` module and node handles coffee scripts for you via normal `requires`.
* Optional braces and parenthesis. Results in visually cleaner and more compact code, especially when dealing with large objects.
* Requiring backticks to do string interpolation seems like an ugly hack.
* CS uses dots to slice and splice ranges:
host?.split(".")[-1..][0] == "dns"
BTW, notice in the example above two additional CS features that don't exist in ES6:* The existential operator `?` soaks up null/undefined references.
* `==` is compiled to `===`
* Expressions always return a value in CS, just like in Lisp, so no need to explicitly `return`
* Block strings and regular expressions.
And more: http://coffeescript.org/
Plus, CS just seems like it's always a step ahead of JS. In using it, you can code in a more intelligently designed language that enforces best-practices better than JS does. Doing so supports diversity, innovations (after all, many of these ES6 features are obviously inspired by CS).
Why abandon such a wonderful language when it still has so much to offer, and at the same time seems to be driving innovation in JavaScript itself?
This seemingly minor feature is so huge for me. Accessing deep objects?.is?.a?.horrible?.pain?.sometimes?()
http://kangax.github.io/compat-table/es6/
The main laggard for now is Safari/WebKit.
Developers are excited about new language features not because of browser support, but because it standardizes patterns they were already using (fat arrow functions, Promises, modules, classes, etc.) through CoffeeScript and third-party code.
(6to5 didn't even exist six months ago.)
And yes, this can be said for almost any tool choice, but my spidey sense tells me the half life for CS is about that of something like Jira.
Team size varies between 8 to 15 people, roughly.
ES5 has Function.bind
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
var Person = function(name) {
var self = this;
self.name = name
};
Person.prototype = new function() {
var prototype = this;
prototype.sayHello = function() {
var self = this;
return "Hello\n\n-- " + self.name;
};
};
var me = new Person('Peter');
console.log(me.sayHello());
Obviously that's a pretty contrived example but it illustrates the idea. It makes it really clear exactly what "this" means at different points in your code. As a bonus, if I had to reference the current context inside of a prototype method, "this" is now available.On that basis, if you must do this, I would suggest `var _this`, `var scope` (though that would probably be confusing if you had the misfortune to be using Angular), `var me` (unless you happen to find anthropomorphism distasteful) or... well, anything other than `var self`, really.
Also when working with external libraries and dependencies, I found myself resorting to trial and error figuring out the correct syntax because nearly all documentation is written in JS and not CS.
Classes:
There is no semicolon after the function name
The function keyword is omitted
There are no commas after each definition
Interpolation: `${1 + 1}` <- why not just # like everyone else?
Multi line strings: ` Now we have a 3rd
string delimiter`
Fat arrow: $("button").on("click", () => {
// really? hanging parens? no function keyword?
});
Destructuring: var [first, , last] = [1, 2, 3]
// thats a var to assign vals inside an array
// and just two commas touching to ignore a value
The whole post is about drastic syntax changes. The brackets are optional in coffeescript.Besides coffeescript is just a tool.
You mean like CS? '#' actually isn't a very popular choice for this.
The significant spaces thing was ironic given that Python is kind of the biggest competitor of Ruby (×) in the modern scripting languages space. Personally it's the main reason I'm not using CS (or Python or HAML or Slim), transpiling is number 2.
(×) kind of because Ruby is probably more successful in web development but less anywhere else.
In my opinion Ceylon nailed it:
class Person(variable String firstName, variable String lastName) {
shared String name => firstName + " " + lastName;
assign name {
value names = name.split().sequence();
firstName = names[0] else "";
lastName = names[1] else "";
}
}
Classes are effectively just closures with subtyping that export their shared members/functions.Unrelated: A simple class like that shouldn't be mutable.
TypeScript is pretty good at giving you a taste of ES6, it brings in a lot of features from ES6, such as the new classes, default arguments, generics, as well as a few of it's own features (interfaces, optional static type checking).
They ship it as a node module, so you can just "npm install -g typescript" and it's ready to go. As much as I dislike Microsoft, Typescript is something that seems to work well, and unlike Coffeescript, I can quite happily paste in standard Javascript code (even most ES6 code) and it won't break my source.
Short braceless code typesets beautifully, but you can probably get a similar effect w/ an appropriate 'braces highlight at lower contrast when autoindented as expected'.
To replace one tool with another, you need a compelling reason...and "it's almost at feature parity" is not that.
Other than that, the braces/indentation issue alone will keep people with CS. Can its compiler emit ES6, by the way?
Unfortunately, they didn't solve this with ES6.
Those features will be (or already are) ported to CoffeeScript.
And the CoffeeScript sugar is just tastier.
ES6 syntax is kind of CoffeeScript for people who hate meaningful indentination and it's quite decent for that purpose.
(Weak)Map, (Weak)Set, Symbol, Generators, Promises, Modules, Proxies... these aren't sugar.
Promises, modules we already had. Native implementation doesn't provide new functionality, just picks winners.
I'm really excited by generators and proxies but those are available in latest version of CoffeeScript already.