7 ms·
Of course CoffeeScript is its own language. What kind of requirements do you think a language requires that CoffeeScript doesn't meet?
by Me1000 14y ago
Of course CoffeeScript is its own language. What kind of requirements do you think a language requires that CoffeeScript doesn't meet?
- michael_fine 14y agoBecause it simply compiles down and is executed as Javascript. It doesn't (and can't) change anything but the syntax. Edit: It does add features like pattern matching and list comprehension, and anything can compile down to js, so I guess it is a separate language.
- tolmasky 14y agoBy this logic no language is a real language other than JavaScript, since as we've seen, you can make just about anything "simply compile down" to JavaScript. Let me put it another way. If I were to write a separate runtime that directly executed CoffeeScript (without JS as an intermediate step), would you then be satisfied that it is in fact a real language?
- michael_fine 14y agoNow that you say it, and I think about it more, I guess you're right. It does add features like list comprehension and pattern matching, and the compilation really is ambiguous.
- asynchrony 14y agoCoffeescript doesn't add pattern matching.
- michael_fine 14y agoCoffeescript has it, though it's formally called destructuring: http://jashkenas.github.com/coffee-script/#destructuring http://jashkenas.github.com/coffee-script/#destructuring
- jashkenas 14y agoAhem. That'd be "destructuring". http://wiki.ecmascript.org/doku.php?id=harmony:destructuring http://wiki.ecmascript.org/doku.php?id=harmony:destructuring
- riffraff 14y agodestructuring assignment is not really pattern matching, as the latter allows flow control and the former does not.
- epidemian 14y agoI think the difference between syntax and semantics can be quite blurred sometimes. For example, CoffeeScript embraces the "everything is an expression" philosophy and that's a pretty big difference for me compared to plain JS; it affects the way i write -and think about- code in a much deeper way than using indentation instead of braces. So, is the difference between having statements and expressions as different constructs and having only expressions just a syntactic difference? Another aspect in which CS differs from JS is that it provides built-in classes; which i think can make code written in CS much more consistent compared to JS, where everyone seems to like inventing their own way of writing classes. And i'm sure i'm forgetting other aspects in which CS differs from JS that i wouldn't consider "just syntactic".
- raganwald 14y agoMy suggestion: For some language X where Y “compiles to “ X, Y is a new language if it introduces new semantics. For example, pure functional semantics, or object-orientation, or pattern matching, or method flavours, or static typing. One easy test for this is to ask whether compiling Y to X can be done in small chunks or whether it requires “Whole program rewriting.” For example, transforming a program with continuations into CPS requires whole-program rewriting. I would call any language that adds continuations to JavaScript a new language on that basis alone. CoffeeScript is almost entirely local transformations. I think of it as JavaScript.
- jonmrodriguez 14y agoWhy is this downvoted? Seems like a reasonable suggestion, and I don't see the haters suggesting alternative criteria...
- endtime 14y agoI didn't downvote him, but one alternative is that a language is defined by a grammar. Of course you'd want to group certain very similar grammars together as one language (Python 2.x and 3.x), but the grammars of CoffeeScript and JavaScript are significantly different.
- raganwald 14y agoThat’s also a reasonable definition. Since I didn’t say “if and only if,” both definitions are compatible. By the grammar definition, we could make a language with pure JavaScript semantics but Lisp-ish s-exprs, and it would be a different language as well.
- adeelk 14y agoThis seems like a reasonable definition. Does CoffeeScript not have its own idioms, though? I’ve never used it myself, but a search turned up this chapter on idioms in “The Little Book on CoffeeScript”: http://arcturo.github.com/library/coffeescript/04_idioms.html http://arcturo.github.com/library/coffeescript/04_idioms.htm...