Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Isn't this simply a category error? C++98 and C++0x aren't separate languages, nor are Python 2.x and 3.x. CoffeeScript has good branding, but is it really its own language?


Of course CoffeeScript is its own language. What kind of requirements do you think a language requires that CoffeeScript doesn't meet?


My 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.


But CoffeeScript does introduce new semantics. To name a few:

• a classical object model, complete with super()

• forced strict equality

• loop-local index variables (gets around the setTimeout(function() {console.log(i)}, 100) problem)

• all variables local unless explicitly declared otherwise

• CoffeeScript's splat arrays are totally different from JavaScript's arguments object

• list comprehensions (whether this is a semantic or syntactic change is debatable, I suppose, but the same could be said for basic OO)

• everything is an expression

The last one is a biggie that completely changes the meaning of many seemingly identical blocks of code. If that isn't a semantic change, what is?


I think differently in CS vs JS. I go for different solutions because they seem more elegant in CS than they did in JS. And if language shapes how we think, then surely thinking differently makes it a different language. Maybe.


This 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.htm...


What about if it removes harmful semantics?

Javascript has a distinction between statements and expressions, while to my knowledge CoffeeScript does not. "Everything is an expression" is a huge difference in semantics even though nothing has been added.


Let us suppose that languages BE and LE were designed completely independently, but came up with the same semantics in a different syntactic packet. For arguments' sake, let's suppose Google made one and Apple the other. They had different marketing budgets, different logos, different conferences. Religious wars were fought over them. Even though they had identical semantics.

Are they the same language?


Why is this downvoted? Seems like a reasonable suggestion, and I don't see the haters suggesting alternative criteria...


I 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.


That’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.


Because 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.


I 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".


By 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?


Now 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.


Coffeescript doesn't add pattern matching.


Coffeescript has it, though it's formally called destructuring: http://jashkenas.github.com/coffee-script/#destructuring


destructuring assignment is not really pattern matching, as the latter allows flow control and the former does not.



A programming language is independent of its implementation. If web browsers supported CoffeeScript natively, would that make it more of a language?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: