Skip to content

Instantly share code, notes, and snippets.

@7fe
Created September 28, 2011 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7fe/1248911 to your computer and use it in GitHub Desktop.
Save 7fe/1248911 to your computer and use it in GitHub Desktop.
CoffeeScript isn't simpler

Although the following examples could use parenthesis, the issue demonstrates how a trivially overlooked ending delimiter further complicated the language. Not only is the intent of the CoffeScript code unclear in these examples but the slight variation in the CoffeScript, produces radically different output. The CoffeeScript differences are so small it would be easy for someone to add accidentally while editing. Anonymous function passing and function calling in Javascript require no additional wrappers or edits, while in CoffeeScript you must add special case clarity for something commonplace in Javascript.

foo ->
  bar 'foo'
, -> 'bar'

compiles into:

foo(function() {
  return bar('foo');
}, function() {
  return 'bar';
});
foo ->
bar 'foo'
, -> 'bar'

compiles into:

foo(function() {});

bar('foo', function() {
  return 'bar';
});
foo -> bar 'foo'
, -> 'bar'

compiles into:

foo(function() {
  return bar('foo', function() {
    return 'bar';
  });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment