-
Notifications
You must be signed in to change notification settings - Fork 48
improvements
satyr edited this page May 11, 2011
·
22 revisions
$ git log -1 --format=oneline
09712603c4638933ec86efffc919c270e41256ad coffee-script 1.1.0
$ ls -sk extras/*.js
160 extras/coffee-script.js
$ cake loc
2411
$ cake bench
Lex 2353 ms (21690 tokens)
Rewrite 227 ms (24177 tokens)
Parse 274 ms
Compile 225 ms (131059 chars)
total 3079 ms
$ cd ../coco
$ git log -1 --format=oneline
4d51b68e94bc71f10851015566000a8c08961742 0.5.0
$ ls -sk extras/*.js
128 extras/coco.js*
$ coke loc
2276
$ coke bench
Lex 2123 ms (23037 tokens)
Rewrite 179 ms (26858 tokens)
Parse 225 ms (23342 nodes)
Compile 153 ms (136071 chars)
TOTAL 2680 ms
Coco uses them more wisely than Coffee, making generated code cleaner and/or faster.
$ coffee -bpe '[i for i in a]'
var i;
[
(function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = a.length; _i < _len; _i++) {
i = a[_i];
_results.push(i);
}
return _results;
})()
];
$ coco -bpe '[i for i of a]'
var i;
[
(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 -bpe 'a < b() < c; d > e() > f'
var _ref, _ref2;
(a < (_ref = b()) && _ref < c);
(d > (_ref2 = e()) && _ref2 > f);
$ coco -bpe 'a < b() < c; d > e() > f'
var _ref;
a < (_ref = b()) && _ref < c;
d > (_ref = e()) && _ref > f;
$ coffee -bpe '=> this'
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments)
; }; };
__bind(function() {
return this;
}, this);
$ coco -bpe '~> this'
var _this = this;
(function(){
return _this;
});
$ coffee -bpe 'r = for k of o then arguments'
var k, r;
r = (function() {
var _results;
_results = [];
for (k in o) {
_results.push(arguments);
}
return _results;
}).apply(this, arguments);
$ coco -bpe 'r = for k in o then arguments'
var k, r;
r = (function(_args){
var _results = [];
for (k in o) {
_results.push(_args);
}
return _results;
}(arguments));
$ coffee -bpe 'Math += 1'
Math += 1;
$ coco -bpe 'Math += 1'
SyntaxError: assignment to undeclared variable "Math" on line 1
$ coffee -bpe 'a:1, a:2'
({
a: 1,
a: 2
});
$ coco -bpe 'a:1, a:2'
SyntaxError: duplicate property name "a" on line 1
$ coffee -bpe '[]()'
[]();
$ coco -bpe '[]()'
SyntaxError: invalid callee on line 1
$ coffee -bpe '/+/'
/+/;
$ coco -bpe '/+/'
SyntaxError: Invalid regular expression: /+/: Nothing to repeat on line 1