$ git log -1 --oneline
79492aa CoffeeScript 1.3.3
$ ls -sk extras/co*.js
176 extras/coffee-script.js
$ cake loc
2659
$ cake bench
Lex 1520 ms (24184 tokens)
Rewrite 186 ms (26925 tokens)
Parse 368 ms
Compile 285 ms (149588 chars)
total 2359 ms
$ git log -1 --oneline
dcff170 0.7.2
$ ls -sk extras/co*.js
160 extras/coco.js
$ coke loc
2499
$ coke bench
Lex 469 ms (26005 tokens)
Rewrite 200 ms (31203 tokens)
Parse 539 ms (26737 nodes)
Compile 341 ms (174118 chars)
TOTAL 1549 ms
Temporary Variables
Coco uses them more wisely than Coffee, making generated code cleaner and/or faster.
$coffee-bce'[i for i in a]'// Generated by CoffeeScript 1.3.3vari;[(function(){var_i,_len,_results;_results=[];for(_i=0,_len=a.length;_i<_len;_i++){i=a[_i];_results.push(i);}return_results;})()];
$coco-bce'[i for i of a]'vari;[(function(){var__i,__ref,__len,__results=[];for(__i=0,__len=(__ref=a).length;__i<__len;++__i){i=__ref[__i];__results.push(i);}return__results;}())];
$coffee-bce'a > b() > c; d > e() > f'// Generated by CoffeeScript 1.3.3var_ref,_ref1;(a>(_ref=b())&&_ref>c);(d>(_ref1=e())&&_ref1>f);
$coco-bce'a > b() > c; d > e() > f'var__ref;a>(__ref=b())&&__ref>c;d>(__ref=e())&&__ref>f;
$coffee-bce'r = for k of o then arguments'// Generated by CoffeeScript 1.3.3vark,r;r=(function(){var_results;_results=[];for(kino){_results.push(arguments);}return_results;}).apply(this,arguments);
$coco-bce'r = for k in o then arguments'vark,r,__res,__i,__ref,__len;__res=[];for(__i=0,__len=(__ref=o).length;__i<__len;++__i){k=__ref[__i];__res.push(arguments);}r=__res;
Compile Errors
variable safety
$ coffee -bce 'Math += 1'
// Generated by CoffeeScript 1.3.3
Math += 1;
$ coco -bce 'Math += 1'
SyntaxError: assignment to undeclared variable "Math" on line 1
$ coffee -bce 'x = (return)'
SyntaxError: cannot use a pure statement in an expression.
...
$ coco -bce 'x = (return)'
SyntaxError: inconvertible statement on line 1
...
`
space/tab contamination
$ cat space_tab.coffee
if 0
console.log 1
console.log 2
$ coffee space_tab.coffee
2
$ coco space_tab.coffee
Failed at: space_tab.coffee
SyntaxError: contaminated indent %09 on line 2
misdentation
$ cat misdent.coffee
if 0
console.log 1
console.log 2
$ coffee misdent.coffee
2
$ coco misdent.coffee
Failed at: misdent.coffee
SyntaxError: unmatched dedent (2 for 4) on line 3
invalid call
$ coffee -bce '[]()'
// Generated by CoffeeScript 1.3.3
[]();
$ coco -bce '[]()'
SyntaxError: invalid callee on line 1
invalid regex
$ coffee -bce '/+/'
// Generated by CoffeeScript 1.3.3
/+/;
$ coco -bce '/+/'
SyntaxError: Invalid regular expression: /+/: Nothing to repeat on line 1
invalid identifier
$ coffee -bce '$= 1'
// Generated by CoffeeScript 1.3.3
var $;
$ = 1;
$ coco -bce '$= 1'
Error: Parse error on line 1: Unexpected '$'
$ node -e '$= 1'
undefined:1
^
SyntaxError: Unexpected token ILLEGAL
invalid operand
$ coffee -bce '0 instanceof 1'
// Generated by CoffeeScript 1.3.3
0 instanceof 1;
$ coco -bce '0 instanceof 1'
SyntaxError: invalid instanceof operand on line 1
$ node -e '0 instanceof 1'
undefined:1
^
TypeError: Expecting a functionin instanceof check, but got 0
Syntax Consistency
@foo ⇔ this.foo
$coffee-bce'{@foo}'// Generated by CoffeeScript 1.3.3({foo: this.foo});$coffee-bce'{this.foo}'
Error: Parse erroronline1: Unexpected'THIS'...
$ coffee -bce 'f k: v, a + b'
Error: Parse error on line 1: Unexpected '+'
...
$ coffee -bce 'k: f a, ->'
Error: Parse error on line 1: Unexpected ','
...
$coco-bce'f k: v, a + b'f({k: v},a+b);$coco-bce'k: f a, ->'({k: f(a,function(){})});
$ coffee -bcs
f
k: v
a
// Generated by CoffeeScript 1.3.3
f({
k: v
}, a);
$ coffee -bcs
f
a
k: v
Error: Parse error on line 2: Unexpected 'INDENT'
...
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
Learn more.
We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products.
You can always update your selection by clicking Cookie Preferences at the bottom of the page.
For more information, see our Privacy Statement.
Essential cookies
We use essential cookies to perform essential website functions, e.g. they're used to log you in.
Learn more
Always active
Analytics cookies
We use analytics cookies to understand how you use our websites so we can make them better, e.g. they're used to gather information about the pages you visit and how many clicks you need to accomplish a task.
Learn more
✕
Wait! Don't Go Yet 🚀
Get our FREE eBook "10 Programming Tips That Changed Everything" when you subscribe!