Actually, this problem could not occur in JavaScript, because ES6+ will always be backwards compatible with the current version of JavaScript. Further, the “1JS” principle means that you will be able to take existing code and opt into new features simply by using the new syntax (there will be no “use es6” pragma or version switch).
The core difference is that ES6 is, by definition and by requirement, a strict superset of current JavaScript. By definition, there can be no new syntax that is incompatible with existing JavaScript.
In contrast, how would CoffeeScript target the new for/of
loops, when they already have for/of
loops of their own? Sure, they could add new syntax, but it would be massively confusing for for/of
to target the old semantics, and some other syntax to target ES6 for/of
.
Similarly, CoffeeScript classes and super
have subtly different semantics than ES6 classes and super
. If CoffeeScript started targeting the new semantics, they would break existing code. If they required a different keyword to target ES6 class
, it would, again, be very confusing.
You could imagine an incompatible CoffeeScript 2 that targeted ES6 syntax, but existing CoffeeScript code would not work. Again, this cannot happen in future versions of JavaScript, because new JavaScript features are required not to break existing JavaScript code.
It may be a bit difficult to wrap your mind around the difference, but I assure you, it’s true.