5 ms·
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 obj
by raganwald 14y ago
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.
- 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...
- technomancy 14y agoWhat 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.
- chc 14y agoBut 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?
- pbiggar 14y agoI 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.
- pbiggar 14y agoLet 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?